Repository navigation
GRPO autocast test: let the unlatched packing probe run without autocast - #18369
Merged
Merged
Conversation
#18335 added _unsloth_grpo_packing_leaks, which reads getattr(self, "_autocast_enabled", False). It can run before the autocast latch on the loss path, and there no autocast is the safe answer: True would autocast in the bfloat16 fallback dtype, which raises on a T4 or V100. test_reading_it_tolerates_an_older_trainer required True at every read and fails on main. Scan the scoring sites without the probe, and pin the probe's own False default in a separate test.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
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.
Summary
tests/test_grpo_autocast_disabled.py::test_reading_it_tolerates_an_older_trainerfails on main since #18335:Seen in the CPU "rest" shard on the staging run for #17742.
Cause
The test requires every
getattr(self, "_autocast_enabled", ...)inrl_replacements.pyto default toTrue. On a trainer built before the autocast latch existed, that keeps the scoring forwards autocasting as they always did.#18335 added
_unsloth_grpo_packing_leaks, a one-off probe that checks whether packed documents can see each other. It readsgetattr(self, "_autocast_enabled", False), andFalseis the right default there. The probe runs from_unsloth_grpo_refuse_boundary_blind_packingon the loss path as well, where the latch may not have run yet (for example under vLLM). Unlatched,Truewould autocast in thebfloat16fallback dtype. As_unsloth_grpo_autocastitself notes, reading the precision as bfloat16 raises on a T4 or V100. Running the probe in the model's own dtype is the safe choice, and once the latch exists the probe follows it.So the code is correct and the test rule was broader than its intent.
Fix
Test-only:
test_reading_it_tolerates_an_older_trainerscansrl_replacements.pywith the probe's function body removed. It now also asserts that it found scoring call sites, so it cannot pass on an empty match.test_an_unlatched_probe_runs_without_autocastpins the probe'sFalsedefault, so neither side of the rule can drift silently.Verification
rl_replacements.pyFalsetest_reading_it_tolerates_an_older_trainerfailsTruetest_an_unlatched_probe_runs_without_autocastfailsruff is clean.