Skip to content

Add target-coupled draft GGUF cohort - #583

Merged
justinchuby merged 3 commits into
mainfrom
justinchuby-add-draft-gguf-cohort
Aug 25, 2026
Merged

justinchuby merged 3 commits into
mainfrom
justinchuby-add-draft-gguf-cohort

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

  • add pinned llama.cpp dflash and eagle3 GGUF import as target-coupled speculative draft auxiliaries, never standalone CausalLMs
  • validate target dimensions, selected hidden-state layers, exact ordered vocabulary and special IDs, suffix-exact tensor closure, Q/K conversion, quantization sidecars, and I64 draft-to-target remaps before graph construction
  • emit draft_manifest.json with the target config hash, ordered-token vocabulary hash, draft/target shapes, output ownership, cache ownership, and compact-logit remap contract
  • keep runtime support deferred pending an independently verified real target+draft parity loop

Explicit pairing contract

mobius build-gguf draft.gguf \
  --target-config /path/to/exact-target/ \
  --output output/draft/

--target-config accepts the exact target directory or config.json; the adjacent tokenizer.json is mandatory. The Python API also accepts an explicit mapping with tokenizer_tokens. File inputs record SHA-256 over the exact config bytes; mapping inputs record SHA-256 over canonical sorted JSON. The manifest separately records SHA-256 over the ordered token strings. These hashes identify the validated config/token-ID contract, not target weights; the caller must attest and pair the exact target weight revision.

Draft builds reject task="text-generation", static-cache export, and write_gguf_runtime_package. They only save an auxiliary ONNX graph plus draft_manifest.json. Missing target heads/embeddings are exposed as explicit target-owned graph inputs/outputs rather than duplicated or synthesized.

Real-artifact evidence

  • DFlash: lym00/Qwen3-4B-DFlash-GGUF-Test@9d2ec464a15346d8a7d7a696c06694eb1bf690b5, Qwen3-4B-DFlash-q8_0.gguf, 577,047,072 bytes, LFS SHA-256 5ecf02bb269fc42277f43961794387fea11ecc367ea2d99e86b2b71cc249aff6, paired target Qwen/Qwen3-4B@1cfa9a7208912126459214e8b04321603b3df60c. Its 58-tensor header uses post-pin hidden_norm.weight, so pinned suffix closure rejects it.
  • EAGLE-3: williamliao/Qwen3-8B-EAGLE3-Speculator-GGUF@44480ff4ea6330788818f7f5fc9a69b326dc4c06, Qwen3-8B-speculator.eagle3-F16.gguf, 2,049,930,400 bytes, LFS SHA-256 d6cf1f3cf29e9cd72c02fb11f989f5192f2b24e142741fdc2de8cd590140f2f2, paired target Qwen/Qwen3-8B@b968826d9c46dd6066d109eabc6255188de91218. Its 15-tensor header contains a draft-owned embedding, which the external-embedding graph rejects rather than dropping.

Neither artifact was executed. No suitably small real pair satisfies this pinned contract, so runtime remains DEFERRED until independent target/draft full-logit and multi-step proposed-token parity exists.

Validation

  • focused draft/registry/mapping/runtime/model tests: 532 passed
  • broad non-integration suite excluding the known unrelated glm_moe_dsa shape-inference regression: 5903 passed, 52 skipped
  • unfiltered broad run: 5922 passed, 52 skipped, with only the two existing glm_moe_dsa missing-output-shape/checker failures
  • lintrunner f --output oneline --all-files
  • bug-focused review covered target assumptions, layer indexing, tokenizer/remap semantics, cache and hidden-state contracts, dropped tensors, standalone dispatch, Q/K permutation, and quantization misuse

@github-actions

github-actions Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing 46aec39 → 7488b89

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 388 KB 388 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 264 264 +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 126 126 +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 428 428 +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.

@github-actions

github-actions Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 46aec39 → 7488b89

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-add-diffusion-gguf-cohort branch from b229ff4 to 05b92e0 Compare August 25, 2026 15:29
Base automatically changed from justinchuby-add-diffusion-gguf-cohort to main August 25, 2026 15:30
@justinchuby
justinchuby requested a review from a team August 25, 2026 15:30
justinchuby and others added 3 commits August 25, 2026 08:33
Import pinned dflash and eagle3 GGUF drafts only through an explicit target-pairing contract. Validate target dimensions, layer selections, tokenizer identity, tensor closure, quantization sidecars, and draft vocabulary remaps before graph construction, then persist the orchestration requirements in a fail-closed manifest.

