Skip to content

Close the GGUF tokenizer census - #603

Merged
justinchuby merged 2 commits into
mainfrom
justinchuby-close-gguf-tokenizer-census
Aug 25, 2026
Merged

justinchuby merged 2 commits into
mainfrom
justinchuby-close-gguf-tokenizer-census

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

  • close the pinned llama.cpp tokenizer pre-tokenizer census at 8d9af256337d1a501250f9bbf4c0859a654bddd6: 87 identifiers across 56 exact semantic groups
  • remove generic BPE/SentencePiece reconstruction and default all 87 policies to deferred unless a vocabulary-identical embedded tokenizer.huggingface.json can be copied verbatim
  • validate tokenizer tables, IDs, flags, merges, scores, UTF-8, templates, and source identity; pin Hub revisions/files and thread exact parsed GGUF snapshots through text and VLM builds
  • stage complete runtime packages transactionally, preserve tokenizer/config/chat assets, reject undeclared ORT GenAI MTP packaging, and document loader-consumed versus converter-only metadata

Route counts

  • deferred by default: 87
  • rejected pinned identifiers: 0
  • exact-copy eligible when an embedded vocabulary-identical tokenizer JSON is present: 87
  • unknown identifiers: rejected

Validation

  • 2586 passed — full GGUF suite
  • 50 passed — complete CLI suite
  • 7015 passed, 52 skipped — broad non-integration suite excluding the unrelated baseline glm_moe_dsa shape-inference case
  • full lintrunner clean
  • two independent full-diff reviews clean

Current baseline note

The unfiltered broad suite currently has two unrelated glm_moe_dsa output shape/checker failures; no files for that model are changed here.

@github-actions

github-actions Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 13b2f84 → bf14467

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 24, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing 13b2f84 → bf14467

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.

@justinchuby
justinchuby force-pushed the justinchuby-close-gguf-architecture-census branch from ee452c2 to d932044 Compare August 25, 2026 16:40
Base automatically changed from justinchuby-close-gguf-architecture-census to main August 25, 2026 16:41
@justinchuby
justinchuby requested a review from a team August 25, 2026 16:41
justinchuby and others added 2 commits August 25, 2026 09:43
Pin all 87 llama.cpp tokenizer pre identifiers behind exact semantic policies, remove generic tokenizer reconstruction, and fail closed when an exact embedded tokenizer asset cannot be materialized. Validate tokenizer metadata, preserve chat/config assets, bind runtime packaging to source identity, and stage package output transactionally across text, draft, MTP, and multimodal paths.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Write embedded tokenizer JSON as exact UTF-8 bytes so platform newline handling cannot violate the verbatim-copy contract. Format the pinned census and verify the grouped documentation rows in deterministic registry order.

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 16:46
@justinchuby
justinchuby force-pushed the justinchuby-close-gguf-tokenizer-census branch from 5a4757e to bf14467 Compare August 25, 2026 16:46
@justinchuby
justinchuby merged commit aa19199 into main Aug 25, 2026
20 of 23 checks passed
@justinchuby
justinchuby deleted the justinchuby-close-gguf-tokenizer-census branch August 25, 2026 16:48

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 tightens GGUF tokenizer handling to be fail-closed and “truthful”: Mobius will only emit runnable runtime packages when the GGUF embeds a vocabulary-identical tokenizer.huggingface.json that can be copied verbatim, and otherwise defers tokenizer materialization while still allowing graph-only imports.

Changes:

  • Replaces best-effort tokenizer reconstruction with strict GGUF tokenizer validation + exact-copy-only materialization, including provenance digests/manifests.
  • Makes GGUF runtime package emission transactional/atomic and gated on a validated, identity-pinned tokenizer snapshot captured at graph-build time.
  • Pins and documents the full llama.cpp tokenizer.ggml.pre identifier census (87 identifiers) via a new registry module + closure tests + docs.

Reviewed changes

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

Show a summary per file
File Description
tests/gguf_test.py Updates CLI/runtime tests to reflect runtime gating and the new package attributes used by the writer.
src/mobius/integrations/gguf/_tokenizer.py Implements strict tokenizer metadata validation and exact embedded tokenizer copy; emits config/maps and provenance manifest.
src/mobius/integrations/gguf/_tokenizer_test.py Replaces reconstruction tests with closure tests for the pinned pre-census and strict validation/copy behavior.
src/mobius/integrations/gguf/_tokenizer_registry.py Adds the pinned llama.cpp tokenizer.ggml.pre identifier registry (87 entries) with canonical grouping.
src/mobius/integrations/gguf/_runtime_package.py Makes runtime package emission atomic and tokenizer-gated; rejects undeclared ORT GenAI MTP packaging.
src/mobius/integrations/gguf/_runtime_package_test.py Adds atomicity + fail-closed coverage for tokenizer gating, identity mismatch, and staged-write rollback.
src/mobius/integrations/gguf/_reader.py Makes tokenizer field parsing fail with a clear error (and enforces UTF-8 decoding).
src/mobius/integrations/gguf/_mmproj.py Threads GGUF source identity/tokenizer verdict onto VLM packages; adds injectable GGUFModel parameters for tests.
src/mobius/integrations/gguf/_mmproj_test.py Updates VLM routing tests for the new injected GGUF model arguments and path normalization.
src/mobius/integrations/gguf/_builder.py Validates tokenizer metadata during GGUF validation; adds explicit HF revision parsing (repo@rev:file.gguf) and threads tokenizer verdict/source onto packages.
src/mobius/integrations/gguf/_builder_test.py Adds tests verifying exact HF revision handling in GGUF path resolution.
src/mobius/main.py Adds CLI preflight to reject deferred tokenizers before creating durable output; routes save/packaging differently for runtime builds.
docs/design/gguf-support-proposal.md Updates design doc to reflect the resolved approach: exact embedded tokenizer copy only, no generic reconstruction.
docs/api/build_from_gguf.md Documents tokenizer truthfulness, the pinned policy table, and loader-consumed vs extension metadata.

