Repository navigation
[Pipelines] Support compressed-tensors NVFP4 checkpoints - #6773
Open
lightofbaldr wants to merge 1 commit into
Open
lightofbaldr wants to merge 1 commit into
lightofbaldr wants to merge 1 commit into
Conversation
BEGIN_PUBLIC [Pipelines] Support compressed-tensors NVFP4 checkpoints MAX's FP4 config parser only recognized the modelopt NVFP4 flavor, so compressed-tensors NVFP4 checkpoints (e.g. RedHatAI/Llama-3.1-8B-Instruct-NVFP4) failed to load: the graph expected packed uint8 weights while the checkpoint's BF16-preserved lm_head shipped as bfloat16, and the global scales use the reciprocal of MAX's multiplicative dequant convention. Add a shared compressed-tensors normalization helper (weight suffix renames, one-time global-scale reciprocation keyed on the raw suffix so it stays idempotent, and optional uint8->e4m3 per-group scale reinterpretation), and teach the FP4 parser to translate a compressed-tensors target scope into the existing per-layer modelopt QuantConfig representation: each MLP/attention subtree is quantized all-or-nothing (partial selection raises), and an unquantized lm_head is excluded independently so it stays bf16. The laguna architecture now shares this helper instead of mutating the HF quantization config in place. Fixes modular#6600. END_PUBLIC Signed-off-by: Adam Kruger <[email protected]>
lightofbaldr
force-pushed
the
clean/nvfp4-dispatch-sm121
branch
from
July 14, 2026 17:46
f9290f8 to
d75b756
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MAX's FP4 config parser only recognizes the modelopt NVFP4 flavor, so
compressed-tensors NVFP4 checkpoints (e.g.
RedHatAI/Llama-3.1-8B-Instruct-NVFP4)fail to load. This adds a compressed-tensors NVFP4 load path.
Two independent problems block serving these checkpoints on a DGX Spark:
bf16 lm-head — and its global scales are stored as the reciprocal of MAX's
multiplicative dequant convention. MAX doesn't recognize the compressed-tensors
schema, so the graph expects packed
uint8where the checkpoint shipsbfloat16.activation scales must be emitted rank-5.
What it does
weights/_compressed_tensors.pyhelper: compressed-tensors NVFP4 schemarecognition; weight-suffix renames; one-time global-scale reciprocation keyed on the
raw suffix (so it is idempotent); optional
uint8→e4m3per-group scale reinterpret.weights/quant.py: recognizesquant_method == "compressed-tensors"and translates itstargets/ignorescope into MAX's existing per-layer modeloptQuantConfigrepresentation, then reuses the modelopt builder. Each MLP/attention subtree is
quantized all-or-nothing (partial selection raises
ValueError); an unquantizedlm_headis excluded independently so it staysbf16.architectures/llama3/weight_adapters.pyapplies the helper; thelagunaarchitecturenow shares it instead of mutating the HF quantization config in place.
Validation
Unit tests (
//max/tests/tests/pipelines:...)test_parse_quant_config: 35 passedtest_llama3_weight_adapters: 5 passedCoverage: global-scale reciprocation, idempotency (canonical scale not re-inverted),
uint8→e4m3reinterpret,Linear-targets, regex/MoE targets, all-or-nothing subtreerejection, non-NVFP4 compressed-tensors fall-through, and a graph-level assertion that
lm_head.weightis built asbfloat16.Hardware — DGX Spark (GB10, sm_121a),
RedHatAI/Llama-3.1-8B-Instruct-NVFP4, identical commandThe failure moving A→B→C shows what each fix contributes: pre-fix, MAX can't load a
mixed-precision compressed-tensors checkpoint; this fix clears that, and the very next
thing to break is the sm_12x NVFP4 math; with #91570 underneath, the math is right and
the model serves. Neither fix alone serves a RedHat/compressed-tensors NVFP4 model on a
DGX Spark; both together do. (Including the three-way trace so a reviewer on consumer
Blackwell who lands on B doesn't conclude the change is broken.)
Fixes #6600.