Skip to content

Promote evidenced GGUF tokenizers independently of runtime evidence - #697

Merged
justinchuby merged 2 commits into
mainfrom
justinchuby-close-tokenizer-evidence
Aug 28, 2026
Merged

justinchuby merged 2 commits into
mainfrom
justinchuby-close-tokenizer-evidence

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

  • promote a tokenizer from deferred to pinned-source only when the complete immutable GGUF identity matches existing exact tokenizer evidence
  • materialize exact tokenizer evidence during runtime package export independently of graph/runtime evidence
  • preserve machine-readable deferred/blocked tokenizer warnings without blocking model or component export
  • regenerate the synchronized GGUF API documentation

Authoritative tokenizer census

  • 87 exact identifiers across 56 semantic groups
  • 31 validated-pinned-source identifiers, conditionally promoted only for their evidenced complete artifacts
  • 45 deferred-compiled-semantics identifiers
  • 4 deferred-pinned-artifact-evidence identifiers
  • 7 deferred-pinned-artifact-mismatch identifiers

The 56 remaining tokenizer work items therefore have no currently feasible promotion under the existing immutable-evidence and 16 GiB/session policy. Identifier-only inspection remains deferred because it cannot prove artifact identity.

Validation

  • focused tokenizer/evidence/runtime package tests: 157 passed
  • broad serial suite: 9,670 passed, 64 skipped, 12 deselected, 1 subtest passed
  • focused mypy: clean
  • generated docs: synchronized
  • lintrunner formatting/lint: clean
  • independent medium review: no findings

Base: 027fd42bb89e970defde0098792df104cd83b541
Head: 8bebbaa8ae1fad23e776c03f6f2db4eea53ef5c4

Local pytest/mypy caches were removed; workspace footprint is 81 MiB. No CI monitoring or merge requested.

Match tokenizer evidence against the complete immutable GGUF identity during model export and carry the artifact-scoped pinned-source verdict into runtime packaging independently of runtime evidence. Keep unsupported and mismatch routes deferred, regenerate the census documentation, and cover promotion plus runtime-unvalidated packaging behavior.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
@justinchuby
justinchuby requested review from a team and a lite review from Copilot August 28, 2026 20:09
@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 027fd42 → 2431dba

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 027fd42 → 2431dba

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 updates the GGUF export pipeline so that tokenizer evidence can be matched and promoted independently of runtime evidence, allowing a tokenizer to be exported as pinned-source when an exact immutable GGUF identity matches existing allowlisted tokenizer evidence—without requiring runtime validation.

Changes:

  • Add find_matching_tokenizer_evidence() and refactor evidence matching to support “return evidence or None” flows.
  • Promote deferred tokenizer verdicts to pinned-source when exact immutable GGUF identity matches tokenizer evidence; preserve blocker/deferred reporting.
  • Update runtime package export to materialize tokenizer assets from tokenizer-only evidence (even when runtime evidence is unavailable) and sync docs/tests accordingly.

Reviewed changes

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

Show a summary per file
File Description
src/mobius/integrations/gguf/_tokenizer_test.py Adds coverage that exact artifact evidence promotes a deferred verdict to pinned-source.
src/mobius/integrations/gguf/_tokenizer_evidence.py Refactors evidence matching and adds find_matching_tokenizer_evidence() to support non-throwing lookup.
src/mobius/integrations/gguf/_runtime_package.py Resolves tokenizer verdict during runtime package export and supports pinned-source tokenizer materialization via tokenizer evidence.
src/mobius/integrations/gguf/_runtime_package_test.py Adds a regression test ensuring tokenizer-only evidence still exports tokenizers when runtime evidence is absent.
src/mobius/integrations/gguf/_docs.py Updates generated GGUF API documentation wording to reflect promotion and evidence independence.
src/mobius/integrations/gguf/_component_export.py Extends verdict resolution to promote to pinned-source when exact evidence matches.
docs/api/build_from_gguf.md Regenerates synchronized docs reflecting the updated tokenizer evidence behavior.
Suppressed comments (1)

src/mobius/integrations/gguf/_runtime_package.py:434

  • This exception message says "tokenizer metadata" no longer matches, but the guard now also rejects mismatched route/evidence_id (and should also reject tokenizer_sha256). Updating the message would make failures actionable when the mismatch isn't actually metadata.
        raise ValueError(
            "The GGUF tokenizer metadata no longer matches the identity captured during "
            "graph construction; refusing to pair the graph with a replaced tokenizer source."
        )

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

