Skip to content

Preserve pinned Qwen4Exp FP8 checkpoint with QDQ - #658

Merged
justinchuby merged 22 commits into
mainfrom
justinchuby-integrate-qwen4exp-fp8
Aug 27, 2026
Merged

Preserve pinned Qwen4Exp FP8 checkpoint with QDQ#658
justinchuby merged 22 commits into
mainfrom
justinchuby-integrate-qwen4exp-fp8

Conversation

@justinchuby

@justinchuby justinchuby commented Aug 26, 2026

Copy link
Copy Markdown
Member

Summary

  • preserve unsloth/Qwen3.8-Flash-Next-FP8@41cc25fe32cc20053a59c89716196897580cddf6 source FLOAT8E4M3FN codes and BF16 scales byte-for-byte
  • reconstruct strict 128x128 blocks with invertible tile-major standard ONNX QDQ; PLE uses its pinned BF16 scalar (0x3951)
  • retain float32 router computation, cast probabilities to model dtype immediately before constant-size com.microsoft.MoE, and assemble packed rank-3 expert banks from independently scaled QDQ projections
  • keep PLE source shards separate; scalar-dequantize and Gather one shard at a time under an explicit dependency chain, avoiding a full-table destination or simultaneous dense shards
  • keep dense reconstruction only behind explicit --dequantize / keep_quantized=False, with BF16-first semantics
  • preserve parent-only quantization_config through text-only config parsing, then strip all multimodal fields before graph construction
  • fail closed on revision drift, malformed shapes/grids, missing/orphan/duplicate/unclassified tensors, changed deterministic buffers, and ambiguous mappings
  • keep loading and saving transactional; stream shards lazily, force one serializer worker, and report source/cast/reconstruction/runtime overlap truthfully
  • report storage fidelity separately from runtime capability: storage_preserving=true, native_fp8=false, runtime_execution_proven=false
  • explicitly exclude 3,101 MTP and 333 visual tensors from this FP8 text route

Base integration

Based directly on current main, preserving merged truthful GGUF reports, compressed routes, runtime capabilities, Qwen4Exp GGUF/multimodal behavior, and tokenizer evidence. The main-relative diff is FP8-QDQ-only.

Validation

  • final blocker-focused suite: 142 passed
  • complete rebased FP8/compressed/multimodal suite: 304 passed, 13 skipped
  • production-dimension Qwen4Exp L2: 9 passed
  • broad serial suite: 8612 passed, 62 skipped, 12 deselected, 4 subtests passed
  • parent/text layout tests prove default QDQ and explicit dense fallback routing without network or weights; multimodal config remains intact when text-only is false
  • QDQ tests prove exact code/scale external bytes, ONNX checker/package roundtrip, tile inversion, packed experts, no dense quantized initializers, bounded stored size, input/output multishard support, and transactional failures
  • fused MoE node count is independent of expert count; BF16 inputs share one T and pinned Transformers numerical parity passes
  • PLE tests prove no full-table Concat, sequential shard dependencies, bounded code+dense+optional-cast peak, and shard-lazy BF16 loading
  • initialized lintrunner formatting/lint: clean
  • independent GPT-5.6 Sol rereview: both HIGH blockers fully fixed; no significant findings

Runtime and scope

Stock ORT may reject FLOAT8 DequantizeLinear(24) because no current kernel is available. This is recorded as a runtime capability gap and does not trigger dense serialization or invalidate the checker-valid storage artifact. Native FP8 compute is not claimed.

Full 185.5 GB payload export and L4/L5 generation are waived; all 131 headers and the complete 152,089-tensor schema were validated without payload download, with independent reduced QDQ/dense and pinned-Transformers parity.

This PR remains text-route only for the FP8 checkpoint. Merged multimodal support supplies the architecture, but visual FP8 loading is not claimed. MTP remains excluded because no authoritative forward equation or NextN cache ABI exists.

@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown

Performance Comparison

Comparing 72280df1e483bf

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.

@github-actions

github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown

🏗️ Architecture Diff

Comparing 72280df1e483bf

Model Sub-model Changes Status
qwen model 0
qwen (static-cache) model 0

No architecture changes detected.


Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed)

