Skip to content

Add small-model GGUF runtime evidence - #607

Merged
justinchuby merged 1 commit into
mainfrom
justinchuby-validate-small-gguf-models
Aug 25, 2026
Merged

justinchuby merged 1 commit into
mainfrom
justinchuby-validate-small-gguf-models

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

  • add first-class pinned GGUF sources to the L4/L5 YAML harness, including immutable GGUF/reference revisions, byte size, LFS SHA-256, tensor census/qtypes, CPU import route, config hash, and golden provenance
  • add reproducible F16 L4/L5 coverage for HuggingFaceTB/SmolLM-135M and HuggingFaceTB/SmolLM2-135M-Instruct through real CLI build, save/reload, ORT prefill, 20 cache-threaded decode steps, full-logit HF parity, and deterministic generation
  • make GGUF case changes select llama in affected-model detection and run the real-artifact tests in fast integration CI

Evidence

Artifact Identity Tensor census Max full-logit abs diff Generation
neopolita/smollm-135m-gguf@22cca988936eafe92908e7558907c3964e10bba7/ggml-model-f16.gguf 270,885,504 bytes; ec8c775c16944a7e4b5251f97b3f848500dcc3e701b0d492ce9055cea42138a2 272 (F16=211, F32=61) 1.277e-4 exact 20/20
unsloth/SmolLM2-135M-Instruct-GGUF@9e6855bc4be717fca1ef21360a1db4b29d5c559a/SmolLM2-135M-Instruct-F16.gguf 270,885,952 bytes; 5157ca60744d21631818364854ac8e4452e1b8022d2ab4c8a2f9cda2344afb30 272 (F16=211, F32=61) 7.176e-5 observed in the initial probe; committed test gates at 2e-4 exact 20/20

Both routes are CPU, dynamic-cache, llama_qk_permute=true, and preserve_quantization=false. Runtime packaging remains deferred: the public GGUFs use compiled llama.cpp smollm pre-tokenizer metadata and do not embed tokenizer.huggingface.json, so no architecture-wide or runtime-package support is claimed.

The pinned SmolLM2 Q4_K_M artifact (105,454,144 bytes, ed5fa30c487b282ec156c29062f1222e5c20875a944ac98289dbd242e947f747) was exercised but is not promoted or compared against mismatched unquantized weights. Its preserved MatMulNBits route diverges from the same artifact under llama.cpp, while Mobius dequantization matches llama.cpp; this exact blocker is documented in the integration test.

Validation

  • real-artifact GGUF integration: 2 passed
  • targeted L4/L5: 4 passed
  • schema/golden/detector infrastructure: 352 passed
  • dashboard/model coverage: 810 passed, 225 skipped
  • Ruff formatting and lint: passed
  • two independent reviews completed; CI selection, dashboard aggregation, provenance, and route-hash findings fixed

The broad non-integration suite remains at 7,054 passed with two pre-existing glm_moe_dsa shape-inference failures unrelated to this diff. CI was not awaited.

@github-actions

github-actions Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 9703140 → bc8afd5

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

Copy link
Copy Markdown

Performance Comparison

Comparing 9703140 → bc8afd5

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 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 429 429 +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-finalize-gguf-support-matrix branch from 7326da4 to 2e0df5a Compare August 25, 2026 16:56
Base automatically changed from justinchuby-finalize-gguf-support-matrix to main August 25, 2026 16:57
@justinchuby
justinchuby requested a review from a team August 25, 2026 16:57
Add pinned SmolLM and SmolLM2 F16 GGUF L4/L5 cases with immutable artifact, reference, tensor-census, import-route, and golden provenance checks. Exercise CLI save/reload, full-logit prefill and cache-threaded decode parity, deterministic generation, and wire exact level-specific cases into affected-model and fast integration CI selection. Pin every HuggingFace reference resource, validate L5 provenance independently, and fail closed for malformed or unmappable evidence selectors.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
@justinchuby
justinchuby force-pushed the justinchuby-validate-small-gguf-models branch from efef079 to bc8afd5 Compare August 25, 2026 17:54
Copilot AI lite review requested due to automatic review settings August 25, 2026 17:54
@justinchuby
justinchuby merged commit 773c965 into main Aug 25, 2026
15 of 23 checks passed
@justinchuby
justinchuby deleted the justinchuby-validate-small-gguf-models branch August 25, 2026 17:55

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 extends Mobius’ golden-test and CI selection infrastructure to support pinned GGUF sources as first-class L4/L5 evidence, and adds real-artifact small-model GGUF runtime parity coverage to validate CLI build/save/reload + ORT prefill/decode correctness against HuggingFace references.

