Skip to content

AsyncGRPOTrainer: patch it at its TRL 1.18 location, and unroll prefix-trie rows for Unsloth's attention (TRL 1.17+) - #18070

Merged
danielhanchen merged 2 commits into
mainfrom
async-grpo-trl118
Nov 17, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
async-grpo-trl118

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

TRL 1.18 (huggingface/trl#8288) moved AsyncGRPOTrainer to trl/trainer/async_grpo_trainer.py. trl/experimental/async_grpo/ is now a deprecated shim that subclasses trl.AsyncGRPOTrainer. patch_trl_async_grpo only imported trl.experimental.async_grpo.async_grpo_trainer and returned when that import failed. On TRL 1.18 it therefore never installed, and three things were lost without any error:

  • the fused LM head wrapper (add_fused_lm_head);
  • the in-process fast_inference vLLM server;
  • the packed-row cross-sequence guard.

This PR also fixes a second problem, which already affects TRL 1.17. Since 1.17, async GRPO folds the samples of each row into a prefix trie: the shared prompt is forwarded once, and each segment attends to its root-to-segment path through TRL's tree_fa3 attention. Unsloth's fast forward ignores the attention implementation TRL sets, and it reads sequence boundaries only from packed_seq_lengths. The trie's position_ids are depths, not restarts at 0, so the guard read the whole row as one sequence (packed_seq_lengths == [29] for a 5-sample row). Each completion then attended to its sibling completions.

Changes

  • _import_trl_async_grpo_module tries trl.trainer.async_grpo_trainer first and falls back to trl.experimental.async_grpo.async_grpo_trainer, so TRL 1.13 to 1.17 resolve exactly as before. The stable class is patched, which also covers the deprecated shim, because the shim subclasses it. The existing sentinel keeps the patch idempotent.
  • patch_trl_rl_trainers skips async_grpo_trainer. On TRL 1.18 it is listed in trl.trainer, so without the skip the generic walk replaces it with a generated UnslothAsyncGRPOTrainer. That copy reads its own module globals, so the in-place async patch would not reach it. TRL 1.18 now gets the same patch path as 1.13 to 1.17.
  • Prefix-trie rows on Unsloth fast backbones (_forward_tree_unrolled) are laid out so that each root-to-leaf path (one per sample) becomes its own packed sequence with its own packed_seq_lengths. Every trie position is then read back from one copy, and each trained position is scored once. The result is exact, but shared prefixes are forwarded once per sample. A row of plain chains (nothing shared) only maps the tree lengths to packed_seq_lengths.
  • Other backbones (compiled, vision, MoE) already run TRL's tree_fa3 attention, so the position_ids self-test, which cannot run that kernel, is skipped for them.

Testing

tests/test_async_grpo_trl_tree.py patches the installed TRL. It uses trl-internal-testing/tiny-Qwen3ForCausalLM on CPU behind a backbone that, like Unsloth's, keeps sequences apart only by packed_seq_lengths. The 5-sample row has two groups, a shared system prefix and two completions that share their first tokens.

TRL main this PR
1.18.0 4 failed: no sentinel, no guard, tree row log-probs and gradients differ from unpacked 26 passed
1.17.1 2 failed: tree row read as one sequence of 29, gradients differ 26 passed
1.15.0 2 passed, 2 skipped (no trie) 24 passed, 2 skipped

The counts in the "this PR" column include tests/test_async_grpo_patch.py. Its fake-TRL fixture now also hides the real trl.trainer.async_grpo_trainer.

GPU correctness on B200 used a real Unsloth FastLanguageModel (tiny Qwen3, LoRA, fp32) with TRL 1.18's TreeRow and fused head. The tree-packed row matches the unpacked per-sample log-probs with max abs diff 0.0. Through TRL's fused head without the unroll, the same row is off by 0.016.

Not covered

  • A full AsyncGRPOTrainer run (vLLM server, weight sync) on TRL 1.18 was not run.
  • The tree_fa3 path for non-fast backbones was not exercised: it needs TRL's FA3/FA4 kernel.
  • TRL 1.14 was not run. The floor tested is 1.15.0.
  • The token budget counts unique trie tokens. On Unsloth fast backbones the forward now covers raw tokens, so a row can be up to the prefix-sharing ratio larger than token_budget suggests.

@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-17T04:11:44.576856Z 0fff343 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. Breezy!

Reviewed commit: 0fff343d2b

ℹ️ 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 8a353eb into main Nov 17, 2026
@danielhanchen
danielhanchen deleted the async-grpo-trl118 branch November 17, 2026 04:39
danielhanchen added a commit to Etherll/unsloth that referenced this pull request Nov 17, 2026
…source lint red since unslothai#18070) (unslothai#18086)

## Summary

`Source lint (Python + shell + YAML + JSON + safety nets)` fails on main
since unslothai#18070 (seen on the staging runs for unslothai#18080 and unslothai#18082, both on
`8c99caf36c`):