@justinchuby
justinchuby force-pushed the justinchuby-integrate-qwen4exp-fp8 branch from 266176a to 6d8c317 Compare August 26, 2026 18:21
@justinchuby
justinchuby changed the base branch from justinchuby-finish-qwen4exp-core to justinchuby-add-qwen4exp-multimodal August 26, 2026 18:22
@justinchuby
justinchuby force-pushed the justinchuby-add-qwen4exp-multimodal branch from a38afdc to 1eeb756 Compare August 26, 2026 18:34
@justinchuby
justinchuby force-pushed the justinchuby-integrate-qwen4exp-fp8 branch from 6d8c317 to 6d23fa1 Compare August 26, 2026 19:02
@justinchuby justinchuby changed the title Integrate pinned Qwen4Exp FP8 checkpoint Preserve pinned Qwen4Exp FP8 checkpoint with QDQ Aug 27, 2026
@justinchuby
justinchuby force-pushed the justinchuby-add-qwen4exp-multimodal branch from 1eeb756 to 822335e Compare August 27, 2026 06:20
Base automatically changed from justinchuby-add-qwen4exp-multimodal to main August 27, 2026 07:52
@justinchuby
justinchuby requested a review from a team August 27, 2026 07:52
justinchuby and others added 17 commits August 27, 2026 01:05
Dequantize strict 128-by-128 inverse-scale grids without materializing expanded scale tensors, while preserving scalar scales.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Stream the immutable Qwen3.8 Flash-Next FP8 checkpoint into a dense ONNX fallback with strict 128x128 scale validation and explicit non-native reporting. Preserve PLE shards as separate graph initializers, classify composite visual and MTP keys, and record header-only schema evidence without downloading the 185.5 GB payload.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Validate every FP8 and inverse-scale header, including ignored MTP tensors, reject orphan scales and revision drift, and persist the dense fallback report with the package. Add preference, sidecar, report round-trip, and immutable revision tests.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Use an independent reduced-matrix reconstruction oracle, support upstream combined PLE tables alongside checkpoint shards, and pass pinned Transformers prefill/decode parity. Account for ONNX IR output-shard buffering by defaulting dense streaming packages to 1 GiB shards, rejecting limits above 5 GB, and reporting the real serialization memory bound.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Apply the pinned shared BF16 scalar to every FP8 PLE shard, validate its exact payload, and report MTP and visual exclusions separately. Reject duplicate safetensors keys, serialize dense fallbacks with one worker, correct QSA RoPE frequency expansion, and add pinned L2/L3/YAML coverage.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Preserve the multimodal registry and config tests while selecting the immutable FP8 text checkpoint for L2 validation. Remove duplicate metadata introduced by the restack and keep the combined core, multimodal, and FP8 surfaces lint-clean.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Require E4M3 PLE shards with the single pinned BF16 scalar, reject per-shard scale bypasses, and use in-place scalar reconstruction. Report the largest simultaneously live source+dense+scale working set so the single-worker serialization bound is accurate.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Restore the defaultdict import required by the inherited GGUF indexer split/fusion path after restacking FP8 on the updated core, GGUF, and multimodal branches.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Reconstruct the pinned per-expert FP8 matrices one projection at a time into the final packed rank-3 graph initializers. Preserve the final core QSA implementation while deduplicating rebased registry and synthetic-parity metadata.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Validate every BF16 PLE graph shard after the FP8 integration changes the shared graph contract from one combined table to checkpoint-native shard initializers.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Select routed token coordinates per expert, run only those token rows through constant-index expert weights, and scatter weighted outputs back. This avoids materializing token-shaped copies of full expert matrices during prefill.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Make storage-preserving standard ONNX QDQ the default for the pinned FP8 checkpoint. Keep exact E4M3 code and BF16 scale initializers, reconstruct block tiles invertibly in-graph, retain dense BF16 reconstruction only behind explicit dequantization, and record runtime capability separately from storage fidelity.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Propagate the Transformers CLI quantization choice, prevalidate complete QDQ source and target closure transactionally, and account for simultaneous source and cast-destination buffers in serialization memory bounds. Strengthen failure regressions with complete graph snapshots.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: e0bfa582-e6d5-4722-b02b-70b18f639ef2

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Assert the persisted single-worker serialization bound incorporates planned source and cast-destination overlap for QDQ packages.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: e0bfa582-e6d5-4722-b02b-70b18f639ef2

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Record the required attribution metadata for the independent review-fix series.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e0bfa582-e6d5-4722-b02b-70b18f639ef2
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Deduplicate build and CLI quantization controls against merged compressed-tensors support, preserve the dedicated FP8 QDQ route ahead of ordinary Qwen loading, and align the inherited BF16 streamer test with sharded PLE graph storage.\n\nCo-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>\nCopilot-Session: e0bfa582-e6d5-4722-b02b-70b18f639ef2

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Queue dense bindings until the complete checkpoint plan validates, and preflight the persisted weight-loading report path before any package artifact is written.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e0bfa582-e6d5-4722-b02b-70b18f639ef2
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
@justinchuby
justinchuby force-pushed the justinchuby-integrate-qwen4exp-fp8 branch from 2c59cd0 to 797a830 Compare August 27, 2026 08:18
Copilot AI lite review requested due to automatic review settings August 27, 2026 08:18

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 adds a storage-preserving FP8 (F8_E4M3 + BF16 scale) import path for the pinned unsloth/Qwen3.8-Flash-Next-FP8@41cc25f… checkpoint by streaming safetensors shards and emitting standard ONNX QDQ to reconstruct logical weights, while keeping dense reconstruction only behind an explicit --dequantize / keep_quantized=False choice.