Changes:

  • Add GGUF source pinning (revision, size, SHA-256, tensor census/qtypes, EP, config hash, quantization expectations) to golden case schema + golden JSON provenance, and enforce provenance checks in L4/L5 tests.
  • Add real-artifact integration coverage for SmolLM / SmolLM2 135M F16 GGUFs via CLI build-gguf, ORT cached decode, full-logit parity, and deterministic generation.
  • Update affected-model detection + GitHub Actions workflows to select L4 vs L5 runs based on changed golden-case/golden-data files, and pin torch reference loads to immutable revisions.

Reviewed changes

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

Show a summary per file
File Description
tests/gguf_small_model_runtime_integration_test.py New integration-fast test validating GGUF CLI build + ORT parity + deterministic decode for pinned small GGUF artifacts.
tests/e2e_golden_test.py Add exact-case selection via MOBIUS_GOLDEN_CASES; add GGUF build path; enforce golden provenance checks.
testdata/golden/causal-lm/smollm2-135m-gguf-f16.json New L4 golden for SmolLM2 GGUF case including provenance block.
testdata/golden/causal-lm/smollm2-135m-gguf-f16_generation.json New L5 golden generation marker for SmolLM2 GGUF case including provenance block.
testdata/golden/causal-lm/smollm-135m-gguf-f16.json New L4 golden for SmolLM GGUF case including provenance block.
testdata/golden/causal-lm/smollm-135m-gguf-f16_generation.json New L5 golden generation marker for SmolLM GGUF case including provenance block.
testdata/cases/schema.json Extend case schema with a gguf object to pin GGUF source identity and expected import-route properties.
testdata/cases/causal-lm/smollm2-135m-gguf-f16.yaml New pinned GGUF-backed L4+L5 case definition for SmolLM2 135M Instruct.
testdata/cases/causal-lm/smollm-135m-gguf-f16.yaml New pinned GGUF-backed L4+L5 case definition for SmolLM 135M.
src/mobius/_testing/torch_reference.py Add revision parameter and pass it through tokenizer/config/model loads and Nemotron-H repair snapshot lookup.
src/mobius/_testing/torch_reference_test.py New unit test asserting load_torch_model() pins all HuggingFace resources to the provided revision.
src/mobius/_testing/golden.py Add GGUF source field to test case model and support storing provenance in golden JSON outputs.
scripts/generate_golden.py Include provenance in generated golden and generation JSON when cases are GGUF-backed; pin reference loads to case revision.
scripts/detect_affected_models.py Add golden-case/golden-data change detection and emit L4/L5 affected-case selectors for CI.
scripts/detect_affected_models_test.py New/updated tests for golden-case classification and level-split affected-case detection + GitHub output fields.
.github/workflows/main.yml Wire new affected-case outputs into reusable GPU golden workflows; gate L4 vs L5 jobs separately; include new GGUF integration test in integration-fast.
.github/workflows/gpu_l5_generation_e2e.yml Accept affected_cases input and run case-scoped L5 generation tests via MOBIUS_GOLDEN_CASES.
.github/workflows/gpu_l4_golden_parity.yml Accept affected_cases input and run case-scoped L4 golden parity tests via MOBIUS_GOLDEN_CASES.

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

Comment thread tests/e2e_golden_test.py
Comment on lines 3021 to 3025
gen_path = generation_json_path_for_case(case)
_assert_gguf_golden_provenance(case, gen_path)
expected_token_ids = load_generation_golden(case)
if expected_token_ids is None:
pytest.skip(f"Generation golden file missing: {gen_path}")
Comment on lines +212 to +236
assert len(captured) == 1
route = json.loads(captured[0].gguf_import_route)
assert route == {
"architecture": "llama",
"config_sha256": case.config_sha256,
"execution_provider": "cpu",
"model_type": "llama",
"module_type": "llama",
"preserve_quantization": False,
"registry_import": {
"config_key_map": None,
"config_postprocessor": None,
"llama_qk_permute": True,
"offset_norm": False,
"required_metadata": [],
"rope_interleave": False,
"tensor_processor": "llama",
"v_head_reorder": False,
"vlm_builder": None,
},
"route_schema": 1,
"static_cache": False,
"task": {"class": "builtins.str", "state": "text-generation"},
"tensor_map_recipe": ["llama"],
}
Comment thread tests/e2e_golden_test.py
Comment on lines +547 to +550
artifact = GGUFModel(gguf_path)
qtypes = Counter(qtype.name for _, _, qtype, _ in artifact.tensor_items_raw())
assert len(artifact._reader.tensors) == source["tensor_count"]
assert dict(sorted(qtypes.items())) == source["tensor_qtypes"]
justinchuby added a commit that referenced this pull request Aug 25, 2026
## Summary
- materialize tokenizer assets only from an immutable, evidence-pinned
Hugging Face revision with exact size and SHA-256 identities
- verify ordered vocabulary/token IDs, merges, special IDs and flags,
tokenizer pipeline assets, chat templates, and GGUF metadata identity
before atomic package publication
- bind the route through CLI, YAML/golden provenance, offline cache
handling, redirect/auth safety, direct-GGUF transaction checks, and
runtime evidence
- promote only the exact SmolLM F16 artifact/CPU/ORT 1.29.0 route;
retain fail-closed SmolLM2 rejection because its GGUF padding ID 0
contradicts the official pinned tokenizer padding ID 2