```
1 risky loader call site(s) not in the baseline:

  unsloth/models/rl.py:5481  [dynamic-import] import_module
```

unslothai#18070 finds TRL's `AsyncGRPOTrainer` at its 1.18 location as well as
the older experimental one, which needs a second
`importlib.import_module(name)` call site.
`scripts/lint_risky_loaders.py` flags every new dynamic import until
someone reviews it and records it in
`scripts/risky_loaders_baseline.json`, and that entry was not added.

## Review

`name` comes from a fixed tuple of two literal module names,
`trl.trainer.async_grpo_trainer` and
`trl.experimental.async_grpo.async_grpo_trainer`, and each is checked
with `importlib.util.find_spec` first. No user or remote input reaches
it. It is the same kind of site as the other TRL `import_module` entries
already recorded for `rl.py`.

## Change

One entry added to `scripts/risky_loaders_baseline.json`, written by
`python scripts/lint_risky_loaders.py --update` (which marks it `REVIEW
ME`), with the reason filled in. No other entry moves.

## Verification

In a clean `git archive` of main:

- `python scripts/lint_risky_loaders.py` exits 1 on main (the site
above) and exits 0 with this change (`ok: 118 risky loader call site(s),
all recorded`).
- `tests/security/test_lint_risky_loaders.py`: 46 passed.
danielhanchen added a commit to Etherll/unsloth that referenced this pull request Nov 17, 2026
…latest red on TRL 1.18) (unslothai#18088)

## Summary

`Core (HF=latest + TRL=latest)` fails on main now that CI installs TRL
1.18.0 (seen on the staging run for unslothai#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`.
unslothai#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.

unslothai#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 added a commit to Etherll/unsloth that referenced this pull request Nov 17, 2026
…oRA slot per sync (unslothai#18175)

## Summary

unslothai#18070 moved the AsyncGRPOTrainer patch to TRL 1.18's stable module, but
the `fast_inference=True` path (the in-process vLLM server) still cannot
train on TRL 1.18, and on 1.17 it fails as soon as a rollout comes back.
This PR has two commits so the crash fix can ship on its own:

1. **Run on TRL 1.17 / 1.18** (crash fix)
2. **Overwrite one LoRA slot per sync** (removes the per-sync drain
bubble)

## Commit 1: crash fix

Running Qwen3-0.6B LoRA with `fast_inference=True` against TRL 1.18.0
and vLLM 0.29.0 hits four failures in a row. Each one hides the next:

| # | Where | Failure on main | Fix |
|---|-------|-----------------|-----|
| 1 | `rl.py` init wrapper | `AttributeError: 'AsyncGRPOConfig' object
has no attribute 'max_inflight_tasks'`. TRL 1.18 renamed it to
`max_concurrent_rollouts` | Check for the old field. TRL 1.14 to 1.17
keep the `-1` = auto behaviour, and on 1.18 the cap is left to TRL's
`/metrics` control loop |
| 2 | TRL 1.18 rollout worker | The rollout process dials
`localhost:8000`. TRL 1.18 passes the config object itself to
`AsyncRolloutWorker` and pickles it at train start, after the wrapper
has put the user's URL back | Unsloth's `AsyncRolloutWorker` subclass
gets a copy of the config that keeps the in-process server URL.
External-server configs are passed through untouched |
| 3 | vLLM input check | `Requested sample logprobs of 8, which is
greater than max allowed: 0`. Unsloth builds its engine with
`max_logprobs=0`, and TRL 1.17+ score centering (on by default) asks for
8 | Raise `model_config.max_logprobs` in process to what the request
asks for. vLLM only checks this cap when a request is added, and `vllm
serve` allows 20 by default |
| 4 | TRL reading the reply | `KeyError: 'top_logprobs'` at
`async_grpo_trainer.py:1695`. The server returned only `token_logprobs`
| Return `top_logprobs` in the `vllm serve` format: the sampled token
first, then the top k, keyed `token_id:<id>`, with `-inf` clamped to
`-9999.0` |

Also in this commit:
- `GET /metrics` now serves the Prometheus lines TRL parses:
`vllm:cache_config_info{...kv_cache_size_tokens=...}`,
`kv_cache_usage_perc`, `num_requests_running` and
`num_requests_waiting`, read from the in-process scheduler. Before, TRL
warned `vLLM /metrics poll failed` every 5 s and its KV cap stayed at
the fallback.
- `top_k > 0` or `top_p < 1` on TRL 1.17+ is refused at construction
with a clear message. TRL then needs the per-token candidate set
(`--return-sampling-mask --enable-scale-out`, Model Runner V2), which
the in-process engine does not return. On main this failed later, inside
the rollout process, with a 404 on `/version`. TRL 1.14 to 1.16 never
ask for the candidate set, so they keep working as before.
- `/version` is still not served: TRL only reads it for sampling-mask
replay, which is now refused up front.

## Commit 2: drain bubble

Each sync loaded the new adapter under a fresh LoRA id. Unsloth engines
hold `max_loras=1`, and vLLM's scheduler only admits a waiting request
whose adapter fits next to the running ones
(`v1/core/sched/scheduler.py`). So after every sync, all new-version
requests waited until the last straggler of the previous version
finished.

With this commit, every sync reloads the adapter into the same id. It is
a remove and an add, both run on the engine thread between steps,
because Unsloth's LoRA manager skips an id it already holds. All
versions then share one slot and are admitted at once:
- Requests in flight continue on the new weights from their next token
(PipelineRL style). The logprobs they return are still those of the
weights that sampled each token, which is what TRL's importance ratio
and score centering use.
- vLLM keys cached prefix blocks on the adapter name, which the slot
keeps (vllm#42125). So each request carries a per-version `cache_salt`,
and a new version never reuses KV computed by older weights.
- If the reload fails, the previous version is put back, since in-flight
requests still name the slot.
- `UNSLOTH_ASYNC_GRPO_INPLACE_LORA=0` restores a new id per sync.

## Tests

CPU, TRL 1.18.0 (real `AsyncRolloutLoop.generate_one_turn` and
`_init_kv_cap` against the server over HTTP, with a fake engine):

| Tree | `test_async_grpo_*`, `test_rl_config_compat`,
`test_rl_list_train_dataset`, `test_trl_fused_lm_head_*` |
|------|------|
| main + this PR's tests | 10 failed, 113 passed, 1 skipped |
| commit 1 alone | 119 passed, 1 skipped |
| commit 1 code + commit 2's server tests | 4 failed, 20 passed |
| both commits | 123 passed, 1 skipped |

These tests fail on main and pass with this PR:
- `test_trl_118_config_without_max_inflight_tasks`: `AttributeError` on
main.
- `test_trl_118_rollout_worker_keeps_the_in_process_server_url`: main
hands the worker `http://localhost:8000`.
- `test_top_logprobs_are_keyed_by_token_id_as_trl_reads_them`:
`KeyError: 'top_logprobs'` on main. The fake engine also applies vLLM's
`max_logprobs` check.
- `test_trl_rollout_loop_samples_and_sizes_its_kv_cap_from_this_server`:
drives TRL 1.18's own `AsyncRolloutLoop.generate_one_turn` and
`_init_kv_cap`. Main fails at TRL's `async_grpo_trainer.py:1695` with
`KeyError: 'top_logprobs'`. With this PR, TRL sizes its KV cap to 16384
/ 2048 = 8.
- `test_metrics_report_kv_capacity_and_load_in_vllm_format`: `/metrics`
is a 404 on main.
- `test_top_k_and_top_p_refused_when_trl_replays_sampling_masks`: covers
the 1.18 layout (`AsyncRolloutLoop`) and the 1.17 one
(`AsyncRolloutWorker._loop_cls`).

These fail on commit 1 alone and pass once commit 2 is applied:
- `test_a_sync_does_not_stall_new_requests_behind_the_previous_version`:
a fake engine that admits requests the way vLLM does with `max_loras=1`.
On commit 1, the next version's request times out behind the previous
version's straggler.
- `test_syncs_overwrite_one_adapter_slot_and_salt_the_prefix_cache`
- `test_a_failed_slot_reload_puts_the_previous_version_back`
-
`test_unloading_the_newest_version_puts_the_previous_one_back_in_the_slot`

TRL 1.14.0 and 1.17.0: with this PR, TRL 1.17.0 gives 122 passed, 2
skipped (the skips need TRL 1.18). TRL 1.14.0 gives 117 passed, 3
skipped, 4 errors. The 4 errors are in `test_async_grpo_trl_tree.py`
(TRL 1.14 has no `add_fused_lm_head`), and main has the same 4. Checked
against the real TRL modules, the replay detector returns False on 1.14
and True on 1.17 and 1.18.

GPU correctness on B200 (Qwen3-0.6B LoRA, TRL 1.18.0, vLLM 0.29.0, torch
2.14.1): main fails at construction with `AttributeError:
'AsyncGRPOConfig' object has no attribute 'max_inflight_tasks'`. With
the old field patched in, the rollout process then retries
`localhost:8000` until it fails. Commit 1 trains 8 steps: `/metrics`
answers 200, TRL's KV cap is sized from it, and the log has 0 `/metrics`
warnings. TRL keeps 5 versioned adapter ids. Commit 2 trains 8 steps
with one adapter id (`1000000`) across 9 syncs. On B200 these runs only
check correctness; they are not used for performance.

## Rollout throughput

Measured on a Colab L4. Setup: Qwen3-0.6B, bf16 LoRA r=16, TRL 1.18.0,
vLLM 0.29.0, unsloth_zoo 2026.11.5. Run settings: `num_generations=8`,
`per_device_train_batch_size=16`, `max_completion_length=384`,
`gpu_memory_utilization=0.5`, `weight_sync_steps=1`, `max_staleness=4`,
30 steps.

All arms ran on one VM, each in a fresh process. After one discarded
warm-up arm, the order was base, head, head, base, base, head, head,
base. The measurement window runs from the 5th sync to the end (26
syncs). Base is commit 1 and head is both commits. Ranges are min..max
over 4 arms each, and the base range is the A/A noise.

| Metric | Base (median, range) | Head (median, range) | Change |
|---|---|---|---|
| Seconds per training step (= sync interval) | 1.912 (1.850..2.000) |
1.557 (1.486..1.657) | -18.6% (A/A 7.8%, ranges do not overlap) |
| Rollout tokens/s | 881 (826..967) | 1004 (951..1109) | +14.0% (A/A
16%, ranges overlap) |
| Time per sync with a request waiting only on the LoRA slot | 0.576 s
(0.550..0.616) | 0 (all 4 arms) | removed |
| Mean running requests per engine step | 14.5 (13.3..16.3) | 22.0
(19.8..23.3) | +51% |
| Mean reward over 30 steps | 0.953 (0.940..0.958) | 0.946
(0.943..0.950) | inside base range |
| Mean loss over 30 steps | -0.079 (-0.098..-0.063) | -0.076
(-0.108..-0.061) | inside base range |

An earlier run on another L4 VM (3 base and 3 head arms, no warm-up arm)
gave the same picture: rollout tokens/s median 850 to 972, and 0.52 s to
0 per sync of LoRA-blocked waiting.

## Not covered

- No GPU run of TRL 1.14 to 1.17 with `fast_inference=True`. Those
versions are covered by CPU tests with the real TRL modules and by
fakes.
- No top-k / top-p sampling-mask replay from the in-process engine. That
needs `return_sampling_mask` (Model Runner V2) in Unsloth Zoo's engine
args, so this PR refuses the combination instead.
- `/metrics` has no `vllm:num_preemptions_total`, so TRL reports a
preemption delta of 0.
- No A100 run, and no model larger than 0.6B. The gain depends on how
uneven completion lengths are.
- Accuracy over a longer run is not tested. The 30-step reward and loss
are inside the A/A range, but no 30-step trajectory can show a slow
drift.
meefs pushed a commit to meefs/unsloth that referenced this pull request Nov 22, 2026
`pyproject.toml` capped TRL at `<=1.15.0`. That cap was never tied to a
known break: unslothai#13203 set it to the newest release the version matrix had
run, which was 1.15.0 at the time (TRL 1.15 shipped Oct 8). Since then
TRL shipped 1.16.0, 1.17.0, 1.17.1, 1.18.0, 1.18.1 and 1.18.2. AsyncGRPO
needs 1.17+, and tree packing for recurrent layers needs it too. Most of
the 1.16 to 1.18 support work already landed on main (unslothai#16220, unslothai#17714,
unslothai#18070, unslothai#18175, unslothai#18230, unslothai#18254, unslothai#18271, unslothai#18466, unslothai#18614 and others), and
the `HF=latest + TRL=latest` CI lane already runs TRL 1.18.2. Users
still could not install any of it because of the cap.

This PR raises the window to `trl>=0.18.2,!=0.19.0,<=1.18.2` and fixes
the four breaks I found going through 1.16 to 1.18.2 at transformers
5.18.0. Two of them are silent on 1.18: the patch anchor stops matching,
so the trainer still builds but does something different.

### Fixes

1. **AsyncGRPO on TRL 1.16.0 crashed on the first step** with `KeyError:
'tree_segment_parents'`. TRL 1.16 already packs AsyncGRPO rows as a
prefix trie, but it only sends `tree_kv_index` / `tree_cu_seqlens_q` /
`tree_cu_seqlens_k`. `tree_segment_parents` arrived in 1.17, and unslothai#18070
handled only the 1.17+ layout. The parents can be recovered from the K/V
paths: each segment's path is its parent's path plus its own tokens.
`_async_grpo_tree_segment_parents` does that, and on TRL >= 1.17 it
gives exactly the parents TRL sends (there is a test for this). The tree
tests now build TRL 1.16's forward kwargs when `unpad_tree` is missing,
instead of skipping.
2. **SFT with padding-free stopped truncating pre-tokenized datasets on
TRL 1.18.** The padding-free `max_length` block was only generated when
TRL's SFTTrainer had the "`max_length` is not enforced" refusal. TRL
1.18 removed that refusal because its own `_prepare_dataset` truncates.
Zoo's prep replaces that step, though, and leaves rows that already have
`input_ids` alone. So on 1.18 a pre-tokenized dataset trained at full
length: in the version-compat test, 1202-token rows went through against
a 128-token cap. The block is now generated on TRL >= 1.18 too. The 31
tests in `test_trl_padding_free_max_length.py` that skipped on 1.18 now
run there and pass.
3. **SFT `assistant_only_loss` lost its train_on_responses_only fallback
on TRL 1.18.** TRL 1.18 calls
`get_training_chat_template(processing_class,
require_prefix_preservation=False)`, and the anchor only matched the old
one-argument call. A chat template TRL cannot train, such as plain
ChatML without `{% generation %}` markers, went back to raising TRL's
`ValueError`. The anchor now accepts trailing arguments and keeps them.
4. **`UNSLOTH_ENABLE_FLEX_ATTENTION=1` stopped padding to the flex block
size on TRL >= 1.16.** TRL 1.16 changed the `pad_to_multiple_of` default
from `None` to `"auto"`, so `"auto"` now counts as unset too.

Two other changes looked like they might break things and are fine. TRL
1.18's `GKDTrainer` now generates inside `get_batch_samples`, which is
upstream's version of the fix the GKD patch applies to the older
`training_step`, so the patch has nothing to do there. TRL 1.18's new
`qwen3_6_v2` template renders like `qwen3_6` and shares its training
template. The tool-template test now accepts both instead of expecting a
single family.

### Cap sites moved together

- `pyproject.toml` (both trl lines),
`studio/backend/requirements/no-torch-runtime.txt`
- `notebooks-ci.yml` lane, and the `version-compat-ci.yml` ceiling lane
now pins `trl==1.18.2` with `transformers==5.18.0`
- `tests/test_trl_cap_sites.py`: `TESTED_CEILING = 1.18.2`,
`NEWLY_ADMITTED` adds 1.16.0 through 1.18.2, and
`ZOO_FLOOR_ADMITTING_TESTED_TRL_CEILING = None`

unsloth_zoo caps TRL at `<=1.15.0` too, and pip takes the lower of the
two caps. The matching zoo change is a one-line pyproject lift. Until a
zoo release ships with it, pip keeps users on 1.15.0, so the zoo floor
gate stays deferred.
`test_the_zoo_trl_deferral_expires_when_the_zoo_release_ships` fails as
soon as a published zoo admits 1.18.2, and that is the point to raise
the `unsloth_zoo` floor here.

### Testing

Everything below runs at transformers 5.18.0 (the pyproject ceiling).
The CPU suites use torch 2.10 CPU. The GPU jobs run on Colab, with main
and this PR on the same VM and the same deps, and only the unsloth tree
swapped.

**CPU, 307 TRL-touching test files:**

| tree | TRL | passed | failed | skipped |
|---|---|---|---|---|
| main | 1.15.0 | 5960 | 182 | 951 |
| main | 1.16.0 | 5969 | 178 | 946 |
| main | 1.17.1 | 5976 | 173 | 944 |
| main | 1.18.2 | 5941 | 180 | 972 |
| this PR | 1.15.0 | 5957 | 185 | 953 |
| this PR | 1.18.2 | 5982 | 167 | 946 |

163 test IDs fail in every one of these runs: CUDA-only kernels and gloo
cases on a CPU box, plus no torchao. Comparing by test ID, the only
tests that move with the TRL version are the four breaks above. The rest
of the delta is a few dozen gloo / timing / packing tests that flip
between xdist runs, and every one of those passes on both trees and both
TRL versions when rerun alone. The unsloth_zoo side (126 TRL-touching
test files) shows no failure specific to TRL 1.16.0 or 1.18.2.

**Flip tests** (this PR's tests run against main's code):

| test | TRL | main | this PR |
|---|---|---|---|
| AsyncGRPO trio (`test_async_grpo_trl_tree.py`, `_patch.py`,
`_fast_inference.py`) | 1.16.0 | 7 tree tests fail, 4 with `KeyError:
'tree_segment_parents'` | 68 passed |
| same | 1.15.0 / 1.17.1 / 1.18.2 | pass | 61 / 68 / 70 passed |
| `test_trl_padding_free_max_length.py` | 1.18.2 | 34 failed
(pre-tokenized rows not truncated, cap not consumed) | 155 passed |
| same | 1.15.0 / 1.17.1 | pass | 155 passed |
| `version_compat/test_sft_assistant_mask_fallback_trainer.py` (real
UnslothSFTTrainer, ChatML without markers, `assistant_only_loss=True`) |
1.18.2 | `ValueError: The chat template is not training-compatible` |
pass |
| same | 1.15.0 / 1.17.1 | pass | pass |
| `test_sft_assistant_mask_fallback.py::test_applies_to_installed_trl`
(real TRL source) | 1.18.2 | fail | pass |
|
`test_flex_pad_to_multiple_of_auto.py::test_trl_default_pads_to_the_flex_block`
| 1.17.1, 1.18.2 | fail (stays `None`) | pass (128) |
| same | 1.15.0 | pass | pass |
| `test_trl_cap_sites.py` + flex test | 1.15.0 / 1.17.1 / 1.18.2 | | 37
passed, 4 skipped (deferred zoo gate) |
| CI TRL discovery shim (taken from `consolidated-tests-ci.yml`) |
1.15.0 / 1.16.0 / 1.17.1 / 1.18.2 | | pass |

**GPU jobs** (`jobs/*.py --backend unsloth`, verdicts from
`jobs/compare.py`):

Final head, L4, one VM, TRL 1.15.0 / 1.16.0 / 1.18.2 x main / this PR:

| job | model | main vs PR at each TRL | PR, TRL 1.15.0 vs 1.16.0 /
1.18.2 |
|---|---|---|---|
| sft | Qwen3-0.6B | NO_REGRESSION x3 | NO_REGRESSION, same loss on
every step in all 6 runs |
| dpo | Qwen3-0.6B | NO_REGRESSION x3 | NO_REGRESSION, same loss on
every step in all 6 runs |
| vision_sft `--tiny` | tiny Qwen2.5-VL | NO_REGRESSION x3 |
NO_REGRESSION, same loss on every step in all 6 runs |
| grpo (notebook preset) | Qwen3-0.6B-Base | NO_REGRESSION x3 |
NO_REGRESSION (sampled rollouts, within the main-vs-main spread) |

Earlier runs used the first commit. The later commits change AsyncGRPO
tree rows and SFTTrainer init, and the table above covers SFTTrainer
init:

| job | where | main vs PR | PR, TRL 1.15.0 vs 1.18.2 |
|---|---|---|---|
| grpo `--fast-inference` (vLLM 0.32.0), Qwen3-0.6B-Base | G4 |
NO_REGRESSION at 1.15.0 and 1.18.2 | NO_REGRESSION |
| sft / grpo / dpo `--tiny` | A100 | NO_REGRESSION at 1.15.0 and 1.18.2
| same loss on every step |

**AsyncGRPO, `fast_inference=True`** (vLLM 0.32.0, Qwen3-0.6B, LoRA
r=16, 6 steps, RTX PRO 6000):

| TRL | main | this PR |
|---|---|---|
| 1.16.0 | crashes: `KeyError: 'tree_segment_parents'` | trains 6 steps,
mean reward 0.93 |
| 1.17.1 | trains 6 steps, mean reward 0.91 | trains 6 steps, mean
reward 0.91 |
| 1.18.2 | trains 6 steps, mean reward 0.92 | trains 6 steps, mean
reward 0.82 (one sampled 6-step run) |

### Not covered

- No published unsloth_zoo admits TRL > 1.15.0 yet, so users only get
1.16+ after the zoo lift ships and the floor here moves.
- `unslothai/notebooks` pins TRL on its own side (`PIN_TRL`), and so
does Studio's single-env install (`trl==0.23.1`). This PR does not touch
either.
- TRL 1.18 with transformers 5.23+ is covered only by the existing
`HF=latest` lane. pyproject still caps transformers at 5.18.0.
- No multi-GPU (FSDP2 / DDP) GRPO or AsyncGRPO run on 1.16 to 1.18. The
CPU gloo tests cover what they can.
- TRL 1.17.0, 1.18.0 and 1.18.1 were not run on their own. 1.17.1 and
1.18.2 are patch releases on top of them.
- Windows, macOS / MLX and AMD were not run.

Companion: unslothai/unsloth-zoo#2656 raises the zoo ceiling the same
way; merge it first.
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