Keep standalone runtime packaging deferred until a pinned real target/draft pair passes independent logits and multi-step proposal parity.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Bind target config and tokenizer reads to one validated directory, canonicalize complete pairing identities, enforce bounded schema-aware tokenizer parsing, and reject sparse vocabulary IDs before allocation.

Preflight incompatible runtime and target inputs before any package filesystem mutation, with relocation, symlink, hash determinism, malformed-resource, and byte-preservation coverage.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 332e47ee-0b3a-4f7d-8c81-cb7be2123f98
Signed-off-by: Justin Chu <[email protected]>
Thread the current quantized-linear factory through every DFlash and Eagle3 projection so the landed fail-closed GGUF importer can preserve affine draft tensors. Update the quantized architecture pin and reader-level validation test for the parent branch's shard-aware loader, and remove a conflict-resolution duplicate assertion.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Copilot AI lite review requested due to automatic review settings August 25, 2026 15:38
@justinchuby
justinchuby force-pushed the justinchuby-add-draft-gguf-cohort branch from 5102565 to 7488b89 Compare August 25, 2026 15:38
@justinchuby
justinchuby merged commit aecebbc into main Aug 25, 2026
17 of 23 checks passed
@justinchuby
justinchuby deleted the justinchuby-add-draft-gguf-cohort branch August 25, 2026 15:38
justinchuby added a commit that referenced this pull request Aug 25, 2026
## Summary

- enumerate all 60 serialized llama.cpp `clip` projector types at
`8d9af256337d1a501250f9bbf4c0859a654bddd6` in an immutable capability
registry
- support only exact, audited Gemma4 vision (`gemma4v`) and Muse Glimmer
(`muse-glimmer`) sidecars; fail before graph construction for unknown,
deferred, mismatched, quantized, or out-of-closure projectors
- validate pinned metadata, tensor suffixes/shapes/qtypes, source and
target identity, projector dimensions, and media-token contracts
- preserve Gemma4 clipping bounds, correct its spatial pooling to 3x3,
and document audited artifacts plus all projector verdicts
- add registry closure/mutation, mixed quantized-text, early rejection,
package round-trip, and independent NumPy/ORT encoder-projector parity
tests

## Validation

- `PYTHONPATH=src python -m pytest
src/mobius/integrations/gguf/_mmproj_registry_test.py
src/mobius/integrations/gguf/_mmproj_mapping_test.py
src/mobius/integrations/gguf/_mmproj_test.py
src/mobius/integrations/gguf/_reader_test.py -q --tb=short` — 126 passed
- `lintrunner f --output oneline --all-files` — passed
- broad non-integration suite — 5963 passed, 52 skipped; two unrelated
existing `glm_moe_dsa` symbolic-shape/checker failures remain

Stacked on #583.

---------

Signed-off-by: Justin Chu <[email protected]>

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 introduces a target-coupled speculative draft GGUF cohort (dflash, eagle3) in the GGUF import pipeline. These drafts are validated against an explicit target config/tokenizer before graph construction, emit a draft_manifest.json for orchestration, and are explicitly blocked from standalone runtime packaging.

Changes:

  • Add draft-specific GGUF validation: suffix-closure tensor contract checks, target config/tokenizer identity validation, and optional d2t draft→target ID remap handling.
  • Extend DFlash/EAGLE-3 model + task graphs to support draft-owned vs target-owned LM heads, switching outputs between draft_logits and draft_hidden.
  • Add CLI/API surface for --target-config, manifest writing, and explicit rejection of runtime packaging for drafts; update GGUF registry/tensor mappings and docs accordingly.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/mobius/tasks/_eagle3.py Adjust EAGLE-3 graph input/output shapes and conditional output naming for target LM head borrowing.
