Skip to content

Allow GGUF export with deferred tokenizers - #693

Merged
justinchuby merged 6 commits into
mainfrom
justinchuby-warn-tokenizer-blockers
Aug 28, 2026
Merged

justinchuby merged 6 commits into
mainfrom
justinchuby-warn-tokenizer-blockers

Conversation

@justinchuby

@justinchuby justinchuby commented Aug 28, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Preserve proven GGUF model and runtime/config components when an authoritative tokenizer route is deferred or blocked.
  • Emit exactly one structured tokenizer warning with route, blocker category, evidence ID, exact recorded reason, impact, and remediation; never publish unverified tokenizer assets.
  • Persist generic component support_status, export_status, and runtime_validation_status in export_report.json.
  • Keep architecture, config, tensor closure, graph, qtype, source identity, I/O, malformed known metadata, and unexpected failures fail-closed.

Final blocker evidence

  • Tokenizer field closure: Complete and incomplete paths accept only exact consumed/extension allowlists plus tokenizer.chat_template.*. Unknown/near-miss fields defer as unsupported-tokenizer-metadata-fields; malformed known fields remain fatal even when unknown fields coexist.
  • Incomplete tokenizer safety: Present model/pre, embedded JSON, RWKV, token list, types/scores/merges, special IDs, booleans, suppress/charsmap, and chat templates validate before downgrade. Tokenless special IDs fail; only mask_token_id on recognized masked-diffusion architectures is left to the graph contract.
  • MTP tokenizer safety: Deferred/blocked MTP routes never copy or pass through unevidenced tokenizer repositories. Only runtime evidence or validated embedded materialization writes tokenizer assets; faithful runtime config remains exported.
  • Reuse metadata lifecycle: The rollback journal always manages/removes stale draft, export, and quantization reports across sidecar variants. Failed reruns restore the complete prior graph/report set.
  • Final-byte runtime identity: Evidence matching occurs after final export/compatibility/MTP status bytes. Pre-report evidence is explicitly legacy/non-validating until regenerated final-package hashes exist.
  • Atomic publication: Report-bearing normal saves use sibling staging and atomic no-replace publication; graph/report/draft/permission/concurrent-destination failures leave no stale output. MTP status and reuse remain non-duplicated transactional surfaces.

Validation

  • Final MTP/tokenizer regressions: 116 passed, 15 deselected.
  • Add standalone GGUF audio projector routes #696 audio-projector affected gate: 428 passed, 453 deselected.
  • Final broad serial suite on exact base: 9,471 passed, 64 skipped, 12 deselected, 1 subtest passed.
  • Generated GGUF docs, full initialized lintrunner, and diff check: clean.
  • New disposition/runtime modules: targeted mypy clean.
  • Broad mypy exact-base comparison: branch 3,768 vs base 3,804 existing diagnostics; 0 normalized new errors.
  • Multiple independent medium-effort reviews completed; final MTP/mask review reported no findings.
  • GitHub review threads: 1 total, 0 unresolved.

Publication preflight

  • Clean worktree and matching remote head.
  • Session artifacts: 0 bytes retained. Completed exact-base mypy worktrees/logs were deleted; no downloaded GGUF/ONNX/package payloads or scratch caches remain.
  • Lease push completed after conflict-free semantic rebase onto Add standalone GGUF audio projector routes #696.
  • All commits contain Signed-off-by and required Copilot Co-authored-by trailers. GPG signing was unavailable because gpg is not installed.
  • CI is intentionally not monitored and this PR is not being merged by this session.

Exact revisions

  • Base: 82e31222c9dbc08d2ea825fd6265498f0f594019
  • Head: 960beeddec616d10d83f5bebe0ecd157a64ff199

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

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 82e3122 → 960beed

Model Sub-model Changes Status

No architecture changes detected. ✅


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

@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing 82e3122 → 960beed

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

Enables GGUF export to proceed when tokenizer materialization is deferred/blocked by introducing a component-level export report (export_report.json) and structured warnings, while keeping model/graph validation fail-closed and preserving validated runtime claims only when exact evidence matches.

Changes:

  • Add ComponentExportReport/ComponentExportDisposition and persist export_report.json via ModelPackage.save/load.
  • Introduce GGUF partial-export policy + structured warnings (tokenizer blocker / runtime-unvalidated) and thread these dispositions through GGUF build + runtime packaging (including multimodal).
  • Relax runtime packaging from hard-fail to “runtime-unvalidated” fallback when exact runtime evidence is unavailable, while still enforcing exact artifact identity and other fail-closed checks.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/gguf_test.py Adds end-to-end tests for partial exports, warnings, CLI behavior, and multimodal/report propagation.
