Skip to content

Prove DFlash and EAGLE3 GGUF draft runtime - #695

Merged
justinchuby merged 8 commits into
mainfrom
justinchuby-prove-draft-model-evidence
Aug 28, 2026
Merged

justinchuby merged 8 commits into
mainfrom
justinchuby-prove-draft-model-evidence

Conversation

@justinchuby

@justinchuby justinchuby commented Aug 28, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add exact target/draft GGUF pair construction with separate cache namespaces, target hidden-state outputs, shared embedding/LM-head bridges, atomic package publication, and self-verifying graph identities.
  • Add a direct ONNX Runtime greedy coordinator for DFlash and EAGLE3 with accepted-prefix verification, target/draft cache rollback, compressed-vocabulary remapping, strict output-capacity bounds, and target-only baseline comparison.
  • Add a separate test-only direct ORT oracle that imports neither DraftPairRunner nor production transition helpers, derives target-layer/remap/block/mask contracts from raw immutable GGUF metadata, and compares production behavior against independently recorded transitions.
  • Make EAGLE3 consume real draft-owned embeddings, normalize GGUF/HuggingFace hidden-state indices correctly, and preserve fully-owned cross-width variants.
  • Semantically rebase onto exact current main at d68f66418096e0fe9a073764b819d6898de314de, integrating Add standalone GGUF audio projector routes #696, Allow GGUF export with deferred tokenizers #693, and Add OCR and document GGUF projector cohort #691 while retaining shared MTP cache/publication/status infrastructure without duplication.
  • Keep higher-level runtime compatibility advisory; no production revision pin or downstream runtime gate is added.

Immutable evidence

Evidence is bound in testdata/evidence/gguf_draft_runtime_evidence.json (13,293,887,389 bytes total, below the 16 GiB cap), including artifact/config/tokenizer/source/graph/package/runtime hashes. Separate SHA-256-bound independent traces record every proposal ID/remapped token and proposal-logit digest, posterior/accepted prefix/correction, target verification/replay logits and tokens, target/draft cache lengths and tensor digests before/tentative/committed/replay states, final cache states, exact counters, and the explicit batch-size-one reorder disposition.

  • DFlash: Qwen/Qwen3-4B-GGUF@bc640142... + AtomicChat/Qwen3-4B-DFlash-GGUF@b53c7de6...; 32/32 direct-ORT greedy tokens equal target-only, 18/75 proposals accepted, 3 multi-token rounds, 5 rejected-suffix rollbacks. Independent full-tensor Q8 source comparison: cosine 0.999879, relative L2 0.005406.
  • EAGLE3: Qwen/Qwen3-8B-GGUF@7c41481f... + williamliao/Qwen3-8B-EAGLE3-Speculator-GGUF@44480ff4...; 32/32 direct-ORT greedy tokens equal target-only, 20/43 proposals accepted, 7 multi-token rounds, 10 rejected-suffix rollbacks. Independent pinned llama.cpp conversion matches all 15 tensor names, qtypes, shapes, and values exactly.
  • Pinned llama.cpp additionally exercised the real acceptance loops with 49/114 DFlash and 45/85 EAGLE3 accepted tokens.
  • Four mutations now alter execution before validation: wrong mapping/order is fed through target verification, draft-cache corruption is threaded into the next round, and target rollback corruption is replayed against full committed history. Each fails its distinct semantic invariant.

Target Q4_K/Q6_K imports truthfully report lossy INT4 affine block-32 repacking; target-only and speculative comparisons use the same repacked target graph. Every target replay starts from an empty cache and rebuilds the complete prompt plus committed token history. Quantized batched verification and full-history replay can differ numerically, so both states are bound and maximum absolute differences are recorded (DFlash 1.967625, EAGLE3 0.912386) while replay argmax tokens must match exactly. Draft replay likewise reconstructs the complete committed history from empty state.

Production DFlash uses target-only tail generation when fewer than one fixed block remains; EAGLE3 caps each final proposal width to remaining - 1. Parametric tests prove target sessions, caches, and counters never process beyond requested max_new_tokens for remaining capacity 1 through width+1. The reference coordinator is batch-size 1 and truthfully reports beam/reorder unsupported. Higher-level execution remains runtime_unvalidated without gating export.