Bind runtime packaging to the captured materialized tokenizer digest in addition to its route, evidence, and metadata identities. Clarify the artifact resolver contract and cover fail-closed digest drift.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
@justinchuby
justinchuby merged commit 2c981f2 into main Aug 28, 2026
19 of 25 checks passed
@justinchuby
justinchuby deleted the justinchuby-close-tokenizer-evidence branch August 28, 2026 20:31
justinchuby added a commit that referenced this pull request Aug 28, 2026
Promote a pre-existing deferred tokenizer component to exported when immutable final-package runtime evidence materializes its pinned source. Regenerate the Apertus package identity and assert that the resulting report is complete, validated, and end-to-end runnable after the #697 tokenizer-policy rebase.

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

Copilot-Session: 75ccb9e3-3ba3-4bee-b5ff-c395a88af1ca
Signed-off-by: Justin Chu <[email protected]>
justinchuby added a commit that referenced this pull request Aug 28, 2026
## Summary

- Promote only the immutable Apertus v1.1 1.5B Instruct BF16 GGUF
exact-float CPU route to final-package runtime-supported status.
- Accept pinned llama.cpp v1.1 serialization: unqualified `xielu.*`
metadata and factorless default RoPE, while rejecting conflicting xIELU
keys, incomplete/malformed factors, unsupported scaling metadata,
ignored `original_context_length`, and lossy factor storage.
- Preserve graph identity independently from the subsequently written
`export_report.json`, then validate the complete final runtime package
including that report.
- Auto-select exact immutable runtime evidence without requiring callers
to repeat its evidence-pinned tokenizer repository/revision. Matching
explicit flags remain accepted; conflicting explicit identities fail
before serialization.
- Reconcile #697 tokenizer policy without adding a broad Tekken
promotion: unmatched artifacts remain deferred and tokenizer-omitted.
- Replace a build-time deferred tokenizer report with supported/exported
after exact materialization, so the validated package is truthfully
complete and end-to-end runnable.
- Use an independent raw `gguf.GGUFReader` + `dequantize` oracle with
Mobius loading, mapping, tensor-processing, and normalization helpers
patched to raise.

## Immutable evidence

- GGUF:
`MrMeOrYou/Apertus-v1.1-1.5B-Instruct-GGUF@88c75ad49566d3c2157d03709bf772262c3241ed`
- File: `Apertus-v1.1-1.5B-Instruct-BF16.gguf`
- Size/SHA-256: `3,028,052,608` /
`f9ec154d0ec29dad1f6465b458b7f27bd25ad7b9a3899233ae98ca6d358501c2`
- Official config/tokenizer:
`swiss-ai/Apertus-v1.1-1.5B-Instruct@9e9d01154446a645d30f04174cf1515a38058be7`
- Tensor census: 163 tensors (`BF16`: 98, `F32`: 65)
- Graph fingerprint:
`4bb91bade19d41559cb524e28692453851fe67274cc58109787ee968df3e0fe5`
- Final runtime-package fingerprint:
`97582549e9c5b4114f3bcfa81c92f16aba9d14dd0ea0d2b20acaefd9060e6486`

The real-artifact test invokes runtime packaging without tokenizer
source flags and proves automatic evidence-pinned materialization,
full-logit prefill, fresh and cached decode parity, full-sequence
replay, rollback, batch reorder, 20 exact greedy decode steps,
deterministic ORT GenAI generation, tokenizer
vocabulary/special-token/chat-template identity, graph/config/package
fingerprints, package/report roundtrip, complete validated export
reporting, and fail-closed artifact/source/tokenizer/runtime mismatches.
Observed prefill max absolute difference was `0.00016784668`;
cached-vs-fresh differences remained below `4e-5`.

## Truthful support boundary

`source_fidelity=true` because BF16 values are exactly representable
after import to float32. `storage_quantized=false` because the emitted
ONNX package stores float tensors. Runtime support is evidence-gated to
this exact artifact, official tokenizer revision, CPU import route, ONNX
Runtime 1.29.0, and ORT GenAI 0.15.2. Other Apertus artifacts retain the
generic best-effort advisory behavior and cannot inherit this evidence.
This does not claim a generic independent Tekken tokenizer promotion,
preserved-quantized runtime, CUDA, or other runtime versions. No Apertus
model-ID/revision production gate was added, and the #675
source/import-route identity remains intact.

## Validation

- Flag-free immutable Apertus runtime probe — 1 passed, 13 deselected;
an initial successful run hit an intermittent ORT GenAI process-exit
mutex error, and the clean replay passed with exit 0
- Focused
Apertus/runtime-evidence/runtime-package/tokenizer/docs/census/schema
tests — 436 passed
- `python -m pytest tests/build_graph_test.py tests/cli_test.py src/ -q
-k 'not phi4mm and not apply_weights_unknown' --tb=short` — 9,675
passed, 64 skipped, 12 deselected, 1 subtest passed
- Exact evidence unit coverage: no tokenizer flags succeeds; matching
explicit flags succeeds; wrong repository/revision conflicts before
save; unmatched artifact does not auto-materialize
- `lintrunner f --output oneline --all-files && lintrunner -a` — clean
- `python scripts/generate_gguf_support_docs.py --check` — current
- Focused mypy — clean
- Final independent medium review found one legacy-case assertion-scope
issue; it was fixed, and the follow-up review found no issues.
- Both existing GitHub review threads were answered and resolved before
the final push.

