Skip to content

[quantization] quantize / dequantize through load operations - #50386

Open
ArthurZucker wants to merge 60 commits into
mixed-nvfp4-fp8-planfrom
quantize-dequantize-load-ops
Open

ArthurZucker wants to merge 60 commits into
mixed-nvfp4-fp8-planfrom
quantize-dequantize-load-ops

Conversation

@ArthurZucker

@ArthurZucker ArthurZucker commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

🤗 Transformers CI

Stacked on #50245. quantize and dequantize become load operations set per param by the plan, replacing quantization_operation and the post-load dequantize() (from #50240).

…ad op, uncompressed checkpoints no longer force it
… the checkpoint format; drop no-op after-load hook
…hts load decompressed, compressed-tensors only sets up activation / kv cache quantization
…ad op, uncompressed checkpoints no longer force it
… the checkpoint format; drop no-op after-load hook
…hts load decompressed, compressed-tensors only sets up activation / kv cache quantization
Replaces WeightTransform.quantization_operation: the op is appended last to each param's converter.
…converters of modules keeping their packed tensors
…buffer kept; serialize visits every module; gptq/awq/auto_round/quark dequantize moved to a follow-up
…vfp4 loads pre-quantized checkpoints with dequantize=True
ArthurZucker and others added 22 commits November 4, 2026 09:40
…tized_module` (#50343)

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

* [quantization] build_fp8_linear / build_fp8_experts
…nd saves it back; dequantize=True is plain dense
…-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
…h; bnb docs: dequantize keeps the quantized values
…kip kernel checks when dequantizing; eetq says why it can't
# Conflicts:
#	src/transformers/quantizers/quantizer_eetq.py
… experts) through the plan (#50376)

* [quantization plan] load ModelOpt per-layer configs through the plan

* [quantization plan] dequantized patterns stay as None so a broader pattern can't claim them

* [nvfp4] load ModelOpt NVFP4 checkpoints, with their static input_scale

* [loading] quantized companions can be buffers; Concatenate stacks tensors that lack the dim (per-expert scales)

* [fp8] load ModelOpt FP8 checkpoints, weight-only FP8 for FP8_PB_WO

* [quantization plan] FP8_PB_WO expects the weight-only FP8 config

* [nvfp4] NVFP4Experts: keep ModelOpt NVFP4 experts packed instead of loading them dense

* [mxfp4] generic MXFP4 experts; DeepSeek-V4 fp4 experts load via a plan

* [quantization plan] a single user config brings only its loading attributes to a saved plan

* [nvfp4] NVFP4Experts: load through the model's merge converters, grouped NVFP4 forward

* [quantization plan] the plan alone says what is quantized; keep renamings appended after general converters

* [quantization plan] default skips except modules the plan names; NVFP4 experts eager outside sm90/sm100

* [quantization plan] each model converter is updated by the quantizer owning its target only

* [quantization plan] the general weight converter first, so an own-name one can't take shared experts

* [mxfp4] Mxfp4Deserialize passes through tensors not in GPT-OSS's blocks layout

* [fp8] dequantize=True dequantizes FP8 embeddings too, like every other quantized module

* [quantization plan] the plan scopes a quantizer's renamings to its own params: plain suffix renames, no module lists

* [fp8] inline the experts weight format; ModelOpt names are plain renames in both modes, no dequantize-side renaming

* [quantization plan] one matching rule for every pattern; [fp8] Fp8Deserialize reshapes and casts at load instead of after it

* [quantization plan] match each module once with the dtype plan's globs; no after-load hooks for fp8/mxfp4 (DeepGEMM's device guard is in its dispatch)

* [tests] trim the quantization plan, NVFP4 and FP8 ModelOpt tests

* [quantization plan] a converted plan is written to the config in the model's names only, so the config can be reused

* [quantization plan] converter owners from the module map; NVFP4 buffers take ModelOpt's names, no renames

* [quantization] a dequantized model saves unquantized: FP8 and NVFP4 dequantize reverse to identity

* [quantization plan] core loading routes each key to its layer's quantizer conversions; no owners, chaining or applies_to

* [quantization plan] each converter updated by its owner only, quantizer renames scoped to its layers and appended to the model's; core loading unchanged

* [quantization plan] scoped renamings also cover a layer's submodules (per-expert tensors)

* [quantization plan] renamings first, then the converters of the key's layer quantizer: no owners, no merged general converters

* [quantization] converters only copy per serialized name; update_weight_transform sets every op per param

* [docs] core model loading design principles: the load path, quantization plans and tensor parallelism

* [quantization plan] per-quantizer conversions on its layers, plan takes the union; core back to main

* [docs] core model loading: one example walked through

* [quantization plan] chain the quantizers' conversions, no dedupe

* [quantization plan] fold rename_patterns into match_modules

* [quantization] every quantized load goes through the plan: it builds the conversions and ops, quantizers only describe formats

* Delete docs/source/en/core_model_loading_design_principles.md

* [quantization plan] single quantizer keeps its isinstance; general converters only when the mode has an op

* [docs] drop the deleted page from the toctree

* [quantization plan] simpler per-param lookup; renamings on the layers holding a param of the format
…rd as methods, FP8/MXFP4 module builders inlined
… set per param by the plan; no quantization code left in core
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

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

run-slow: bitnet_integration, bnb, fbgemm_fp8, finegrained_fp8, higgs, hqq, metal, mxfp4, nvfp4, sinq

@HuggingFaceDocBuilderDev

HuggingFaceDocBuilderDev commented Nov 5, 2026 •

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:

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.

2 participants