Validation

  • Final exact-main broad non-integration suite: 9,668 passed, 64 skipped, 1 subtest passed.
  • Final affected draft+MTP+CLI/evidence/docs/census suite: 302 passed, 2 real-artifact probes skipped by opt-in.
  • Both immutable real-artifact probes were rerun after the three blocker fixes; all eight execution-mutating discriminator runs failed at their expected semantic invariants.
  • Pinned Ruff format/lint, generated GGUF docs, and focused isolated mypy passed. _config_mapping.py retains three unrelated pre-existing mypy errors outside the DFlash change.
  • Final medium review specifically verified execution-mutating discriminators, complete empty-cache target replay, bounded final-round production behavior, DFlash mask metadata propagation, and semantic Allow GGUF export with deferred tokenizers #693/Add OCR and document GGUF projector cohort #691 conflict resolution; no significant findings remain.

No CI monitoring or merge is requested.

@justinchuby
justinchuby requested review from a team and a lite review from Copilot August 28, 2026 17:13
@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing d68f664 → 3ce6560

Model Metric Baseline Current Delta
bert (feature-extraction) model_size_bytes 359 KB 359 KB +0.0% ⚪
bert (feature-extraction) num_nodes 68 68 +0.0% ⚪
falcon model_size_bytes 364 KB 364 KB +0.0% ⚪
falcon num_nodes 66 66 +0.0% ⚪
gemma2 model_size_bytes 428 KB 428 KB +0.0% ⚪
gemma2 num_nodes 105 105 +0.0% ⚪
gpt2 model_size_bytes 324 KB 324 KB +0.0% ⚪
gpt2 num_nodes 54 54 +0.0% ⚪
llama model_size_bytes 425 KB 425 KB +0.0% ⚪
llama num_nodes 60 60 +0.0% ⚪
llama (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
llama (static-cache) num_nodes 56 56 +0.0% ⚪
mamba (ssm-text-generation) model_size_bytes 296 KB 296 KB +0.0% ⚪
mamba (ssm-text-generation) num_nodes 94 94 +0.0% ⚪
phi3 model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 num_nodes 58 58 +0.0% ⚪
phi3 (static-cache) model_size_bytes 421 KB 421 KB +0.0% ⚪
phi3 (static-cache) num_nodes 54 54 +0.0% ⚪
qwen2 model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 num_nodes 60 60 +0.0% ⚪
qwen2 (static-cache) model_size_bytes 425 KB 425 KB +0.0% ⚪
qwen2 (static-cache) num_nodes 56 56 +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) model_size_bytes 506 KB 506 KB +0.0% ⚪
qwen3_5_moe (hybrid-text-generation) num_nodes 265 265 +0.0% ⚪
qwen3_5_text (hybrid-text-generation) model_size_bytes 458 KB 458 KB +0.0% ⚪
qwen3_5_text (hybrid-text-generation) num_nodes 127 127 +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) model_size_bytes 977 KB 977 KB +0.0% ⚪
qwen3_5_vl (hybrid-qwen-vl) num_nodes 450 450 +0.0% ⚪
t5 (seq2seq) model_size_bytes 836 KB 836 KB +0.0% ⚪
t5 (seq2seq) num_nodes 176 176 +0.0% ⚪
whisper (speech-to-text) model_size_bytes 1008 KB 1008 KB +0.0% ⚪
whisper (speech-to-text) num_nodes 128 128 +0.0% ⚪

No performance regressions.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an end-to-end, target-coupled GGUF “draft pair” export and a direct ONNX Runtime greedy coordinator for DFlash and EAGLE3, with immutable evidence capture and documentation updates to reflect the new runtime-unvalidated but directly-executable workflow.

