Skip to content

Prove exact Apertus GGUF runtime support - #683

Merged
justinchuby merged 4 commits into
mainfrom
justinchuby-exact-apertus-gguf
Aug 28, 2026
Merged

Prove exact Apertus GGUF runtime support#683
justinchuby merged 4 commits into
mainfrom
justinchuby-exact-apertus-gguf

Conversation

@justinchuby

@justinchuby justinchuby commented Aug 28, 2026

Copy link
Copy Markdown
Member

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 Promote evidenced GGUF tokenizers independently of runtime evidence #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.

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

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 2c981f2256c2b1

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 2c981f2256c2b1

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.

Comment thread src/mobius/integrations/gguf/_config_mapping.py

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

Promotes a single pinned Apertus v1.1 1.5B Instruct BF16 GGUF (CPU, exact-float import) to runtime-supported status by adding immutable runtime evidence records, expanding config parsing to match the pinned GGUF metadata conventions, and updating the evidence/docs/test harnesses to prove and document the support boundary.

Changes:

  • Add Apertus promoted runtime integration coverage (full-logit parity + deterministic ORT GenAI generation assertions) and an independent raw GGUF reader oracle path.
  • Extend Apertus GGUF config post-processing to accept pinned llama.cpp-style unqualified xielu.* metadata and a factorless default RoPE, while tightening/clarifying RoPE scaling subset validation.
  • Register Apertus runtime evidence as “supported”, and update generated capability artifacts + documentation tables accordingly.

Reviewed changes

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

Show a summary per file
File Description
tests/gguf_small_model_runtime_integration_test.py Adds a promoted Apertus runtime case plus oracle mapping for Apertus-specific weights/metadata.
testdata/evidence/gguf_quantization_capabilities.json Adds immutable Apertus runtime evidence record and updates selected artifact budget totals.
testdata/cases/schema.json Raises per-case download budget ceiling to accommodate large real-artifact GGUF cases.
testdata/cases/causal-lm/apertus-v1.1-1.5b-instruct-bf16.yaml Adds the pinned Apertus BF16 GGUF runtime-evidence enrollment case.
src/mobius/integrations/gguf/_runtime_evidence.py Introduces structured Apertus runtime evidence record and registers it for lookup.
src/mobius/integrations/gguf/_route_census_test.py Updates census expectations to reflect Apertus no longer being “evidence-only”.
src/mobius/integrations/gguf/_quant_capabilities_test.py Updates artifact count/byte totals to include Apertus in the selected real artifacts set.
src/mobius/integrations/gguf/_docs_test.py Ensures docs enumerate Apertus as runtime-supported with structured evidence.
src/mobius/integrations/gguf/_config_mapping.py Adjusts Apertus metadata handling (generic xielu.*, factorless RoPE, closed scaling subset validation).
src/mobius/integrations/gguf/_arch_registry.py Promotes Apertus runtime to supported and wires runtime evidence ID + scoped reason.
src/mobius/integrations/gguf/_apertus_test.py Adds focused Apertus tests for generic metadata acceptance, factorless RoPE, and rejection paths.
docs/api/build_from_gguf.md Updates generated support tables to reflect Apertus runtime support and evidence listing.

💡 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/_config_mapping.py
@justinchuby
justinchuby force-pushed the justinchuby-exact-apertus-gguf branch 2 times, most recently from 8cd4b29 to 7e9b199 Compare August 28, 2026 20:16
Promote the pinned Apertus v1.1 1.5B BF16 route with independent raw-GGUF full-logit and stateful decode evidence. Preserve exact tokenizer provenance and package fingerprints while failing closed on conflicting xIELU and RoPE metadata.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 75ccb9e3-3ba3-4bee-b5ff-c395a88af1ca
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Regenerate Apertus against the final runtime-package schema and preserve the serialized graph identity independently from export metadata. Allow only exact final-package evidence to supersede an identifier-level tokenizer census blocker, while unmatched artifacts remain advisory and omit unverified tokenizer assets.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 75ccb9e3-3ba3-4bee-b5ff-c395a88af1ca
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
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 <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 75ccb9e3-3ba3-4bee-b5ff-c395a88af1ca
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
@justinchuby
justinchuby force-pushed the justinchuby-exact-apertus-gguf branch from 7e9b199 to 4aed1b6 Compare August 28, 2026 21:09
Match immutable final-package evidence without requiring callers to repeat its pinned tokenizer source. Preserve matching explicit overrides, reject conflicting tokenizer identities before serialization, and keep unmatched artifacts deferred and tokenizer-omitted.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 75ccb9e3-3ba3-4bee-b5ff-c395a88af1ca
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
@justinchuby
justinchuby merged commit 40c8469 into main Aug 28, 2026
19 of 25 checks passed
@justinchuby
justinchuby deleted the justinchuby-exact-apertus-gguf branch August 28, 2026 21:40
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 <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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