Repository navigation
feat(training): train with Unsloth through the TRL helper, and wait out a restarting env server - #431
Merged
Merged
Conversation
…ut a restarting env server Unsloth's GRPOTrainer, TRL's rewritten at import, takes AgentEnv's dataset and environment_factory as they are (Unsloth 2026.10.11 on TRL 1.15). Its GPU proof found that a TRL rollout whose session a restarting server dropped was left unscored at once, so every rollout of the steps the restart spanned was lost: the helper now waits for a server that refuses connections, as one restarting does, as long as a reset may take, keeping the short wait for room. The TRL tier also runs on transformers 5.17, the newest Unsloth allows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s reopen within its overall deadline Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
earakely-scale
force-pushed
the
feat/unsloth
branch
from
November 1, 2026 15:31
4370874 to
2fad817
Compare
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.
What
Train on a bundle's tasks with Unsloth's GRPO, through the TRL helper (
agent_env.training.trl). Unsloth'sGRPOTraineris TRL's, rewritten whenunslothis imported first. It takesAgentEnv(url).datasetandAgentEnv.factoryasenvironment_factoryas they are. That covers:fast_inference);The GPU proof below (Unsloth 2026.10.11 on TRL 1.15.0, transformers 5.17.0, vLLM 0.29.0) found one thing to change in the helper, and Unsloth's own constraints add a CI job.
A restarting env server no longer costs every rollout it spans
A TRL environment holds its session across rollouts. When the server dropped it, the helper reopened it with a 4-second wait for room, and didn't wait at all for a server refusing connections, as one restarting does. So the rollouts of every step a restart spanned were left unscored, including those that started while the server was coming back.
reopened(_openenv) now waits for a server that refuses connections as long as a reset may take,max(patience, reset_timeout), when the session asks it to (waits_for_server), and the TRL helper's sessions do.patience=reset_timeout, so they behave as before.CI at Unsloth's ceiling
Unsloth 2026.10.11 caps TRL at 1.15.0 and transformers at 5.17.0. TRL 1.15 can't train on CPU (its log-prob path is a Triton kernel), so
trl.ymladds agrpo (trl==1.16.*, transformers==5.17.*)job: the helper on the newest transformers Unsloth allows.Tests
sessions_test.py: a session tried again past its patience while the server restarts, and given up while it's only busy.trl_test.py: a session dropped by a restarting server opens again once the server is back, and the rollout scores. It fails without the change.GPU runs
Unsloth 2026.10.11 with TRL 1.15.0, transformers 5.17.0 and vLLM 0.29.0 (
vllm-bnb-plugin0.0.3 for 4-bit), on AWS in a temporary VPC, torn down after:Bundles are served by
AgentEnv.local, or by a separatebuild_appserver for the outage runs. The framework is this branch (4370874, before the rebase onto #425's merge; the rebase only renames the session loop).What runs under Unsloth with no change to the helper:
fast_inference=False, transformers generate)end_turn, evals at every step,reward=the meanenv.factorya dict of two classes (gridsim,mail); trainsAsyncGRPOTraineron one GPU, generating on the model's ownfast_inferenceengine, 3 steps of 16Found on GPU, and fixed here: a restarting env server cost every rollout of the steps it spanned. Two 4-step runs on the L4, 16 rollouts a step, with the server stopped 10 s into step 2 and back 30 s later:
Not code, for the docs:
GRPOConfigargument left unset:optimadamw_8bit,weight_decay0.001,seed3407,learning_rate5e-5, a 10% warmup,per_device_eval_batch_size4.loss_type="dr_grpo", Unsloth turnsscale_rewardsoff even when it's set to"group"orTrue; onlyNonekeeps TRL's scaling.end_turn, reaches the task empty. That's the TRL helper's design, which TRL's page documents. Qwen3.5-2B scored 0 on the inbox task for it, where SkyRL's env reads the reply.get_rewardwrapper doesn't passlog_metric. Upstream follow-up.Spend: about $40 of the $40, plus about $1.70. A first round's boxes ran unattended to their 7-hour shutdown, which deleted run A's and run L's results, so both ran again.
🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; no actionable issues remain.Summary
The TRL helper now waits longer when reopening a session against a server that refuses connections.
The earlier, unnumbered timeout finding is fixed:
_callnow includes the reopen budget. No new actionable issues were found.Reviews (3) · Last reviewed commit: "fix(training): a TRL environment's call ..." · Reviewed by Greptile