Skip to content

[quantization] per-layer quantization plan: mixed NVFP4 + FP8 checkpoints - #50245

Open
ArthurZucker wants to merge 11 commits into
compressed-tensors-dequantize-on-loadfrom
mixed-nvfp4-fp8-plan
Open

ArthurZucker wants to merge 11 commits into
compressed-tensors-dequantize-on-loadfrom
mixed-nvfp4-fp8-plan

Conversation

@ArthurZucker

@ArthurZucker ArthurZucker commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

🤗 Transformers CI

A quantization plan, quantization_config={glob: config} with the dtype plan's matching, loads each layer through its own quantizer; pre-quantized NVFP4 loads through a deserialize op. Tested on hf-internal-testing/tiny-random-Mistral4-fp8-nvfp4 (fp8 attention + experts, nvfp4 shared experts).

Supersedes #49818 and #49658 (mixing quantization methods per module); overlaps #49779 and #49851 for pre-quantized NVFP4.
Related issues: #38253, #48371, #44292, #46772. Needs huggingface/kernels-community#1291 for fp8 experts.

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Pages changed in this PR:

quantizer.preprocess_model(model, **kwargs)

def is_serializable(self):
return all(quantizer.is_serializable() for quantizer in self.quantizers.values())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the serialization interface be made consistent with NVFP4? NVFP4HfQuantizer.is_serializable is a property returning a boolean, so this call raises TypeError: bool object is not callable for the advertised mixed plan. A save attempt should produce the intended support decision instead.

self.quantization_config = {
pattern: quantizer.quantization_config for pattern, quantizer in quantizers.items()
}
self.pre_quantized = all(quantizer.pre_quantized for quantizer in quantizers.values())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could fully dequantized plans be cleaned up during postprocessing? The inherited postprocessor checks quantization_config.dequantize, but this config is a dictionary, so an all-dequantized model retains its pre-quantized recipe and quantizer. Please add a dense save/reload round trip, including removal of dequantized plan entries.

max_memory = quantizer.adjust_max_memory(max_memory)
return max_memory

def preprocess_model(self, model, **kwargs):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the plan also delegate each child's post-load hook? It delegates preprocessing but inherits the base postprocessor, so FP8's _disable_deepgemm_on_multi_device() never runs for a mixed plan. A multi-device FP8 plan can therefore keep a backend that the standalone quantizer explicitly disables as unsafe.

@ArthurZucker
ArthurZucker force-pushed the compressed-tensors-dequantize-on-load branch from bc6733c to 7cf9e8a Compare November 4, 2026 08:40
ArthurZucker and others added 3 commits November 4, 2026 10:24
…tized_module` (#50343)

* [quantization] swap modules in one pass through a per-quantizer quantized_module

* [quantization] build_fp8_linear / build_fp8_experts
…-load' into HEAD

# Conflicts:
#	src/transformers/quantizers/quantizer_compressed_tensors.py
#	tests/quantization/compressed_tensors_integration/test_compressed_models.py
…ch transform's ops; fp8 declares fused experts
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: ministral3, mistral4, aqlm_integration, bitnet_integration, eetq_integration, finegrained_fp8, higgs, metal, nvfp4, sinq

This branch has not been deployed

No deployments
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.

3 participants