Repository navigation
[rl] Generator drains itself before a hot_swap=False weight load (8/14) - #5503
felipemello1 wants to merge 53 commits into
Conversation
fc8a101 to
ba0dc0b
Compare
ba0dc0b to
3a10979
Compare
ba8820a to
9bf2abd
Compare
3a10979 to
94f44ea
Compare
|
<WONT REVIEW -- PR IS NOT A PRIORITY> |
94f44ea to
052cb87
Compare
|
reply from claude: this is the same fix as #5253: the generator drains itself before a
|
36b807f to
1bd02b5
Compare
052cb87 to
ca5281f
Compare
ca5281f to
8da6b9d
Compare
…YSTEM A HarnessError counts as the policy's only once the policy has sampled a turn (trace.num_turns > 0). Verifiers also raises it when the harness fails to start, e.g. "opening harness session timed out" when the sandbox tunnel isn't ready in 30 s. The policy never ran, so the rollout is now ERROR_SYSTEM: left out of the reward, the advantage and training, while its siblings train. As ERROR it got reward 0 with no completion tokens, so TrainingSampleBuilder dropped its whole group: a 53-step SWE run lost 293 groups of 16 this way (training_sample_builder/num_groups_dropped_untrainable). A HarnessError after a turn (the agent's own exit) and a ProviderError 4xx before one (first prompt past the context) stay ERROR.
|
Reply from claude: @claude review again |
|
Claude finished @felipemello1's task in 1m 1s —— View job Verdict: Approve -- one thing is still open: the PR description has no "Summary (human-written)" section. A maintainer still needs to review. See review |
There was a problem hiding this comment.
Verdict: Approve -- please address the item below before merging. The new commits fix four of the five items from the last review. The new code has no problems. The one item left is in the PR description, not the code. A maintainer still needs to review, because this touches the RL generator core.
What changed since the last review. drain is now a required keyword in all three load_model_state_dict signatures and on ModelStateDictLoadMessage, and every test passes it explicitly. The two outdated docstrings and the dead sticky-strategy check in strategies.py are fixed or removed. The duplicate decision-level drain test is gone. The three merges from the base branch don't change this PR's diff.
Must fix
- PR description: the "Summary (human-written)" section is still missing. The author has to write it; agents don't fill it in. If the TLDR is meant as the summary, put it under that heading.
Earlier items, resolved
strategies.py:118-121LeastLoadedRoutingStrategy.choosedocstring: now says the tie-break is about which candidates tie, not about candidates leaving the set. Resolved.strategies.py:186-205sticky "pinned candidate gone" check: deleted, along with its docstring bullet and comments.pinned_candidateis still used byrelease_session(inter_generator.py:250), so keeping that method is right. Resolved.draindefault: required ingenerator.py:454,engine_loop.py:208,actors/monarch/generator.py:86and on the message (engine_loop.py:600). The only production caller (inter_generator.py:198) passesdrain=not hot_swap. No other caller in the repo leaves it out. Resolved.- Duplicate drain test:
test_draining_load_waits_for_admitted_work_and_holds_new_requestsis gone. The threadedtest_draining_load_finishes_admitted_requests_then_admits_held_onescovers the same sequence and also checks the policy version at admission. Resolved.
Details
I re-checked these at HEAD (9dd0742):
- No leftover references to
serving,idle,_set_serving,_candidatesorrouter_drain_wait. asyncioandfieldare still used ininter_generator.py.- The
test_engine_loop.py:153helper_load(..., drain=False)keeps a default. That is fine for a test-only helper, and none of the new tests rely on it by accident: the drain tests passdrain=True.
The engine-loop decision logic is the same as at the last review, and the analysis there still applies.
Not verified: I didn't run the unit tests here. The GPU timings come from the PR description.
…lo1/genserver-no-access-log
…/genserver-request-path # Conflicts: # torchtitan/rl/examples/verifiers/generation_server.py
…rollout-worker-structured-logs
…emello1/shutdown/1-drain-in-flight
…lo1/rollout-error-system
…tp/1-generator-drain
…rollout-worker-structured-logs
…emello1/shutdown/1-drain-in-flight
…lo1/rollout-error-system
…tp/1-generator-drain
…/genserver-request-path
…rollout-worker-structured-logs
…emello1/shutdown/1-drain-in-flight
…lo1/rollout-error-system
…tp/1-generator-drain
0ecfb1f to
53b2361
Compare
<WONT REVIEW -- PR IS NOT A PRIORITY>
TLDR: With
hot_swap=False, the generator now drains itself before a weight load, instead of the router holding back its calls. A caller can then sendgeneratestraight to a generator (PR 10) without losing the drain.Stack (14 PRs, merge bottom-up; this PR is in bold)
PRs 2-7 don't need the HTTP design and can be reviewed now. PRs 8-14 wait on the design discussion on PRs 9 and 10.
Problem
hot_swap=False,InterGeneratorRouter.pull_model_state_dictstops routing to a generator, waits until no call it routed there is in flight, then loads.generatecall and sees it start and end.generatestraight to the generator (over HTTP, PR 10) bypasses the router, so the router can't drain.Solution
Generator.load_model_state_dict(version, drain=True)puts a draining load on the engine loop's queue.drain=not hot_swapand drops its per-generatorserving/idlestate.drainis a required keyword, so a caller can't get a hot-swap load by leaving it out.hot_swap=Trueloads, routing, and when a load is requested.Results
Numerics: bitwise vs main. With
hot_swap=True(the default, and every recipe) nothing changes; withhot_swap=Falsea request still waits for the load and runs on the new weights, only where it waits moves.NOTE:
hot_swap=False.hot_swap=False,time_to_first_token_msnow includes the drain wait.router_drain_waitspan is gone; the generator'sload_model_state_dictspan covers drain + load.StickySessionRoutingStrategyno longer checks that a pinned candidate is still incandidates: both routers now pass a fixed list.Test plan
test_session_releases_during_a_drain_ride_the_step_decisiontest_draining_load_at_an_idle_engine_applies_at_oncetest_draining_load_finishes_admitted_requests_then_admits_held_ones(real engine-loop thread, fake engine)test_close_during_a_drain_fails_the_load_and_every_requesttest_pull_model_state_dict_pulls_every_generatorruns with and without hot swap.