Changes:

  • Add FP8 streaming weight-loading infrastructure in mobius.integrations._weight_loading with a strict, fail-closed planning contract and a QDQ-preserving path (stream_qdq_safetensors_to_model) plus a dense fallback (stream_preprocessed_safetensors_to_model).
  • Extend Qwen4-Exp text model support to classify FP8 sources (including packed expert banks and PLE scalar scaling) and produce a detailed weight-loading report, with new evidence fixtures and regression tests.
  • Persist weight-loading-report.json in ModelPackage.save()/load() and force serial external-data saving for streaming packages to keep memory bounds predictable.

Reviewed changes

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

Show a summary per file
File Description
tests/synthetic_parity_test.py Adjust synthetic HF-config adaptation for Qwen4-Exp text.
tests/cli_test.py Add CLI test asserting --dequantize toggles keep_quantized.
testdata/evidence/causal-lm/qwen3.8-flash-next-fp8-schema.json New pinned header/schema evidence for the FP8 checkpoint.
testdata/cases/causal-lm/qwen3.8-flash-next-fp8.yaml New (skipped) L4/L5 case documenting the pinned FP8 artifact and waiver.
src/mobius/models/qwen4_exp.py Add FP8 header validation + streaming plan + sharded PLE embedding + routed-expert dispatch changes.
src/mobius/models/qwen4_exp_test.py Add extensive FP8/QDQ/dense-fallback streaming tests and fixture validation.
src/mobius/integrations/transformers/_qwen4_exp_weights_test.py Update streaming loader tests for sharded PLE embedding parameters.
src/mobius/integrations/transformers/_builder.py Enforce pinned revision and route FP8 block-quant configs into QDQ/dense streaming loaders.
src/mobius/integrations/transformers/_builder_test.py Add tests for loader selection and pinned revision enforcement.
src/mobius/integrations/_weight_loading.py Implement streaming plan dataclasses, strict shard indexing, FP8 block dequant, and QDQ graph rewriting.
src/mobius/integrations/_weight_loading_test.py Update generic FP8 dequant tests to fail closed on missing scales; add 2D-grid coverage.
src/mobius/integrations/_weight_loading_stream_test.py Add regression ensuring duplicate tensor keys across shards fail closed.
src/mobius/_registry.py Point qwen4_exp_text test model id/revision to the pinned FP8 checkpoint.
src/mobius/_model_package.py Persist and validate weight-loading-report.json; force serial external-data saving for streaming packages.
src/mobius/_model_package_test.py Add roundtrip + save-policy tests for the weight-loading report behaviors.
src/mobius/_configs/_base.py Add allow_block_fp8_dense_fallback to allow parsing FP8 block schemes for Qwen4Exp.
docs/design/qwen4-exp-text-core.md Document the pinned FP8 checkpoint route, QDQ recipe, and reporting semantics.

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

Comment thread src/mobius/models/qwen4_exp.py Outdated
Comment thread src/mobius/models/qwen4_exp.py
Comment thread src/mobius/models/qwen4_exp.py Outdated
justinchuby and others added 5 commits August 27, 2026 01:34
Parse the composite parent before stripping multimodal fields so its sole quantization_config reaches the Qwen4Exp text route. Cover default QDQ, explicit dense fallback, and unchanged multimodal config derivation without network or weights.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e0bfa582-e6d5-4722-b02b-70b18f639ef2
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Inherit parent-only quantization metadata before stripping text-only multimodal fields. Replace per-expert and per-shard runtime expansion with constant-size fused MoE and one logical PLE gather, and cover both storage and multimodal routing contracts.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e0bfa582-e6d5-4722-b02b-70b18f639ef2
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Cast float32 routing probabilities to the model dtype before fused MoE, keeping graph size expert-count independent. Restore per-shard PLE lookup and serialize shard dequantization with explicit dependencies so only one dense shard is live at a time.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e0bfa582-e6d5-4722-b02b-70b18f639ef2
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Describe the implemented full-shard DQ then Gather order and its code, dense, scale, and optional-cast peak. Gate full BF16 QDQ model load and inference only on an independent exact DequantizeLinear capability probe.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e0bfa582-e6d5-4722-b02b-70b18f639ef2
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Skip BF16 FP8 QDQ validation only for ORT's exact NotImplemented class and canonical DequantizeLinear(24) missing-kernel signature. Re-raise matching ValueError text, near matches, wrong op versions, and subclasses.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e0bfa582-e6d5-4722-b02b-70b18f639ef2
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
@justinchuby
justinchuby merged commit af3328f into main Aug 27, 2026
20 of 25 checks passed
@justinchuby
justinchuby deleted the justinchuby-integrate-qwen4exp-fp8 branch August 27, 2026 09:29
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