src/mobius/tasks/_dflash.py Conditional draft_logits vs draft_hidden output based on use_draft_lm_head.
src/mobius/models/eagle3.py Allow configurable linear class, support target LM head borrowing (optional lm_head=None), and target-hidden width for FC input.
src/mobius/models/dflash.py Add optional draft-owned LM head and propagate linear-class selection through layers.
src/mobius/models/_eagle3_test.py Update unit coverage to assert FC input width when target_hidden_size differs.
src/mobius/integrations/gguf/_upstream_data/llamacpp_pin.json Pin tensor family/name closures for dflash and eagle3.
src/mobius/integrations/gguf/_tensor_mapping.py Add GGUF→HF name mapping tables for dflash and eagle3.
src/mobius/integrations/gguf/_runtime_package.py Reject runtime packaging for draft packages (manifest-present).
src/mobius/integrations/gguf/_runtime_package_test.py Add test ensuring draft runtime packaging rejection is fail-closed and non-mutating.
src/mobius/integrations/gguf/_draft.py Implement target pairing validation, ordered-token hashing, tensor closure validation, and manifest writing.
src/mobius/integrations/gguf/_draft_test.py Add synthetic GGUF tests for validation, non-mutation, and execution sanity checks.
src/mobius/integrations/gguf/_config_mapping.py Add draft-specific key map plus config postprocessors for dflash/eagle3.
src/mobius/integrations/gguf/_builder.py Wire draft validation into build flow; add target_config; exclude d2t from tensor materialization/state dict.
src/mobius/integrations/gguf/_arch_registry.py Register dflash/eagle3 GGUF architectures as deferred-runtime drafts with explicit rationale.
src/mobius/integrations/gguf/_arch_registry_test.py Extend supported architecture set assertions for the two new draft arches.
src/mobius/components/_dflash.py Plumb linear_class through DFlash attention/decoder-layer components for quant/variant support.
src/mobius/_configs/_base.py Add config fields to represent draft-vocab and head-ownership (draft_vocab_size, use_draft_lm_head, use_target_lm_head, etc.).
src/mobius/main.py Add --target-config, block --runtime when target-coupled, and emit draft_manifest.json.
docs/api/build_from_gguf.md Document target_config parameter and add a draft GGUF contract section.

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

Comment on lines +238 to +245
if isinstance(target_config, Mapping):
data = dict(target_config)
tokenizer = data.pop("tokenizer_json", None)
if not isinstance(tokenizer, Mapping):
raise TypeError(
"mapping target_config must include the complete tokenizer_json object; "
"tokenizer_tokens alone cannot verify merges, normalization, or pre-tokenization"
)
Comment on lines +254 to +263
config_payload = _canonical_json_bytes(
data,
label="target config",
limit=_MAX_CONFIG_JSON_BYTES,
)
tokenizer_payload = _canonical_json_bytes(
tokenizer,
label="target tokenizer",
limit=_MAX_TOKENIZER_JSON_BYTES,
)
Comment on lines +104 to +107
builder.add_output(
draft_output,
"draft_logits" if config.use_draft_lm_head else "draft_hidden",
)
justinchuby added a commit that referenced this pull request Aug 25, 2026
## Summary

- clean up still-valid typing, documentation, test robustness,
error-message,
  maintainability, and performance findings left by the GGUF PR stack
- preserve the behavioral fixes merged in #625-#632
- hash reused multi-GB GGUF sources once, at the final pre-publication
integrity
  gate, while retaining cheap identity checks around staging

Exact base: `2db9d33debdc254d879a51b14434c9a81c230f4f`

Exact head: `4541ed2bc9d2ab4227484510b4a85b2d9113eb25`

## Reconstructed original 17-item low-priority tranche

The persisted audit retained only the totals, so this list was
reconstructed
from the live threads and current source. All but the already-fixed #596
comment are addressed in this PR.

| PR | Comment | Disposition |
|---|---:|---|
| #550 | 3837144656 | Implemented: correct tuple return annotation |
| #552 | 3837389183 | Implemented: multichannel waveform shape docs |
| #559 | 3837716261 | Implemented: name-based cache assertions |
| #573 | 3854308350 | Implemented: one final GGUF hash, with integrity
regression coverage |
| #574 | 3854345521 | Implemented: `TensorRole \| None` typing |
| #574 | 3854345597 | Implemented: removed obsolete verdict filtering |
| #577 | 3854472859 | Implemented: documented SSM sequence length |
| #578 | 3843112613 | Implemented: documented F64 passthrough |
| #579 | 3854518332 | Implemented: generalized fused-projection error |
| #580 | 3854576300 | Implemented: removed brittle node counts |
| #583 | 3854681386 | Implemented: documented conditional draft outputs
|
| #587 | 3854816872 | Implemented: corrected MTP output contract docs |
| #596 | 3846110059 | Already fixed on base: unambiguous GQA bias
comment |
| #600 | 3855174281 | Implemented: metadata-count-only MTP error |
| #607 | 3855776048 | Implemented: stable route-field assertions |
| #607 | 3855776086 | Implemented: public tensor iterator |
| #609 | 3856486136 | Implemented: fail-closed LM-head comment |

## Current unresolved-thread disposition

This covers all 48 Copilot threads returned by the reproducible
#600-#630
query. The one human #623 thread is excluded.

