Repository navigation
GGUF export preflight: block-preserving lossless-only classification + budget (reconciled into #581) - #578
Conversation
Performance Comparison
|
Independent review verdict: ❌ REJECT WITH REVISIONReviewed at HEAD Blocking issues1. Duplicate That is raised at parser-construction time, so every 2. Stale sharded-input blocker → false REFUSED for the target model (High). if split_count and split_count > 1:
blockers.append("sharded GGUF input (...) is rejected by the GGUF builder; ... needs a second full copy on disk (double-copy)")This premise is now false. #581's 3. Stale double-copy disk budget (High). 4. Test bakes in the stale behavior. What is correct (and should be preserved when reconciling)
Base / rebase ordering
Revision ownerSapper (Models & Export pod — owns Mobius export + GLM/DeepSeek GGUF enablement, i.e. the #581 multi-shard-import/GGUF-preflight track), with Roy (Lead) to arbitrate the de-duplication decision between this PR and merged #581. Not the current author (Sebastian). Reviewed independently; not the PR author. Do not merge. |
46f292d to
e452dab
Compare
PR #578 was cut against #576 before #581 ("Direct multi-shard GGUF import") merged into main as 7003bc7. #581 already ships a `preflight-gguf` CLI and the `mobius.integrations.gguf._preflight` library, so the standalone `mobius.preflight_gguf` module + second `preflight-gguf` subparser collided with it (argparse `conflicting subparser` on Python 3.12, breaking the whole CLI) and re-implemented parallel logic. Per the review, fold the genuinely-additive value into #581's `_preflight.py` and delete the parallel implementation. Folded in (reusing #581's GgufShardSet/GGUFModel header reader, metadata-only): - Block-preserving, lossless-only per-tensor-type classification against the *real* repacker (`native_block_spec` / `repack_quant_params`) plus float passthrough — no model-name allowlist. Dispositions: passthrough / native-preserve / repack / unsupported. - Real-artifact budget: ONNX external-data output estimate and a weights-only VRAM figure derived from the export artifact. Direct random-access shard reads, so there is NO merged second-copy budget. - A blocker listing the *exact* unsupported native qtypes (e.g. Q5_K/Q2_K/Q3_K), which — with #581's sparse-MoE fusion gate — are the real remaining code gaps, never architecture or sharding. Removed (net-new, now-invalid blockers): the hardcoded `split.count > 1` refusal (GgufShardSet imports sharded sets directly), the `merged_input_bytes` double-copy disk budget, and the `/mnt` staging recommendation. No static DeepSeek 401/404 blocker, no bandwidth/tok-s inference, no payload download. Tests: supported sharded set clears shard+arch gates; dispositions match the real repacker; exact unsupported qtype is the only blocker; budget carries no second-copy and VRAM derives from the artifact; exactly one `preflight-gguf` CLI registration (parser builds on 3.12) and no parallel top-level module. Co-authored-by: Copilot <[email protected]>
PR #578 was cut against #576 before #581 ("Direct multi-shard GGUF import") merged into main as 7003bc7. #581 already ships a `preflight-gguf` CLI and the `mobius.integrations.gguf._preflight` library, so the standalone `mobius.preflight_gguf` module + second `preflight-gguf` subparser collided with it (argparse `conflicting subparser` on Python 3.12, breaking the whole CLI) and re-implemented parallel logic. Per the review, fold the genuinely-additive value into #581's `_preflight.py` and delete the parallel implementation. Folded in (reusing #581's GgufShardSet/GGUFModel header reader, metadata-only): - Block-preserving, lossless-only per-tensor-type classification against the *real* repacker (`native_block_spec` / `repack_quant_params`) plus float passthrough — no model-name allowlist. Dispositions: passthrough / native-preserve / repack / unsupported. - Real-artifact budget: ONNX external-data output estimate and a weights-only VRAM figure derived from the export artifact. Direct random-access shard reads, so there is NO merged second-copy budget. - A blocker listing the *exact* unsupported native qtypes (e.g. Q5_K/Q2_K/Q3_K), which — with #581's sparse-MoE fusion gate — are the real remaining code gaps, never architecture or sharding. Removed (net-new, now-invalid blockers): the hardcoded `split.count > 1` refusal (GgufShardSet imports sharded sets directly), the `merged_input_bytes` double-copy disk budget, and the `/mnt` staging recommendation. No static DeepSeek 401/404 blocker, no bandwidth/tok-s inference, no payload download. Tests: supported sharded set clears shard+arch gates; dispositions match the real repacker; exact unsupported qtype is the only blocker; budget carries no second-copy and VRAM derives from the artifact; exactly one `preflight-gguf` CLI registration (parser builds on 3.12) and no parallel top-level module. Co-authored-by: Copilot <[email protected]>
b534379 to
3474c96
Compare
There was a problem hiding this comment.
Pull request overview
Adds a metadata-only GGUF export preflight that (a) classifies GGUF tensor quant types by lossless conversion path (passthrough vs runtime-native preserve vs MatMulNBits repack vs unsupported) and (b) estimates ONNX external-data + VRAM budgets without downloading tensor bodies, enabling early refusal.
Changes:
- Introduces per-quant-type accounting (
GgufTypeStat) and report fields for estimated ONNX output bytes, weights VRAM bytes, and unsupported quant types. - Implements lossless conversion classification against the actual GGUF repacker support sets, and renders budget/type breakdowns in the human-readable report.
- Adds/extends tests with mixed-quant, multi-shard GGUF fixtures and CLI registration checks.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/mobius/integrations/gguf/_preflight.py | Adds GGUF tensor-type classification + byte budgeting fields and report rendering. |
| src/mobius/integrations/gguf/_preflight_test.py | Adds fixtures and tests validating classification/budgeting behavior and CLI registration. |
| src/mobius/integrations/gguf/init.py | Exports GgufTypeStat from the public gguf integration API. |
Suppressed comments (1)
src/mobius/integrations/gguf/_preflight.py:384
- The MatMulNBits byte estimate should use float32 scales for GGUF Q4_K/Q6_K repacks (they are produced via repack_dequantized_tensor() which returns float32 scales). Otherwise output_bytes and VRAM are undercounted for those types.
out = _matmulnbits_output_bytes(np_shape, bits, block_size)
return "repack", out, f"MatMulNBits {bits}-bit/{block_size}"
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| def _matmulnbits_output_bytes(np_shape: tuple[int, ...], bits: int, block_size: int) -> int: | ||
| """Estimate ``com.microsoft::MatMulNBits`` external-data bytes for a repack. | ||
|
|
||
| Sizes the ``[N, blocks_per_row, blob]`` weight, ``[N, blocks_per_row]`` fp16 | ||
| scales and ``[N, ceil(blocks_per_row*bits/8)]`` bit-packed zero points with | ||
| per-row block rounding, matching the operator layout (K is padded up to a | ||
| whole block per row, not across the flattened tensor). | ||
| """ | ||
| if not np_shape or not block_size: | ||
| return 0 | ||
| k = np_shape[-1] | ||
| rows = 1 | ||
| for dim in np_shape[:-1]: | ||
| rows *= dim | ||
| blocks_per_row = math.ceil(k / block_size) | ||
| weight = rows * blocks_per_row * (block_size * bits // 8) | ||
| scales = rows * blocks_per_row * 2 # fp16 per block | ||
| zero_points = rows * math.ceil(blocks_per_row * bits / 8) # bit-packed per row | ||
| return int(weight + scales + zero_points) |
| " budget (real artifacts, direct random-access — no merged copy):" | ||
| ) | ||
| lines.append( | ||
| f" download : {_gib(self.total_bytes):.3f} GiB " | ||
| f"(shard set, read in place)" |
| (:func:`._repacker.native_block_spec` / :func:`._repacker.repack_quant_params`) | ||
| plus the float passthrough set — never a model-name allowlist: | ||
|
|
||
| * ``passthrough`` — a float block kept as-is (F32/F16/BF16). |
🔧 Revision (Sapper) — reconciled into #581, ready for independent re-reviewReworked at Addresses every blocking issue in the rejection verdict:
Preserved value: dynamic arch lookup ( Also dropped: Validation: Per the reviewer rejection lockout, this revision was authored independently (not the |
Independent re-review verdict: ❌ REJECT WITH REVISIONReviewed at HEAD What is correctly fixed (verified independently, not just re-reading the PR body)
Blocking issue (High confidence, substantive)
Ran the test's exact scenario directly:
To be clear about severity: this is a test-fidelity gap in the new regression test, Fix scope (narrow, does not require redesign): make the synthetic fixture's Minor (not blocking on its own, but the PR's own validation claim is imprecise)
VerdictREJECT WITH REVISION. The CLI de-duplication, sharded-input/no-second-copy budget Per the reviewer lockout protocol, Sapper is now locked out of this artifact Reviewed independently (Roy, Lead); not the PR author. Do not merge. |
…ruff format Addresses the sole blocking item and the minor from the independent re-review of #578 (Roy, REJECT WITH REVISION). Narrow, test-only + formatting revision; production behavior, CLI, budgets, GgufShardSet, builder, and BQMoE fusion are unchanged. Blocking item: `test_sparse_iq1_moe_is_the_remaining_blocker_not_sharding` did not exercise the sparse-MoE honesty blocker it claimed to test. Its fixture (stem `q`, no `general.name`) put no `IQ1_S` string into any of the three candidates production feeds to `_detect_quantization` (`general.file_type_name`, `path.name`, `general.name`), so `quantization` resolved to None, `_assess_sparse_moe` returned `(True, [])`, and the old assertions (`is_sharded` + absence of "shard"/"split") passed trivially whether or not any blocker fired. Fix (test-fidelity only, no production change, no monkeypatch/weakening): - New independent fixture `_write_glm_moe_iq1_sharded_gguf` faithful to the flagship GLM-5.2 UD-IQ1_S set on exactly the signals production consumes: * shard filenames are the exact real `GLM-5.2-UD-IQ1_S-000i-of-000N.gguf` that `_detect_quantization` reads from `path.name` (GGUFWriter truncates a dotted stem, so shards are written under a dot-free stem then renamed; only on-disk names change, embedded split metadata untouched, discovery is filename-prefix based); * `general.architecture='glm-dsa'` -> resolved model type `glm_moe_dsa`, `glm-dsa.expert_count` marks routed-expert MoE; * real per-projection `blk.i.ffn_{gate,up,down}_exps.weight` tensors physically stored as `IQ1_S` native blocks (3D), so the detected quant tag is consistent with the actual payload. Helper `_raw_quant_expert_rows` writes the 3D routed-expert raw blocks. - The test now proves its preconditions explicitly (real quant-bearing filename via `_detect_quantization`; sharded; arch resolves to `glm_moe_dsa`; `num_experts==8`; `quantization=="IQ1_S"`; IQ1_S experts present and `native-preserve`; no unsupported qtypes), then asserts the positive gate: `sparse_moe_fusion_supported is False` with exactly one blocker containing the sparse-MoE fusion text ("dense-all-expert", "BlockQuantizedMoE", "glm_moe_dsa", "IQ1_S"), while sharding is explicitly not a blocker. The assertions fail if filename detection or the sparse-MoE gate is bypassed (verified: the prior vacuous fixture makes them fail). Minor: ran `ruff format` on the two affected files. `_preflight.py` change is formatting-only (line re-wrapping in `GgufPreflightReport.__str__`); no logic change. `ruff check` and `ruff format --check` are both clean on the touched files. Validation (local): `_preflight_test.py` 22/22, `integrations/gguf/` 408/408, `_cli_option_parity_test.py` 36/36. Co-authored-by: Copilot <[email protected]>
Revision pushed — sparse-IQ1 MoE blocker test made non-vacuous +
|
| field | old fixture (vacuous) | new fixture (this revision) |
|---|---|---|
shard[0].name |
q-00001-of-00002.gguf |
GLM-5.2-UD-IQ1_S-00001-of-00003.gguf |
_detect_quantization(name) |
None |
IQ1_S |
architecture → resolved_model_type |
llama → llama |
glm-dsa → glm_moe_dsa |
num_experts / quantization |
8 / None |
8 / IQ1_S |
is_sharded / split_count |
True / 2 |
True / 3 |
unsupported_types |
[] |
[] |
sparse_moe_fusion_supported |
True (wrong) |
False (correct) |
blockers |
[] |
1 × sparse-MoE fusion blocker |
Blocker text now asserted (present in the report):
sparse-MoE fusion blocker: … is a MoE architecture ('glm_moe_dsa') whose routed experts use 'IQ1_S' native blocks. No sparse top-k BlockQuantizedMoE fusion exists for these block formats — only int4 MatMulNBits experts fuse into com.microsoft::QMoE. A default export would build a dense-all-expert graph … so build_from_gguf fails closed.
Non-vacuity proof (negative control): feeding the old vacuous fixture's report through the new assertions fails on sparse_moe_fusion_supported is False and len(blockers) == 1 — i.e. the revised test fails unless the sparse-MoE blocker actually fires for a real quant-bearing filename. Sharding is still explicitly asserted not to be a blocker (shard/split/merge/double-copy/second absent from blocker text).
Minor — ruff format
Ran ruff format on the two affected files. The _preflight.py change is formatting-only (line re-wrapping in GgufPreflightReport.__str__, the budget-lines block) — no logic change. Both gates clean on the touched files:
ruff check→ All checks passedruff format --check→ 3 files already formatted
Test evidence (local, exact counts)
_preflight_test.py→ 22 passedintegrations/gguf/→ 408 passed_cli_option_parity_test.py→ 36 passed
No production behavior, CLI, budgets, GgufShardSet, builder, or BQMoE fusion were modified. Stopping for @-review (Roy) — do not merge.
The dense non-MoE fixture _write_quant_sharded_gguf carried a num_experts kwarg whose only caller was the pre-revision vacuous MoE test. That caller now uses the dedicated _write_glm_moe_iq1_sharded_gguf fixture, leaving the param dead. Per the no-backward-compat / clean-API directive, remove the shim rather than retain it; the dense fixture is now explicitly expert-free and points at the MoE fixture for sparse routed-expert coverage. No caller of _write_quant_sharded_gguf passed num_experts, so this is caller-atomic. Co-authored-by: Copilot <[email protected]>
Follow-up (HEAD
|
…izedMoE (+ build_from_gguf wiring) (#591) ## Native-block sparse-MoE fusion + `build_from_gguf` integration Collapses GLM-style **routed** native-block expert storms (a per-expert `pkg.nxrt::BlockQuantizedMatMul` for every gate/up/down of every expert, dispatched by an `Equal` one-hot mask) into **one sparse top-k `pkg.nxrt::BlockQuantizedMoE` per layer**, reusing the existing native blocks **byte-for-byte** (no dequantize, no requantize). Gated on graph/tensor structure, never on model names. ### What's here 1. **Rewrite** (`rewrite_rules/_block_quantized_moe_fusion.py`) — the transform: finds the dense-fallback MoE subgraph, validates **all** layers, then emits. Two-pass so an unfusable layer fails **atomically** with the graph untouched. 2. **Builder integration** (`integrations/gguf/_builder.py`) — wires the fusion into `build_from_gguf` at the **single** post-export authority point (step 9b, after `pkg.apply_weights`, once every native block carries real packed bytes), then a final-graph-state honesty gate. ### Applicability verdict (Phase-1 audit) - GLM-5.2 UD-IQ1_S/M routed experts are **per-projection mixed-format** per layer (fused `gate==up` in iq1_s/iq1_m; `down` in a higher-bit format such as iq4_xs). A v1 single-`format` `BlockQuantizedMoE` therefore fuses **0** GLM layers. - Expressing a mixed-format layer needs the **`block_layout_version=2` per-projection ABI** (`fc1_format`/`fc2_format`/`fc3_format`). That runtime ABI lives on an **unmerged onnx-genai branch**, so mobius's runnable runtime does **not** yet have it. - **Honest consequence:** GLM-5.2 mixed-format layers **typed-reject** (`SparseMoEExportError`, message names `block_layout_version=2`) until the runtime ships v2 — we never emit an unrunnable v2 node by default. **Uniform** native-block routed MoE **does** fuse today (v1). ### Honesty / fail-closed policy - Default `allow_dense_moe=False`. Unsupported layers (mixed w/o v2, per-expert bias, ragged/incomplete groups) raise the shared **`SparseMoEExportError`** atomically; the graph is left as the original dense storm. - `_perproj_bqmoe_v2_runtime_available()` gates v2 emission on `MOBIUS_ENABLE_BQMOE_PERPROJ_V2` (default off). Flip it **only** once the onnx-genai v2 runtime ships. - The **pre-export module-level gate call was removed** (it would reject the layers the fusion now collapses); enforcement moved to the **final graph state** — the fusion's atomic reject + a `_assert_sparse_moe_graph` backstop that fails closed on any surviving routed `.experts.` `BlockQuantizedMatMul` storm. Single mechanism, no duplicate gate. Batty's `_assert_sparse_moe_capability` / `_routed_dense_block_expert_paths` (#581) stay defined for their unit tests. - `allow_dense_moe=True` may warn + retain the dense fallback, but **never** counts as a performance path (no throughput claim). ### Emitted ABI (unchanged runtime contract) `BlockQuantizedMoE` 9 inputs, FLOAT32: `[input, router_logits, fc1_experts_weights(uint8 4D), fc1_bias?, fc2_experts_weights, fc2_bias?, fc3_experts_weights?, fc3_bias?, router_weights?]`. Uniform layer → `format` attr (v1). Mixed layer → `block_layout_version=2` + `fc1_format`/`fc2_format`/ `fc3_format`. Expert banks are the source native blocks **stacked verbatim** (byte-preservation asserted in tests). ### Tests (same commits) - **Rewrite unit** (`_block_quantized_moe_fusion_test.py`, 23): GLM-style Sigmoid+TopK+normalize routing, top-k {1,8}, byte-preserving stacking, atomic fail-closed (dropped/duplicate/ragged/mixed-bias experts), structural proof the expert matmuls collapse, and the new **v2-runtime gate** (uniform fuses without v2; mixed typed-rejects without v2; mixed emits v2 when opted in). - **Builder integration** (`_block_quantized_moe_builder_test.py`, 20): step-9b helpers on synthetic exported packages (default fail-closed, v2 opt-in, dense retention, byte-preserving banks, deterministic external data, final-state backstop) **plus 5 real end-to-end `build_from_gguf` builds** on synthetic native-block MoE GGUFs (`qwen3_moe` / `qwen2_moe`, which lower through the identical routed dense-loop → `BlockQuantizedMatMul` storm and the same step-9b authority point): - uniform → **one** `BlockQuantizedMoE`, only attention matmuls remain (no storm); - mixed → **`SparseMoEExportError`** (GLM-5.2's honest path); - mixed + `MOBIUS_ENABLE_BQMOE_PERPROJ_V2=1` → one **v2** node; - `allow_dense_moe=True` → dense storm retained (no fused node); - **shared expert stays dense** while the routed storm collapses. Full `rewrite_rules/` + `integrations/gguf/` suites: **576 passed, 1 skipped**. `ruff check` + `ruff format --check`: clean. ### Remaining typed blockers (not overclaimed) 1. **v2 per-projection runtime ABI is unmerged in onnx-genai** → GLM-5.2 mixed-format typed-rejects end-to-end until it ships. Uniform native-block MoE fuses today. 2. **No A100 benchmark yet** — deferred until a runnable shape-faithful importer path exists (GLM-5.2 can't build to a runnable graph until v2 lands). Full-model speed is not claimed. 3. **`_builder.py` merge coordination** — Sapper's #578 (unmerged) also rewrites `_builder.py`; a future rebase will need coordinator-mediated conflict resolution. No live collision on this base. ### Dependency on Batty's sharded import Builds on the merged **#581** (`GgufShardSet`, `glm-dsa` → `glm_moe_dsa` bridge, shared `SparseMoEExportError`) and **#576**; rebased cleanly on `059bf5f`. Only uses those committed public interfaces — no edits to shard-reader / architecture- mapping files. **Draft — do not merge.** Requesting independent review (excluding author). --------- Co-authored-by: Copilot <[email protected]>
Roy — re-review of Deckard's narrow revision, exact HEAD
|
…ion) [Slice 3B] (#599) ## Slice 3B — Mobius opt-in `--paged-attention` export (dense MLA, LATENT) Emits `com.microsoft::PagedAttention` v1 in **LATENT / absorbed-MLA** mode for property-compatible **dense MLA** (DeepSeek-V2/V3, GLM-5.2 `--glm-full-attention`). Builds on the merged onnx-genai native runtime contract: audit/typed-validator/oracle (#1940), KV index emission (#1955), CUDA LATENT kernel (#1978). ### Guarantees - **Default off.** Feature-off exports are **byte-identical** to the current dense-MLA graph (all new code is gated behind the flag/task). A byte-identical test locks this. - **Property-based eligibility, never model names.** Decided from semantic geometry: latent width, `v_head_size`, partial-RoPE suffix (`rotary_offset = kv_lora_rank`), cache dtype (fp16/bf16), and the onnx-genai-kv page/block constraints (head_size %8, kv_lora %8, rotary_dim %16, rotary_offset %8, block pow2 ≥16). - **Typed reject, never silent fallback.** Active query-dependent sparse selection (GLM **DSA/IndexShare**, DeepSeek-V4 **CSA/HCA**), **MTP**, **quantized cache**, **head_sink**, **qk-norm**, **sliding window** all raise a typed reason at model construction / build. Feature-on with an incompatible geometry errors. GLM's *vestigial* indexer config (dropped under `--glm-full-attention`) does **not** reject. - **One cache authority.** The op consumes/mutates caller-owned page buffers in place; Mobius **allocates no pages** and creates no second cache manager. `onnx-genai-kv` stays the sole authority. The graph binds caller-owned `block_table` / `slot_mapping` / cumulative + past lengths / per-layer LATENT `key_cache`, aliases the cache in place, and derives token positions from the length tensors (no `position_ids` input). ### Emitted contract - One `PagedAttention` node per layer, `_domain="com.microsoft"`, LATENT attrs (`kv_cache_layout=LATENT`, `kv_num_heads=1`, explicit `scale`, `v_head_size=kv_lora_rank`, `rotary_offset=kv_lora_rank`, `do_rotary=1`); `rotary_dim` is **derived** from `cos_cache`, never emitted. - Model inputs: `input_ids`, `block_table` (i32), `slot_mapping` (i32), `cumulative_sequence_length` (i32), `past_seqlens` (i32), per-layer `key_cache.{i}` `[num_blocks, block_size, 1, head_size]`. Outputs: `logits`, `updated_key_cache.{i}` (aliases input). - `kv_b_proj` is absorbed into the query/output projections at weight-apply time; numeric contract mirrors the onnx-genai equivalence oracle. ### Tests (same commit) - **component** (`components/_paged_mla_test.py`): eligibility rejects, absorption, numpy **decomposed-vs-absorbed LATENT parity** (rel < 1e-6), structural emission. - **model-level** (`models/paged_mla_export_test.py`): feature-off byte-identical; feature-on structural + exact op attrs/inputs/outputs/model IO; typed rejects (DSA/CSA/HCA/MTP/window); torch-tensor weight absorption; DeepSeek-V3 path proves eligibility is not name-gated. - **CLI** (`tests/cli_test.py`): `--features paged-attention` plumbing + task resolution + mutual-exclusion errors. - Existing GLM / DeepSeek / task / build-graph tests pass unchanged. ### Scope / gates - **No full-size performance claim.** Tiny correctness only. Native runtime full-size verification is separate. - Executing the emitted graph needs **ORT ≥ 1.29 CUDA** (contrib op is unknown to the base onnx checker, so model-level assertions are structural). - Avoids #578 (GGUF preflight) and #591 (BQMoE) files. **Draft — do not merge.** Independent review required (reviewer excluding Leon/Sapper; Gaff or Roy final approval). Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
…able export on nxrt runtime capability Rebased #593 (native pkg.nxrt::CompressedSparseAttention export, ratio-4 CSA + ratio-128 HCA) onto Mobius main now that #578 (6992181) and #602 (d16cd4a, mobius.integrations._block_quant block-FP8 / packed-FP4 loading contract) are merged. Consumes the merged _block_quant API directly; the temporary stacked duplicate-parse branch is retired. #602 rejects the block-scaled-FP8 + packed-FP4 DeepSeek-V4-Flash checkpoint at config resolution (the INT4/per-tensor path cannot load it). That is correct for a normal export, but it also blocks a native-CSA export before any graph exists. Split the behavior into the two stages the directive requires: * Non-native (default) export keeps #602's early, loud config-resolution reject -- unchanged, its tests still pass. * native_csa opts into DEFERRING that reject: ArchitectureConfig.from_transformers catches the typed BlockQuantExportError, records the parsed block_quant_scheme on the config, and lets graph construction PROGRESS past the former generic "Weight shape mismatch" (build_from_module emits the CSA nodes + compressed state IO). The runnable FULL EXPORT then fails closed at a runtime-capability gate (assert_native_runtime_supports_block_quant, enforced at the top of DeepSeekV4 preprocess_weights, before apply_weights) while nxrt cannot execute block-FP8 / planar-FP4 weights. The gap string is sourced from _block_quant.runtime_representation_gap, so the gate tracks the real nxrt format strings and opens automatically when the native runtime slice lands -- no change here. Never a silent dense fallback, never partial-native. No BC shims: ArchitectureConfig gains a block_quant_scheme field; deepseek_v4.py adds no FP8/FP4 weight parsing (delegates to _block_quant). No performance claim -- ratio-4 sparse execution and >=16-decode remain blocked on the unmerged native block-FP8 / planar-FP4 runtime. Tests (deepseek_v4_flash_test.py, 45 pass): non-native fail-closed at config resolution; fp4-experts-alone owned; native_csa defers (scheme recorded, quant None); full export typed-rejects at the runtime-capability gate; graph construction progresses past block-quant (CSA node built); preprocess_weights enforces the gate; property-gated not a blanket V4/native_csa refusal; per-tensor fp8 not over-owned. #602 (_block_quant_test) + config (_base_test/_extractors_test) suites unchanged (69 pass). Co-authored-by: Copilot <[email protected]>
## 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]>
What
Metadata-only, block-preserving / lossless-only classification and budget for
GGUF export, folded into the #581 preflight library (
mobius.integrations.gguf._preflight).This is the reconciled revision of the rejected PR: the standalone
mobius.preflight_ggufmodule and its duplicatepreflight-ggufsubcommand aregone; the additive value lives on the single #581 code path.
Rebased/rebuilt onto current
main(now includes #5817003bc7and #576059bf5f). Base retargeted from the deletedsebastian/export-preflight-streamingto
main. Single focused commit; no dependency on #576.Why the rejection is addressed
#581 shipped a
preflight-ggufCLI + preflight library after this branch wascut. The old branch added a second subparser (breaking
build_parser()onPython 3.12 with
conflicting subparser: preflight-gguf) and duplicated headerparsing / shard resolution. It also carried three now-invalid blockers.
Removed (net-new, now-false):
preflight-ggufCLI ownership — exactly oneregistration remains (Direct multi-shard GGUF import + GLM-5.2 (glm-dsa→glm_moe_dsa) resolution #581's); the parser builds on 3.12.
split.count > 1refusal —GgufShardSetimports sharded setsdirectly, so GLM-5.2
UD-IQ1_S(6 shards) is not rejected for sharding.merged_input_bytes/ second-copy disk budget — direct random access means nomerged file; the budget reflects real artifacts only.
/mntstaging recommendation — no environment paths in product defaults.download (headers only).
Preserved / folded in (validated against the real repacker):
glm-dsa → glm_moe_dsa, from Direct multi-shard GGUF import + GLM-5.2 (glm-dsa→glm_moe_dsa) resolution #581).(
native_block_spec/repack_quant_params) + float passthrough — nomodel-name allowlist:
passthrough/native-preserve/repack/unsupported.VRAM figure derived from the export artifact (not the source dtype).
unsupported native qtypes (e.g.
Q5_K/Q2_K/Q3_K) are the real remaining codegaps for
UD-IQ1_S— never architecture or sharding.GgufPreflightReportgains additive fields (type_stats,output_bytes,vram_weights_bytes,unsupported_types) with defaults; #581 APIs unchanged.Tests
Added to
_preflight_test.py(metadata-only, shape-faithful multi-shardfixtures): a supported sharded set clears the shard + arch gates;
dispositions match the real repacker; an unsupported qtype is the only blocker;
the budget carries no second-copy and VRAM derives from the artifact; exactly one
preflight-ggufCLI registration and no parallel top-level module. Full_preflight_test.py+ the GGUF suite (408) + CLI option parity pass;ruffclean (0.16.2).
Independent re-review requested. Do not merge.