Skip to content

TRL discovery shim: check AsyncGRPOTrainer as patched in place (Core latest red on TRL 1.18) - #18088

Merged
danielhanchen merged 1 commit into
mainfrom
ci-trl118-async-grpo-shim
Nov 17, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
ci-trl118-async-grpo-shim

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Core (HF=latest + TRL=latest) fails on main now that CI installs TRL 1.18.0 (seen on the staging run for #18082, on 8c99caf36c):

tests/_trl_trainer_discovery_shim.py::test_unsloth_patches_every_canonical_trainer_in_this_trl_version
AssertionError: unsloth.models.rl.patch_trl_rl_trainers did NOT patch: async_grpo_trainer:AsyncGRPOTrainer

TRL 1.18 moved AsyncGRPOTrainer into trl.trainer.async_grpo_trainer. #18070 handles that on purpose: patch_trl_rl_trainers skips async_grpo_trainer, and patch_trl_async_grpo patches the class in place, because it needs TRL's own module globals (create_model_from_path, the lm_head helpers). The class keeps its name. The discovery shim in consolidated-tests-ci.yml counts a trainer as patched only if its class name starts with Unsloth, and it did not know about that exclusion.

#18070 is right. The shim did not follow it.

Change

In the shim embedded in .github/workflows/consolidated-tests-ci.yml:

  • PATCHED_IN_PLACE = {"async_grpo_trainer"} mirrors the exclusion in patch_trl_rl_trainers, and the canonical-trainer test leaves those modules out of its renamed-class check.
  • New test_trainers_patched_in_place_are_wrapped: where TRL ships one of those modules, it runs patch_trl_async_grpo() and checks that each *Trainer class's __init__ has a layer whose code is in unsloth/models/rl.py, following the __wrapped__ chain since other Unsloth patches wrap on top. On TRL versions without the module it skips. So the trainer is still checked, only in the way it is actually patched.

Verification

The shim extracted from the workflow and run locally:

  • TRL 1.18.0: main's shim fails as in CI (1 failed, 4 passed); this one passes (6 passed).
  • TRL 1.18.0 with patch_trl_async_grpo made a no-op: the new test fails (__init__ has no layer from Unsloth's in-place patch ...: [unsloth/trainer.py, trl/trainer/async_grpo_trainer.py]).
  • TRL 1.15.0: 5 passed, 1 skipped (no trl.trainer.async_grpo_trainer).

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 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-17T06:02:12.655061Z 7d15b50 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. Nice work!

Reviewed commit: 7d15b503dd

ℹ️ 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 a5e9c2c into main Nov 17, 2026
@danielhanchen
danielhanchen deleted the ci-trl118-async-grpo-shim branch November 17, 2026 06:10
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