| PR | Comment | Current-main disposition and evidence |
|---|---:|---|
| #600 | 3855174177 | Already fixed by #629: package cycle and
reserved-sidecar validation |
| #600 | 3855174238 | Already fixed by #629: explicit MTP sidecar
naming/loading |
| #600 | 3855174281 | Implemented here: error no longer invents an
observed block count |
| #602 | 3848155961 | Outside exact stack; already fixed: top-level
`expert_dtype` is classified before early return |
| #602 | 3848155983 | Outside exact stack; still-valid behavioral
block-quant validation, unchanged |
| #602 | 3848156000 | Outside exact stack; still-valid truncated-read
behavioral finding, unchanged |
| #602 | 3848156022 | Outside exact stack; still-valid descriptor
byte/dtype validation, unchanged |
| #602 | 3848156040 | Outside exact stack; still-valid expert-bank
payload validation, unchanged |
| #603 | 3855249765 | Already fixed by #630: runtime preflight preserves
shard sets |
| #603 | 3855249840 | Already fixed by #630: success output follows
durable runtime publication |
| #604 | 3855343082 | Implemented here: graph-only MTP persistence
distinguished from runtime rejection |
| #604 | 3855343131 | Already fixed by #630: runtime success messages
are atomic |
| #607 | 3855776001 | Implemented here: missing generation golden skips
before provenance read |
| #607 | 3855776048 | Implemented here: only stable route fields are
asserted |
| #607 | 3855776086 | Implemented here: tensor count uses
`tensor_items_raw()` |
| #608 | 3856079371 | Still-valid behavioral cache-symlink containment
finding; unchanged |
| #608 | 3856079415 | Still-valid behavioral lowercase-digest validation
finding; unchanged |
| #609 | 3856486136 | Implemented here: comment matches value-preserving
policy |
| #610 | 3855541683 | Already fixed by #628: Falcon bias precedence is
explicit |
| #610 | 3855541761 | Already fixed by #628: CTRL tiny config exercises
projection biases |
| #611 | 3856595840 | Implemented here: runtime test resolves the
distribution providing the module |
| #612 | 3855677383 | Already fixed by #625: supported-version
endianness detection |
| #612 | 3855677427 | Implemented here: shared `INT64_MAX` sentinel |
| #612 | 3855677460 | Implemented here: shared PLaMo2 width inference |
| #612 | 3855677486 | Implemented here: accepted PLaMo2 activation
spellings are explicit |
| #613 | 3855845678 | Implemented here: canonical issue URL |
| #613 | 3855845757 | Implemented here: Mamba-1 function-registration
docs |
| #613 | 3855845806 | Implemented here: test expects the canonical issue
URL |
| #614 | 3855988545 | Implemented here: removed stale Nemotron-H
divergence comments |
| #614 | 3855988597 | Already fixed by #628: zero-head geometry raises
actionable `ValueError` |
| #615 | 3856082290 | Already fixed by #626: dense GraniteHybrid bias
closure |
| #618 | 3856729330 | Implemented here: required routes filter ORT GenAI
evidence |
| #618 | 3856729409 | Implemented here: env-selected runtime version is
authoritative |
| #618 | 3856729490 | Stale/N/A: PR-description-only matrix claim;
repository workflow claims one pinned version |
| #618 | 3856729563 | Implemented here: schema tail restored to normal
indentation |
| #619 | 3856342484 | Already fixed on base: Kimi Linear uses
`/issues/605` |
| #619 | 3856342532 | Already fixed by #628: config rejects convolution
kernels below 2 |
| #619 | 3856342580 | Already fixed by #628: GGUF contract rejects
convolution kernels below 2 |
| #620 | 3855717041 | Already fixed by #627: tied LM-head-only
checkpoints are retained |
| #621 | 3856722324 | Already fixed by #628: Kimi-K3 required metadata
is complete |
| #623 | 3855931210 | N/A to current main: comment belongs to open,
unmerged #623 |
| #623 | 3855939302 | N/A to current main: comment belongs to open,
unmerged #623 |
| #623 | 3855939358 | N/A to current main: comment belongs to open,
unmerged #623 |
| #623 | 3855939394 | N/A to current main: comment belongs to open,
unmerged #623 |
| #624 | 3856777152 | Implemented here: runtime compatibility reuses the
emitted model type |
| #625 | 3857049733 | Implemented here: unsupported header reports both
endian candidates |
| #629 | 3857313182 | Newer post-audit behavioral sidecar-symlink
cleanup finding; unchanged |
| #629 | 3857313251 | Newer post-audit cross-platform path-safety
finding; unchanged |

## Validation

- affected GGUF/package/ORT GenAI/model/schema tests: 1,040 passed
- broad non-integration suite: 7,851 passed, 56 skipped, 1 subtest
passed
- generated GGUF docs checks: 7 passed
- initialized `lintrunner`; full lint/format passed
- GPT-5.6 Sol medium review: one integrity finding fixed; re-review
found no significant issues

Signed-off-by: Justin Chu <[email protected]>
Co-authored-by: Copilot App <[email protected]>
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.

3 participants