💡 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
Comment on lines +641 to +652
from mobius.integrations.gguf._builder import (
_resolve_gguf_path,
_validate_gguf_model,
)
from mobius.integrations.gguf._reader import GGUFModel
from mobius.integrations.gguf._tokenizer import inspect_gguf_tokenizer

# Resolve and validate the exact selected source before graph construction
# so a deferred tokenizer cannot leave a graph-only directory behind.
gguf_path = _resolve_gguf_path(gguf_path)
gguf_model = GGUFModel(gguf_path)
_validate_gguf_model(gguf_model, source=str(gguf_path))
Comment thread src/mobius/__main__.py
Comment on lines +678 to +687
if runtime is None:
os.makedirs(output_dir, exist_ok=True)
pkg.save(
output_dir,
external_data=args.external_data,
max_shard_size_bytes=(
_parse_size(args.max_shard_size) if args.max_shard_size else None
),
max_workers=args.max_workers,
)
justinchuby added a commit that referenced this pull request Aug 25, 2026
## Summary

- generate the authoritative GGUF support matrix from the pinned
llama.cpp census at `8d9af256337d1a501250f9bbf4c0859a654bddd6`
(`2026-08-23T16:59:42Z`)
- lock documentation to all 147 architectures, 25 active stored qtypes,
60 projector strings, and 87 tokenizer pre-types in 56 semantic groups
- distinguish graph construction/importability from real runtime support
and downgrade every architecture/projector without complete evidence
- fail runtime publication closed unless canonical architecture, exact
runtime/version, immutable source identity, tensor/qtype census,
graph-shaping import route, serialized graph, tokenizer/config, and
complete staged package all match structured evidence
- document exact-copy versus conversion qtype routes, CLI/Hub
provenance, tokenizer/mmproj/MTP behavior, transaction limitations, and
downstream-runtime scope

## Final verdicts

- architectures: 147 total; 52 graph-supported; 51 fully importable; 0
runtime-supported
- stored qtypes: 25 active; 24 routed; `Q2_0` deferred because pinned
gguf-py has no dequantizer
- projectors: 60 total; 2 graph-importable (`gemma4v`, `muse-glimmer`);
0 runtime-supported
- tokenizers: 87 exact identifiers in 56 semantic groups; exact copy
only when a vocabulary-identical embedded `tokenizer.huggingface.json`
is present

## Local validation

- `python scripts/generate_gguf_support_docs.py --check`
- `lintrunner f --output oneline --all-files`
- `lintrunner -a`
- GGUF/CLI/coverage suite: 3,375 passed, 225 skipped
- broad non-integration suite: 7,027 passed, 52 skipped, 1 subtest
passed (known unrelated `glm_moe_dsa` baseline excluded)
- two independent full-diff reviews: CLEAN
- final cross-stack policy review: CLEAN

## Waivers and limitations

This PR closes importer/registry/documentation policy; it does not add a
new model architecture or claim downstream runtime readiness.

- L1-L3 architecture-model checklist items: not applicable to this
registry/importer closure; existing graph/CLI/import suites cover
changed behavior.
- L4/L5 and representative real-weight full-logit/generation parity: not
claimed globally. Their absence is why runtime verdicts remain
deferred/rejected.
- fp16/bf16/CUDA/DirectML/cross-EP semantic parity: not claimed by this
matrix without architecture-specific real evidence.
- ORT GenAI, Foundry Local, and Olive: optional downstream probes;
absence does not gate Mobius graph export and implies no runtime
support.
- direct source-backed GGUF external-data reuse: not implemented.
Packages are self-contained; source-range manifests, source-backed
locking/recovery, and source-reference symlink containment are not
claimed.
- publication uses staged files plus two renames and in-process
rollback; it is not a single-step atomic exchange, crash-durable
transaction, or multi-process lock.

Stacked on #603 / `justinchuby-close-gguf-tokenizer-census`.

---------

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