Changes:

  • Introduces build_draft_pair_from_gguf / write_draft_pair_package to emit exact target+draft graph packages with separate cache namespaces, shared-weight bridges (embedding/LM-head), and self-verifying graph package identities.
  • Adds DraftPairRunner (direct ORT coordinator) implementing speculative acceptance/rollback for DFlash and EAGLE3, including compressed-vocabulary remapping and target-only baseline comparison.
  • Updates EAGLE3 to optionally consume draft-owned embeddings and normalizes GGUF/HF hidden-state index conventions; adds tests + docs + CLI support (--target-gguf) and evidence fixtures.

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/gguf_draft_runtime_integration_test.py Real-artifact integration probe gated by env var; verifies direct-ORT acceptance loop equals target-only.
testdata/evidence/gguf_draft_runtime_evidence.json Adds pinned evidence record for DFlash/EAGLE3 identities + direct-ORT results.
src/mobius/tasks/_eagle3.py Task input contract updated to support input_ids when draft owns embeddings.
src/mobius/tasks/_draft_target.py New task emitting target decoder + optional embedding/LM-head bridge graphs; supports shared initializer binding.
src/mobius/tasks/_draft_target_test.py Unit test validating emitted decoder/embedding/head graphs and hidden-state outputs.
src/mobius/tasks/init.py Exports DraftTargetCausalLMTask.
src/mobius/models/eagle3.py Adds optional draft-owned embedding path; updates weight preprocessing and forward input validation.
src/mobius/models/_eagle3_test.py Tests for owning embeddings, retaining embedding weights, and graph input selection.
src/mobius/integrations/gguf/_tensor_mapping.py Maps EAGLE3 token_embd → embed_tokens.
src/mobius/integrations/gguf/_runtime_evidence.py Extends graph package identity hashing with an explicit “selected files” mode + stricter validation.
src/mobius/integrations/gguf/_runtime_evidence_test.py Tests selected-file identity stability and path-escape rejection.
src/mobius/integrations/gguf/_route_census.py Treats draft arches with direct runtime as no longer “runtime unsupported” census work items.
src/mobius/integrations/gguf/_route_census_test.py Updates expected census counts and ensures draft items are absent.
src/mobius/integrations/gguf/_draft.py Tokenizer vocab trailing padding handling; stricter target config validation; pairing validation tightened; manifest runtime status updated.
src/mobius/integrations/gguf/_draft_test.py Adds tokenizer padding/gap tests; updates embedding/head ownership behaviors; validates normalized hidden-state indices; CLI tests updated.
src/mobius/integrations/gguf/_draft_runtime.py New DraftPairRunner coordinator + verified snapshotting + external-data closure enforcement.
src/mobius/integrations/gguf/_draft_runtime_test.py Unit tests for embedding bridge selection, logits projection, external-data scanning, snapshot immutability.
src/mobius/integrations/gguf/_draft_runtime_evidence_test.py Validates evidence schema bounds and asserts evidence demonstrates real speculative work.
src/mobius/integrations/gguf/_draft_pair.py New draft-pair builder/writer producing multi-component packages + manifest binding + atomic publish.
src/mobius/integrations/gguf/_draft_pair_test.py Tests target artifact binding, bf16 rejection, manifest persistence, runner verification/closure enforcement.
src/mobius/integrations/gguf/_docs.py Adds draft runtime evidence summary + doc updates for the new draft-pair workflow.
src/mobius/integrations/gguf/_config_mapping.py Normalizes EAGLE3 hidden-state indices and detects draft-owned embedding presence.
src/mobius/integrations/gguf/_builder.py Allows task to be a ModelTask instance; adds output_layer_indices plumbing; binds shared initializers post-build.
src/mobius/integrations/gguf/_arch_registry.py Updates draft runtime reason text to reflect direct-ORT evidence + runtime-unvalidated stance.
src/mobius/integrations/gguf/init.py Exposes draft-pair builder/writer and DraftPairRunner API.
src/mobius/_model_package.py Extends ModelPackage with draft-pair metadata fields.
src/mobius/_configs/_base.py Adds use_draft_token_embedding to Eagle3Config and defaults it for speculators-format HF configs.
src/mobius/main.py Adds --target-gguf path and routes draft-pair builds through the new builder/writer.
docs/cli_reference.md Documents --target-gguf.
docs/api/build_from_gguf.md Updates API doc to reference draft-pair workflow and includes evidence summary snippet.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/mobius/integrations/gguf/_docs.py Resolved
@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing d68f664 → 3ce6560