src/mobius/integrations/gguf/_tokenizer.py Extends tokenizer verdict with stable diagnostics fields for deferred/blocked routes.
src/mobius/integrations/gguf/_tokenizer_test.py Verifies authoritative blocker diagnostics and alias evidence wiring.
src/mobius/integrations/gguf/_tokenizer_evidence.py Adds exact blocker-evidence matcher and refactors sequence digest logic.
src/mobius/integrations/gguf/_tokenizer_evidence_test.py Tests blocker evidence matching behavior.
src/mobius/integrations/gguf/_runtime_package.py Exports validated runtime packages when evidence matches, otherwise exports runtime-unvalidated packages + report.
src/mobius/integrations/gguf/_runtime_package_test.py Expands runtime packaging tests for unvalidated/validated flows and tokenizer omission policy.
src/mobius/integrations/gguf/_runtime_evidence.py Adds RuntimeEvidenceUnavailableError and splits “find match” vs “raise on missing” behavior.
src/mobius/integrations/gguf/_docs.py Updates GGUF docs to describe partial exports, warnings, and report semantics.
src/mobius/integrations/gguf/_component_export.py New module implementing component-aware export policy, report attachment, and structured warnings.
src/mobius/integrations/gguf/_builder.py Ensures GGUF builds (including multimodal) attach canonical identities/routes and tokenizer dispositions.
src/mobius/integrations/gguf/_builder_test.py Adjusts builder tests for new report/runtime packaging behavior and multimodal identity preservation.
src/mobius/integrations/gguf/init.py Updates public GGUF integration docs to reflect runtime-unvalidated fallback behavior.
src/mobius/_model_package.py Adds export_report persistence, output-directory safety checks for partial/unvalidated exports, and export-report collisions.
src/mobius/_model_package_test.py Adds roundtrip + safety tests for export_report.json persistence and save-path validation.
src/mobius/_export_report.py New deterministic, validated schema for component dispositions and package-level export/runtime status.
src/mobius/main.py Updates CLI build-gguf flow to support partial exports + prints status via export_report.json.
src/mobius/init.py Exposes export-report types as part of the public API.
docs/api/build_from_gguf.md Updates API docs to describe partial exports, warnings, and export_report.json.

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

Comment thread src/mobius/__main__.py Resolved
@justinchuby
justinchuby force-pushed the justinchuby-warn-tokenizer-blockers branch 2 times, most recently from c5e0242 to a711d5e Compare August 28, 2026 18:18
justinchuby and others added 6 commits August 28, 2026 11:39
Preserve proven model and runtime components when authoritative tokenizer semantics are deferred or blocked. Emit one structured warning, omit unverified tokenizer assets, and persist generic component export/runtime validation dispositions.

Keep architecture, tensor, graph, qtype, source identity, I/O, and unexpected failures fail-closed while reusing the runtime advisory packaging introduced on main.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Validate runtime evidence against final staged metadata bytes, classify every incomplete tokenizer route, and publish report-bearing model packages atomically.

Preserve MTP runtime status semantics and extend the existing GGUF reuse rollback transaction to cover export and draft metadata.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Distinguish fully emitted but runtime-unvalidated packages from partial packages that actually omit components.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Reject corrupt present tokenizer fields before incomplete-route downgrades and transactionally manage quantization, export, and draft reports across GGUF reuse updates.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Defer unknown tokenizer semantics with explicit component diagnostics while keeping malformed known fields fail-closed and allowing validated named chat-template fields.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Do not pass through tokenizer repositories for deferred MTP routes, and scope tokenless mask-token metadata to recognized diffusion architectures.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
@justinchuby
justinchuby force-pushed the justinchuby-warn-tokenizer-blockers branch from 99e2dd0 to 960beed Compare August 28, 2026 18:57
@justinchuby
justinchuby merged commit cc40cd7 into main Aug 28, 2026
19 of 25 checks passed
@justinchuby
justinchuby deleted the justinchuby-warn-tokenizer-blockers branch August 28, 2026 19:08
justinchuby added a commit that referenced this pull request Aug 28, 2026
Regenerate the GGUF support document after rebasing the OCR projector matrix onto PR #693's export-status and tokenizer-reporting changes.

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

Copilot-Session: f96aa7b0-95a6-473f-a875-5883767c2a24
Signed-off-by: Justin Chu <[email protected]>
justinchuby added a commit that referenced this pull request Aug 28, 2026
## 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 #696, #693, and
#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
#693/#691 conflict resolution; no significant findings remain.

No CI monitoring or merge is requested.

---------

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.

2 participants