Skip to content

GRPO autocast test: let the unlatched packing probe run without autocast - #18369

Merged
danielhanchen merged 1 commit into
mainfrom
ci/grpo-autocast-test-spare-packing-probe
Nov 18, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci/grpo-autocast-test-spare-packing-probe

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

tests/test_grpo_autocast_disabled.py::test_reading_it_tolerates_an_older_trainer fails on main since #18335:

AssertionError: getattr(self, "_autocast_enabled", False)

Seen in the CPU "rest" shard on the staging run for #17742.

Cause

The test requires every getattr(self, "_autocast_enabled", ...) in rl_replacements.py to default to True. 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 reads getattr(self, "_autocast_enabled", False), and False is the right default there. The probe runs from _unsloth_grpo_refuse_boundary_blind_packing on the loss path as well, where the latch may not have run yet (for example under vLLM). Unlatched, True would autocast in the bfloat16 fallback dtype. As _unsloth_grpo_autocast itself 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_trainer scans rl_replacements.py with the probe's function body removed. It now also asserts that it found scoring call sites, so it cannot pass on an empty match.
  • A new test_an_unlatched_probe_runs_without_autocast pins the probe's False default, so neither side of the rule can drift silently.

Verification

Change to rl_replacements.py Result
none (main) 18 passed (before: 1 failed)
a scoring site switched to False test_reading_it_tolerates_an_older_trainer fails
the probe switched to True test_an_unlatched_probe_runs_without_autocast fails

ruff is clean.

#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.
@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T17:26:52.001328Z e0d5af0 Manual request
ℹ️ 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.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: e0d5af0c9a

ℹ️ 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".

@danielhanchen
danielhanchen merged commit 5fd1c74 into main Nov 18, 2026
@danielhanchen
danielhanchen deleted the ci/grpo-autocast-test-spare-packing-probe branch November 18, 2026 17:28
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.

1 participant