Model Sub-model Changes Status
bert (feature-extraction) model 0 ⚪
falcon model 0 ⚪
gemma2 model 0 ⚪
gemma4 (gemma4) decoder 0 ⚪
gemma4 (gemma4) embedding 0 ⚪
gemma4 (gemma4) vision_encoder 0 ⚪
gemma4_text model 0 ⚪
gpt2 model 0 ⚪
llama model 0 ⚪
llama (static-cache) model 0 ⚪
mamba (ssm-text-generation) model 0 ⚪
phi3 model 0 ⚪
phi3 (static-cache) model 0 ⚪
qwen model 0 ⚪
qwen (static-cache) model 0 ⚪
qwen2 model 0 ⚪
qwen2 (static-cache) model 0 ⚪
qwen2_moe model 0 ⚪
qwen2_moe (static-cache) model 0 ⚪
qwen3 model 0 ⚪
qwen3 (static-cache) model 0 ⚪
qwen3_5_moe (hybrid-text-generation) model 0 ⚪
qwen3_5_text (hybrid-text-generation) model 0 ⚪
qwen3_5_vl (hybrid-qwen-vl) decoder 0 ⚪
qwen3_5_vl (hybrid-qwen-vl) embedding 0 ⚪
qwen3_5_vl (hybrid-qwen-vl) vision_encoder 0 ⚪
qwen3_moe model 0 ⚪
qwen3_moe (static-cache) model 0 ⚪
qwen3_next (hybrid-text-generation) model 0 ⚪
t5 (seq2seq) decoder 0 ⚪
t5 (seq2seq) encoder 0 ⚪
whisper (speech-to-text) decoder 0 ⚪
whisper (speech-to-text) encoder 0 ⚪

No architecture changes detected. ✅


Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed)

@justinchuby
justinchuby force-pushed the justinchuby-prove-draft-model-evidence branch 3 times, most recently from a3853d3 to a995cd2 Compare August 28, 2026 18:58
justinchuby and others added 8 commits August 28, 2026 12:29
Add exact target/draft package construction and a direct ONNX Runtime coordinator for DFlash and EAGLE3. Preserve independent cache namespaces, accepted-prefix rollback, target bridges, EAGLE-owned embeddings, and immutable graph/package identities.

Record bounded source and raw-GGUF evidence for deterministic target-only token equality and real multi-token acceptance while keeping higher-level runtime compatibility advisory.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Reuse the merged MTP cache-port and runtime_unvalidated status conventions for target-coupled draft packages. Bind the manifest through the runtime-payload hash and revalidate both GGUF sources throughout atomic publication.

Preserve requested runtime/version metadata while keeping direct ORT evidence artifact-scoped and higher-level execution advisory.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
ORT session inputs are immutable and each draft step returns new present-cache arrays, so retain the existing accepted cache dictionary as the rollback baseline instead of cloning every tensor each round.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Build the draft-pair usage paragraph from wrapped source fragments while preserving the generated single-line documentation and its concision contract.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Exercise DFlash and EAGLE3 through a test-only direct ONNX Runtime coordinator that derives its contract from raw GGUF metadata instead of production transition helpers. Bind per-round proposal, replay, cache, rollback, and mutation evidence and compare production aggregate behavior against the independent trace.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Derive EAGLE3 synthetic input dtypes from the direct ORT session and preserve assertion-shaped trace mismatches under current lint rules.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Separate draft architecture and direct-runtime capability sets, and rebuild independent oracle draft caches from empty state through committed history instead of replaying only the latest transition.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Move mutation discriminators into proposal, cache, and rollback execution; replay the complete target history from empty cache; and bound final speculative rounds so sessions, counters, and caches never advance past max_new_tokens. Regenerate both immutable direct-ORT traces under the corrected semantics.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
@justinchuby
justinchuby force-pushed the justinchuby-prove-draft-model-evidence branch from a995cd2 to 3ce6560 Compare August 28, 2026 19:42
@justinchuby
justinchuby merged commit 027fd42 into main Aug 28, 2026
19 of 25 checks passed
@justinchuby
justinchuby deleted the justinchuby-prove-draft-model-evidence branch August 28, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants