Skip to content

Support Qwen3.8 compressed NVFP4 checkpoints - #654

Merged
justinchuby merged 7 commits into
mainfrom
justinchuby-support-qwen3-8-nvfp4
Aug 27, 2026
Merged

justinchuby merged 7 commits into
mainfrom
justinchuby-support-qwen3-8-nvfp4

Conversation

@justinchuby

Copy link
Copy Markdown
Member

Summary

  • parse compressed-tensors 0.17.2 mixed FP8/NVFP4 metadata before graph construction, preserving ordered targets, ignores, and the last-eight-layer FP8 override
  • stream each shard tensor into exact dense reconstruction with strict dtype/shape/qparam guards, then retain lazy transpose/concat folding
  • keep FP8 KV cache disabled by default and require a complete scale map plus an emitted EP-supported GQA FP8 ABI when explicitly enabled
  • add independent packed-code ORT parity, Qwen3.5 VLM package loading, and immutable official/quantized checkpoint evidence

Capability

  • Native preserved FP8/NVFP4 weights: none; current available ORT dense operator schemas do not exactly match this checkpoint ABI
  • Fallback: FP8 weights reconstruct as q * channel_scale; NVFP4 weights reconstruct as E2M1(code) * E4M3(block_scale) / stored_global_scale, emitted as dense floating-point weights. The package report and warning explicitly state that output is no longer NVFP4 and dynamic activation quantization is not represented.
  • KV cache: float by default. FP8 is opt-in only through the existing EP-gated GQA feature with every checkpoint k_scale/v_scale supplied.

Immutable evidence

  • official base: Qwen/Qwen3.8-27B@1d4bf0f2ff6012fd82039f2fa52739d0dd7c60c0
  • quantized derivative: unsloth/Qwen3.8-27B-NVFP4@9e3d73c76eddb75f795cc24ccfbc5affe41c66bd
  • derivative index total: 23,417,592,488 bytes; representative safetensors header offsets/dtypes/shapes and LFS identity are pinned in tests

Validation

  • 8371 passed, 57 skipped, 12 deselected in the broad serial suite
  • targeted compressed-tensors, Qwen3.5, adjacent quantization, FP8 KV-cache, and ORT numerical tests pass
  • lintrunner f --output oneline --all-files and lintrunner -a pass
  • three GPT-5.6 Sol medium review rounds completed; all findings fixed

Waivers

  • Full-checkpoint L4/L5 and generation were not run because the task explicitly prohibits downloading the 23.4 GB payload. Reduced independently generated FP8/NVFP4 matrices execute in ORT with exact parity, and the full immutable config/index/header schema is pinned without payload artifacts.
  • Native NVFP4 preservation is unavailable because no actually available ORT dense operator ABI matches the checkpoint layout and dynamic activation contract exactly.

@justinchuby
justinchuby requested review from a team and a lite review from Copilot August 26, 2026 15:42

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

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for loading compressed-tensors (mixed FP8/NVFP4) checkpoints via streaming/lazy reconstruction and routes Transformers builds to use it, including guards for FP8 KV-cache scale requirements.

Changes:

  • Add a new mobius.integrations.compressed_tensors loader that streams/dequantizes supported compressed-tensors checkpoints into ONNX initializers via ir.LazyTensor.
  • Update Transformers builder to detect compressed-tensors configs, validate FP8 KV-cache scale maps, and avoid eager weight downloads.
  • Add extensive tests for the new loader and routing behavior, and attach a quantization_report to ModelPackage.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/mobius/integrations/transformers/_builder.py Detects compressed-tensors configs, validates KV-cache scales, and streams weights into packages.
src/mobius/integrations/transformers/_builder_test.py Adds tests ensuring streaming loader is used and KV-cache scale validation triggers.
src/mobius/integrations/compressed_tensors/_loader.py Implements streamed lazy reconstruction/dequantization and fail-closed validation for compressed-tensors 0.17.2.
src/mobius/integrations/compressed_tensors/_loader_test.py Adds reconstruction, config-resolution, and end-to-end build/load tests for compressed-tensors.
src/mobius/integrations/compressed_tensors/init.py Exposes compressed-tensors public API.
src/mobius/_model_package.py Adds quantization_report field to carry loader reports.
src/mobius/_configs/_quantization.py Rejects compressed-tensors in coarse quantization parsing (fail-closed).
src/mobius/_configs/_base.py Updates Kimi-K3 detection/rejection path for compressed-tensors configs.

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

Comment thread src/mobius/_configs/_base.py Resolved
Comment thread src/mobius/_model_package.py Resolved
@github-actions

github-actions Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

Performance Comparison

