Skip to content

Make the one scored completion GRPO test follow the TRL version - #14775

Merged
danielhanchen merged 4 commits into
mainfrom
fix-grpo-sample-weight-test-trl16
Oct 27, 2026
Merged

danielhanchen merged 4 commits into
mainfrom
fix-grpo-sample-weight-test-trl16

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

tests/test_grpo_sample_weight.py::test_group_with_one_scored_completion_is_kept
fails on TRL older than 1.6 (the supported floor is 0.22.2) although the code it
tests is right there.

_unsloth_grpo_sample_weight keys on _unsloth_trl_masks_unscorable(), which is true
from TRL 1.6.0. From 1.6, a completion no reward function scored is left out of its
group's statistics, so a group with one scored completion has no variance to test
and is kept. Before 1.6, TRL scores such a completion 0. With sum_then_normalize the
group [1, 0, 0, 0] still has variance and is kept, but with normalize_then_sum each
reward function has a single scored value in the group, its z-score is NaN, the
nansum leaves every reward at 0 and the group has zero variance, so it is excluded.
The test expected "kept" in both modes on every TRL version.

Fix (test only): the expectation for normalize_then_sum now follows the same 1.6.0
switch the code uses. The test runs on the installed TRL and on 1.5.1 and 1.6.0
(set through trl.version, as the neighbouring test already does), so both
behaviours are checked on every CI configuration instead of being skipped.

Checked on TRL 0.25.1: the old test fails with [False, True] != [True, True]; the
new test passes for the installed version and both pinned versions.

test_group_with_one_scored_completion_is_kept expected the group to be kept under
normalize_then_sum on every TRL, which only holds from TRL 1.6, where unscored completions
are left out of the group statistics. Older TRL scores them 0, so after per function
normalisation the group has zero variance and is excluded. Derive the expectation from the
same 1.6.0 switch the code uses and check the installed TRL plus both sides of the switch.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 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-10-27T12:56:10.294791Z a2ee08d 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 9da9c61d39

ℹ️ 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 added a commit that referenced this pull request Oct 22, 2026
pre-commit.ci fails `ruff-format-with-kwargs` on every open PR (#14806,
#14805, #14803, #14790, #14785, #14781, #14780, #14777, #14776, #14775,
#14774, #14773, #14772, #14770, #14769, #14768, and others): "files were
modified by this hook". pre-commit.ci runs the hooks on all files, and
20 files on main (26 by the time this lands) are not in the formatter's
output, so every PR is reformatted outside its own diff. Where
pre-commit.ci can push, its autofix commit drags those unrelated files
into the PR (for example #14790's touches `tests/test_block_compile.py`,
`tests/test_bnb_integration_compile.py` and `unsloth/models/_utils.py`).

The drift came in with PRs merged today, among them #14702, #14751,
#14759, #14784, #14786, #14787, #14788, #14791 and the FP8 block decode,
GRPO routing replay, 4-bit decode, compiled blocks and MoE LoRA target
changes.

### Change

`python scripts/run_ruff_format.py` (the hook's own entry point,
`ruff==0.6.9` as pinned in `.pre-commit-config.yaml`) applied to those
20 files, plus 6 more from #14739, #14779 and #14806, which merged while
this was open. Formatting only.

### Verification

- Every changed file parses to an identical AST before and after.
- A second run of the hook over the same files changes nothing (fixed
point), and over all tracked Python files on this branch it changes
nothing.
- `ruff check` passes on the changed files;
`tests/test_formatter_fixed_point.py` passes (16).

Open PRs pick this up on their next pre-commit.ci run after merging
main.
@danielhanchen danielhanchen self-assigned this Oct 27, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: a2ee08d9e4

ℹ️ 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 cd7850c into main Oct 27, 2026
20 of 21 checks passed
@danielhanchen
danielhanchen deleted the fix-grpo-sample-weight-test-trl16 branch October 27, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant