Skip to content

Save dequantized models without the quantizer's weight conversions - #50271

Merged
ydshieh merged 8 commits into
mainfrom
mxfp4-dequantized-save
Nov 20, 2026
Merged

ydshieh merged 8 commits into
mainfrom
mxfp4-dequantized-save

Conversation

@qgallouedec

@qgallouedec qgallouedec commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Fixes #50270

A model loaded with dequantize=True drops its quantization config but keeps the quantizer's weight conversions, which save_pretrained reverses. MXFP4 then saves the bf16 experts under *_blocks, and FP8 saves re-quantized weights with no quantization_config, so neither reloads correctly. remove_quantization_config now also drops the conversions the model was loaded with, so a dequantized model saves like an unquantized one, with the conversions of its class. #49774 adds an opt-in hook for this; here it holds for every quantizer.

Tested on H100: the repro from #50270 and an FP8 Mistral3 checkpoint now reload to identical logits (the FP8 one was off by up to 1600). Both new tests fail without the fix.

Who can review?

@SunMarc @MekkCyber @IlyasMoutawwakil

@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.

@qgallouedec qgallouedec changed the title Save dequantized MXFP4 experts under their own names Save dequantized models without the quantizer's weight conversions Nov 2, 2026
Comment thread src/transformers/quantizers/base.py Resolved
if hasattr(model, "quantization_method"):
del model.quantization_method
if hasattr(model, "_weight_conversions"):
del model._weight_conversions

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

are these only the quantizer's weight conversions ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will work in most cases but not for models that we load with transformers format but have weight conversions for the original format. We try to tackle this in #49774.

However, maybe as a temporary fix, I don't mind having this as right now as support for the original format is much more important.

@SunMarc SunMarc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks a lot ! Maybe @ArthurZucker have some feedback on this as it concerns weight conversion.

if hasattr(model, "quantization_method"):
del model.quantization_method
if hasattr(model, "_weight_conversions"):
del model._weight_conversions

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will work in most cases but not for models that we load with transformers format but have weight conversions for the original format. We try to tackle this in #49774.

However, maybe as a temporary fix, I don't mind having this as right now as support for the original format is much more important.

@SunMarc
SunMarc requested a review from ArthurZucker November 3, 2026 13:50
@qgallouedec

Copy link
Copy Markdown
Member Author

This will work in most cases but not for models that we load with transformers format but have weight conversions for the original format. We try to tackle this in #49774.

However, maybe as a temporary fix, I don't mind having this as right now as support for the original format is much more important.

Thanks, agreed: #49774 covers that case, and this is the stop-gap until it lands. @ArthurZucker fine to merge it as such?

@ArthurZucker ArthurZucker left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Agree with @SunMarc

@github-actions

Copy link
Copy Markdown
Contributor

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

run-slow: finegrained_fp8, mxfp4

@qgallouedec
qgallouedec added this pull request to the merge queue Nov 19, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 19, 2026
@qgallouedec
qgallouedec added this pull request to the merge queue Nov 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 20, 2026
@qgallouedec
qgallouedec added this pull request to the merge queue Nov 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Nov 20, 2026
@qgallouedec
qgallouedec added this pull request to the merge queue Nov 20, 2026
@ydshieh
ydshieh removed this pull request from the merge queue due to a manual request Nov 20, 2026
@ydshieh
ydshieh merged commit 106b40c into main Nov 20, 2026
123 of 124 checks passed
@ydshieh
ydshieh deleted the mxfp4-dequantized-save branch November 20, 2026 19:23
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.

Saving a gpt-oss loaded with Mxfp4Config(dequantize=True) loses the experts

6 participants