Skip to content

Load MXFP4 and FP8 checkpoints dequantized by default - #8070

Merged
qgallouedec merged 13 commits into
mainfrom
quantized-model-default
Nov 4, 2026
Merged

qgallouedec merged 13 commits into
mainfrom
quantized-model-default

Conversation

@qgallouedec

@qgallouedec qgallouedec commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

With kernels installed, any trainer given openai/gpt-oss-20b by name refuses to train: transformers rejects full fine-tuning of a quantized model, and PEFT finds nothing to adapt in the packed MXFP4 experts. Neither MXFP4 nor FP8 weights train in place, so create_model_from_path now loads these checkpoints dequantized. A quantization_config in model_init_kwargs still wins.


Note

Medium Risk
Changes default model loading for all trainers using create_model_from_path, increasing memory for pre-quantized IDs but fixing training failures; callers can still override with quantization_config.

Overview
Hub checkpoints shipped as MXFP4 or FP8 (e.g. gpt-oss, Mistral Medium) cannot be fine-tuned in their quantized form. create_model_from_path now reads the config first, detects quant_method, and unless the caller passes quantization_config, injects Mxfp4Config(dequantize=True) or FineGrainedFP8Config(dequantize=True) so trainers get trainable full-precision weights for full fine-tuning and PEFT. FP8 dequantization raises a clear error on transformers < 5.0.0.

The early config load also aligns revision with weight loading and removes a duplicate AutoConfig.from_pretrained when inferring architecture. PEFT docs describe this behavior, memory tradeoffs, and setting dtype via SFTConfig(model_init_kwargs=...).

Test fixes: CI revision overrides apply when revision is missing or explicitly None (not when a non-None revision is set). A new test_dequantizes_fp8_checkpoint asserts FP8 tiny models load with float32 weights on transformers ≥ 5.0.0.

Reviewed by Cursor Bugbot for commit 9188b21. Bugbot is set up for automated code reviews on this repo. Configure here.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T13:53:48.694325Z 7409a9f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7409a9f897

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread trl/trainer/utils.py
Comment on lines +1330 to +1332
config = AutoConfig.from_pretrained(
model_id, revision=kwargs.get("revision"), trust_remote_code=kwargs.get("trust_remote_code", False)
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Forward repository lookup options to the config load

When callers use repository-resolution options such as subfolder, local_files_only, or an explicit token, this new preliminary lookup ignores them and may fail or load the wrong root config before architecture.from_pretrained() receives the valid arguments. This also regresses calls with an explicit architecture, which previously did not perform a separate config lookup; pass the applicable Hub/config-loading kwargs through to AutoConfig.from_pretrained.

Useful? React with 👍 / 👎.

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.

The default path (no architecture) already ignored these before this PR. Only revision matters now that the config decides dequantization; see the Bugbot thread.

@bot-ci-comment

bot-ci-comment Bot commented Nov 2, 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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9361804. Configure here.

Comment thread trl/trainer/utils.py Resolved
Comment thread trl/trainer/utils.py Resolved

@albertvillanova albertvillanova 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! The config now follows revision; refs/pr/5 of the tiny gpt-oss loads as MXFP4.

  • The conflict comes from #8085 deleting examples/sft_gpt_oss/sft_gpt_oss.py: dropping that change resolves it.
  • Nit: revision=kwargs.get("revision") also works, since None falls back to main (4.56.2 too).

@qgallouedec

Copy link
Copy Markdown
Member Author

Applied in 9188b21. The test fixture that pins revisions only injected one when revision was absent, so the explicit None loaded the tiny gpt-oss config from main in #8058; it now also pins when revision is None.

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