Comparing 4ee4580 → a3df09b

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 4ee4580 → a3df09b

Model Sub-model Changes Status
bert (feature-extraction) model 0 ⚪
falcon model 0 ⚪
gemma2 model 0 ⚪
gemma4 (gemma4) decoder 0 ⚪
gemma4 (gemma4) embedding 0 ⚪
gemma4 (gemma4) vision_encoder 0 ⚪
gemma4_text model 0 ⚪
gpt2 model 0 ⚪
llama model 0 ⚪
llama (static-cache) model 0 ⚪
mamba (ssm-text-generation) model 0 ⚪
phi3 model 0 ⚪
phi3 (static-cache) model 0 ⚪
qwen model 0 ⚪
qwen (static-cache) model 0 ⚪
qwen2 model 0 ⚪
qwen2 (static-cache) model 0 ⚪
qwen2_moe model 0 ⚪
qwen2_moe (static-cache) model 0 ⚪
qwen3 model 0 ⚪
qwen3 (static-cache) model 0 ⚪
qwen3_5_moe (hybrid-text-generation) model 0 ⚪
qwen3_5_text (hybrid-text-generation) model 0 ⚪
qwen3_5_vl (hybrid-qwen-vl) decoder 0 ⚪
qwen3_5_vl (hybrid-qwen-vl) embedding 0 ⚪
qwen3_5_vl (hybrid-qwen-vl) vision_encoder 0 ⚪
qwen3_moe model 0 ⚪
qwen3_moe (static-cache) model 0 ⚪
qwen3_next (hybrid-text-generation) model 0 ⚪
t5 (seq2seq) decoder 0 ⚪
t5 (seq2seq) encoder 0 ⚪
whisper (speech-to-text) decoder 0 ⚪
whisper (speech-to-text) encoder 0 ⚪

No architecture changes detected. ✅


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

justinchuby and others added 7 commits August 26, 2026 22:11
Parse compressed-tensors 0.17.2 mixed FP8/NVFP4 metadata before graph construction so packed E2M1 weights cannot fall into MatMulNBits. Reconstruct supported weights lazily into dense float tensors with strict target, layout, dtype, shape, and KV-cache scale validation while reporting the loss of native quantization semantics. Add pinned checkpoint header evidence, reduced ORT parity, and Qwen3.5 VLM streaming load coverage.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Make target replacement and version handling match compressed-tensors exactly, reject unsupported output quantization, report only emitted FP8 KV-cache support, and preserve lazy post-weight transpose/concat folding. Pin the official Qwen3.8 base config alongside the quantized derivative evidence.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Preserve declared target precedence, batch safetensors reads per logical tensor, normalize compressed-tensors config representations, and document the transient quantization report contract. Add focused regressions for each behavior.

Co-authored-by: Copilot App <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Emit Microsoft's native W4A16/W8A16 block-weight operators from compressed-tensors checkpoints, register an inlineable standard-ONNX NVFP4 fallback, and retain exact packed codes and scales through serialization. Keep dense reconstruction behind the explicit dequantize policy and persist the source quantization recipe and runtime caveats.

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

Copilot-Session: acdf6027-4e8f-40aa-8600-abc9ee8591a4
Signed-off-by: Justin Chu <[email protected]>
Route local compressed-tensors directories through the faithful streaming loader for both native and explicit dense policies. Reject E5M2 and FNUZ FP8 payloads from the E4M3FN-only native operator while retaining exact dense E5M2 reconstruction.

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

Copilot-Session: acdf6027-4e8f-40aa-8600-abc9ee8591a4
Signed-off-by: Justin Chu <[email protected]>
Resolve guaranteed compressed-tensors dtypes without touching FNUZ attributes that are absent from minimum-supported PyTorch versions. Register optional FNUZ dtypes only when available and preserve explicit fail-closed errors otherwise.

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

Copilot-Session: acdf6027-4e8f-40aa-8600-abc9ee8591a4
Signed-off-by: Justin Chu <[email protected]>
Require the PyTorch release baseline selected for compressed FP8/FNUZ support, remove the obsolete legacy-attribute compatibility shim, and update the recorded dependency lower bound.

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

Copilot-Session: acdf6027-4e8f-40aa-8600-abc9ee8591a4
Signed-off-by: Justin Chu <[email protected]>
@justinchuby
justinchuby force-pushed the justinchuby-support-qwen3-8-nvfp4 branch from 06b10cc to a3df09b Compare August 27, 2026 05:13
@justinchuby
justinchuby merged commit ba64bfe into main Aug 27, 2026
22 of 25 checks passed
@justinchuby
justinchuby deleted the justinchuby-support-qwen3-8-nvfp4 branch August 27, 2026 05:16
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