## Waivers

- Preserved-quantized runtime: not claimed; representative evidence is
BF16 imported exactly into float storage.
- CUDA, Foundry Local, and Olive probes: outside this CPU ORT GenAI
evidence promotion and not claimed.
- Separate L4/L5 golden files: waived in favor of the immutable
real-artifact harness, which asserts full logits and all 20 generated
token IDs rather than prefix-only output.

Semantically rebased and validated at exact base
`2c981f2b631a907f43c57d3235647c22cc888eae`; exact head
`256c2b15f17ec327634ef5cae1d1e902a07f5309`. Do not merge as part of this
task.

---------

Signed-off-by: Justin Chu <[email protected]>
Copilot-Session: 75ccb9e3-3ba3-4bee-b5ff-c395a88af1ca
justinchuby added a commit that referenced this pull request Aug 28, 2026
Adds NVIDIA's [RE-USE](https://huggingface.co/nvidia/RE-USE)
speech-enhancement generator (SEMamba) on current Mobius APIs. This is a
semantic replay of the original PR head
`809d674deb6003892e1b439fd0e00ae64abae322` onto `main` at
`027fd42bb89e970defde0098792df104cd83b541`, pinned to NVIDIA
source/config/weights revision
`761905064ea1ea882e015e20a64e2e9d28458890`.

RE-USE is not a Transformers architecture: its config has no
`model_type`, and the checkpoint targets `mamba_ssm`. Mobius therefore
detects the published SEMamba config structurally and supports both the
normal API/CLI model source path and local `--config` directories.

## Implementation

- `SequenceSelectiveScan`: stateless Mamba-1 recurrence over a full
sequence as one ONNX `Scan`, initialized to zero for every graph
invocation with dynamic batch shape. Decay/state accumulation and
`softplus` stay in FP32; outputs return to the activation dtype.
- `SequenceMambaBlock`: full-sequence counterpart to decode-time
`MambaBlock`, retaining checkpoint-compatible parameter names.
- RE-USE model: dense convolutional encoder, 30 bidirectional
time/frequency SEMamba blocks, separate magnitude and phase decoders,
and ONNX `atan2` composition.
- `SpeechEnhancementTask`: `noisy_mag`/`noisy_pha` inputs and
`denoised_mag`/`denoised_pha`/`denoised_com` outputs, with dynamic batch
and time dimensions.
- onnx-genai workflow metadata: NVIDIA preprocessing contract
(`center_reflect_unnormalized`, Hann window, hop 40, window/FFT 320, 8
kHz, `log1p`) plus the required audio-preprocess adapter ABI.
- Public build/CLI integration: `mobius.build()`, `mobius build --model
...`, and `mobius build --config ...` all recognize the bespoke
checkpoint. Remote exports default to the immutable NVIDIA revision;
local exports report local provenance.

The default export now preserves NVIDIA native-rate behavior: frequency
is dynamic, the adapter keeps the decoded sample rate, and
FFT/hop/window use the pinned source floor-then-even scaling rule.
`--input-sample-rate HZ` explicitly bakes a static native-rate graph
without resampling; `--bwe-sample-rate HZ` explicitly applies NVIDIA BWE
resampling and bakes matching static geometry. Unsupported adapters must
reject the declared `scaled_spectrogram` operation rather than silently
analyzing native audio with 8 kHz geometry.

## Source and weight validation

The pinned NVIDIA generator, codec, TF-Mamba block, STFT, inference
code, and published config were checked directly. The graph preserves:

- all 30 TF-Mamba blocks and their bidirectional time/frequency
recurrence;
- fresh zero recurrence state per invocation, with no hidden cache
carried between calls;
- reference convolution geometry, normalization, crop behavior, and
complex-output construction;
- external STFT/ISTFT boundaries and the published magnitude compression
contract.

All **1,416 checkpoint tensors** map to all **1,416 Mobius parameters**
after preprocessing: no missing, extra, or shape-mismatched weights. The
built graph has 1,429 initializers and 5,207 nodes.

A full 9.61M-parameter weighted CPU run serialized to 42,462,537 bytes,
had no unfilled initializers, accepted `(1, 161, 1)`, and produced
finite nonzero outputs with shapes `(1, 161, 1)`, `(1, 161, 1)`, and
`(1, 161, 1, 2)`.

