Raise on quantization_config + already-instantiated model in DPOTrainer/ KTOTrainer#6312
Merged
Merged
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 80a6dab06d
ℹ️ 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".
|
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. |
quantization_config + already-instantiated model in DPOTrainerquantization_config + already-instantiated model in DPOTrainer/ KTOTrainer
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.
DPOTraineraccepts aquantization_configargument that is only meaningful when the model is loaded from a model identifier (str). That's the only point wherefrom_pretrainedruns and can apply it. When the policy is passed already instantiated, the config can't be applied to it, and the trainer only logged a warning saying it would be ignored.But the warning didn't tell the whole story. The reference model is auto-created from
self.model.configviafrom_pretrained, and that path did injectquantization_config. So in this scenario you silently ended up with:Reproducer (previous behavior)
What this PR does
Turn the silent, misleading warning into a hard error: passing
quantization_configwith an already-instantiated model is a contradiction, so reject it up front.Note
Low Risk
Small validation change at trainer init; may break callers who relied on the old warn-and-continue behavior, but prevents incorrect mixed-precision DPO/KTO runs.
Overview
DPOTrainer and KTOTrainer now fail at construction with a
ValueErrorif you passquantization_configwhilemodelis already a loadedPreTrainedModel, instead of only logging that the config will be ignored on the policy.That closes a footgun where the warning suggested quantization was fully ignored, but the auto-loaded reference model could still be created with
quantization_config, leaving policy full-precision and reference 4/8-bit. The error tells callers to pass a model id string (so both loads can quantize consistently) or dropquantization_config.Reviewed by Cursor Bugbot for commit 012735f. Bugbot is set up for automated code reviews on this repo. Configure here.