## Validation
- `386 passed` focused GGUF/tokenizer/runtime/CLI/schema suite
- `2658 passed` full GGUF + CLI suite
- `7062 passed, 52 skipped` broad affected suite; only the two
pre-existing `glm_moe_dsa` shape-inference failures remain
- `2 passed` real SmolLM/SmolLM2 runtime integration
- `6 passed` targeted L4/L5 golden tests
- lintrunner passed
- two independent reviews completed and findings addressed

Stacked on #607 via `justinchuby-validate-small-gguf-models`.

---------

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

Fixes the preserved Q4_K_M/MatMulNBits correctness divergence exposed by
#607.

Q4_K_M is a model-level mixed preset, not a GGML tensor type. The pinned
SmolLM artifact contains Q5_0=166, Q4_K=16, Q8_0=15, Q6_K=14, and F32=61
tensors. Mobius correctly decoded Q4_K's 144-byte/256-value layout,
six-bit scale/min fields, nibble order, orientation, and signed minimum
subtraction, and ORT correctly consumed the emitted affine packing. The
divergence came earlier: the importer normalized the mixed Q5/Q4_K/Q6/Q8
source tensors into one four-bit MatMulNBits contract, adding a second
lossy quantization.

This change:
- records which affine repacks preserve dequantized values and rejects
lossy or incompatible routes under `keep_quantized=True`;
- fails closed for unsupported projections, mixed float projections,
embeddings/heads, multimodal builders, MTP sidecars/native blocks, and
packed fused expert gate/up tensors;
- retains explicit `keep_quantized=False` / `--dequantize` as the opt-in
float route;
- adds independent asymmetric Q4_K and ORT MatMulNBits value tests plus
real SmolLM2 Q4_K_M prefill/decode/generation coverage.

## Root-cause evidence

The first divergence is already present in layer 0 before ORT execution:

| Tensor role | Source qtype | Relative L2 error after normalization |
|---|---:|---:|
| Q projection | Q5_0 | 0.09408 |
| K projection | Q5_0 | 0.09410 |
| V projection | Q8_0 -> Q4 | 0.08793 |
| FFN down | Q6_K -> Q4 | 0.08310 |

The Q4_K formula is `value = d * sub_scale * q - dmin * sub_min`.
Although Q4_K itself can be represented by four-bit MatMulNBits with
floating zero points, the full Q4_K_M mixture cannot be represented
losslessly by one four-bit graph contract. ORT 1.29 also advertises
8-bit MatMulNBits in schema but the tested CPU unpacked path rejects it
with `Only 2b and 4b quantization is supported for unpacked compute for
now`.

## Validation

- Final focused GGUF/quantization/MatMulNBits suite: **745 passed**
- Real pinned SmolLM2 Q4_K_M test: **1 passed**
  - default API and CLI preservation reject before producing a model;
  - explicit dequantization builds, saves, reloads, and runs;
- full prefill and ten cached-decode logits match the same-artifact
Transformers GGUF reference;
  - maximum prefill absolute difference: **9.0599e-05**;
- ten greedy tokens match exactly: `198, 198, 18, 504, 2388, 13685, 284,
5208, 28, 198`.
- Earlier broad run: **7058 passed, 52 skipped**; the two remaining
`glm_moe_dsa` shape/checker failures reproduce on the base and are
unrelated.
- Changed-file Ruff check and format check pass.
- Two independent final review passes completed; all findings were
addressed and the final MoE fix was re-reviewed with no findings.

## Verdict

This is an importer preservation-policy bug, not an ORT Q4 packing bug.
Preservation now succeeds only for value-equivalent routes and otherwise
fails closed rather than emitting wrong logits.

---------

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.

2 participants