The original PR's independent pure-PyTorch transcription comparison with
real weights remains valid evidence: magnitude and complex outputs
matched to **4.2e-06**; phase exceeded `1e-04` only at 10 of 6,601
near-zero-radius points where `atan2` is ill-conditioned, with
complex-plane error at those points at most `1.7e-05`.

## Dtype and execution-provider behavior

- FP32 and FP16 execute on CPU across dynamic time lengths.
- BF16 exports successfully. Stock CPU ORT has no BF16 `Conv(22)`
implementation, which is a downstream kernel limitation and does not
block export.
- Default, CPU, CUDA, and DML EP-aware graph construction succeeds.
CUDA/DML runtime execution was unavailable on the validation host, so no
runtime claim is made for those providers.
- Export is not gated on downstream onnxruntime-genai or plugin-EP
support.

## Preserved MLX evidence

The time-major `Scan` layout is retained because `onnxruntime-ep-mlx`
0.29.4 did not claim non-axis-zero Scan. The original measurements were
on an Apple M1 Max using 2 seconds of 8 kHz audio in steady state:
approximately **7x** over CPU. The first MLX invocation was roughly **4x
slower than steady state** because of graph translation/kernel
compilation. These historical measurements are performance evidence, not
an export gate, and should be cited with their hardware, runtime
version, input geometry, and warm-up conditions.

## Validation

- Focused RE-USE model, SSM/Mamba component, metadata, API, and CLI
tests pass.
- Broad serial suite: **9,741 passed, 64 skipped, 12 deselected, 47
warnings, 1 subtest**.
- Initialized lintrunner: clean.
- Focused mypy for changed model/task and SSM/Mamba components: clean
with third-party imports skipped.
- Generated 368 model pages plus the index: no resulting documentation
diff.
- Independent medium code review completed; findings around `--config`
detection, task-object acceptance, and local revision provenance were
fixed and retested.

The standard Transformers config-extraction and Transformers integration
levels do not apply because NVIDIA RE-USE is a bespoke non-Transformers
checkpoint; direct config parsing, pinned-source inspection, exact
real-weight loading, full weighted ORT execution, and
reference-transcription parity cover those semantics instead.
Autoregressive generation testing does not apply to a single-invocation
speech-enhancement graph.


## Final exact-base freeze

Semantically rebased onto current `main` at
`2c981f2b631a907f43c57d3235647c22cc888eae` (#697). Its GGUF
tokenizer-evidence and runtime-identity changes are disjoint and
preserved.

Native-rate executable workflow evidence uses the published 8 kHz
baseline `(n_fft=320, hop=40, window=320)` and verifies exact scaled
geometry at 8/16/48 kHz: `(320,40,320)` / `(640,80,640)` /
`(1920,240,1920)`, producing 161/321/961 graph input bins. Odd and even
waveform lengths retain their native rate and exact input length after
inverse STFT alignment. Explicit BWE from 8 kHz to 16 kHz returns 16 kHz
audio at the resampled length with `(640,80,640)` geometry and 321 bins.

The native-rate and BWE selections are fail-closed and mutually
exclusive across every public surface: `ReUseConfig.validate()`, direct
`build_reuse()`, public `mobius.build()`, top-level
`write_onnx_genai_config()`, direct workflow-metadata construction,
metadata writing, and CLI parsing. Top-level auto-export recognizes
`ReUseConfig` from either the explicit argument or `pkg.config` and
validates before package/graph inspection, structural dispatch, advisory
early returns, incomplete-STFT fallback, destination creation, or
writes. Equal and unequal dual-rate pairs reject even with
incomplete/empty packages and missing reference geometry; strings,
floats, booleans, zero, and negative rates reject; valid no-rate and
single-rate incomplete geometries retain the intentional spectrum-input
fallback.

Semantically rebased onto current `main` at
`40c8469cf58275be554f793c9586d31dba51b369` (#683). Its Apertus GGUF
runtime-identity, evidence, config-mapping, schema, and documentation
changes are disjoint and preserved.

Final exact-head gates: affected suite **940 passed, 275 skipped, 1,770
deselected**; broad serial suite **9,833 passed, 64 skipped, 12
deselected, 47 warnings, 1 subtest**; initialized lintrunner, 368
generated model pages/index, focused RE-USE mypy, and diff checks are
clean. An independent medium review traced every public
auto-export/workflow entry and early return, verified absent destination
side effects, audited the full RE-USE diff and Apertus reconciliation,
and reported no findings.

Head: `54a8f589d00eddca6c1ed93b629639801cad5fc4`
Base: `40c8469cf58275be554f793c9586d31dba51b369`

---------

Signed-off-by: Copilot <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 43bb31ac-c136-44bc-8cdf-70cbcedd4a42
Copilot-Session: cb70334e-9510-469a-bd3c-f1301eb0ae47
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