Repository navigation
[rl] Periodic validation beside training - #5228
Conversation
659a06b to
10f5b69
Compare
571b6df to
0b9db7c
Compare
|
Reply from claude: Rebased on main and the W&B fix below it. Changes since the last head:
@claude please review |
|
Claude finished @felipemello1's task in 5m 4s —— View job Request changes: an overlapped validation pass that fails as a whole is logged and then ignored, which leaks reused group ids and hides failures from CI. The human-written summary in the description is also still empty. Review |
There was a problem hiding this comment.
Verdict: Request changes -- the scheduling looks right, but overlapped passes that fail as a whole are logged and then ignored, which leaks reused group ids and makes the new CI coverage blind to overlapped-pass failures.
What this PR does. It adds ValidationConfig.freq for periodic validation, plus overlap_training, which runs the pre-training and periodic passes as an asyncio task beside training at the lowest vLLM priority. A pass is logged at the step it ends. Validation steps that come due while a pass is running merge into one deferred pass. After training, a pass still running is awaited, and then the final blocking pass runs, at step N+1 if the awaited pass took step N. Every pass now logs the policy versions it sampled, and timing/validate is split into timing/validation/{blocking,overlapped}.
Example. freq=2, overlap_training=True, 5 steps, pass 0 is slow:
step 1-3: pass 0 runs beside training; step 2 is due -> validation_requested=True
step 3: pass 0 done -> logged at 3; pass "3" starts after pull 3 (policy >= 3)
step 4: due again, pass 3 running -> deferred
step 5: last step: starts nothing; pass 3 still running
run(): await pass 3 -> logged at 5; final pass logged at 6
With the default (overlap_training=False), steps 2 and 4 wait for pull N, then run a blocking pass on policy N while training rollouts keep generating.
Must fix
- The PR description's "Summary (human-written)" is empty. The author needs to fill it in (see CONTRIBUTING.md, "AI-assisted contributions").
torchtitan/rl/controller/controller.py:1070-- a failed overlapped pass is logged, then ignored. Prompt-level errors are already counted invalidation/group_failures, so what reaches this branch is infrastructure failure, for examplerelease_groups(L777). If that fails, the reused ids-1_000_000...keep their cache salt and KV into the next pass, which L776 says must not happen. It also means CI passes even if every overlapped pass fails. Fix: re-raise, as blocking mode does. That letsvalidation/pass_failuresand two tests go.
Should consider
controller.py:171-- also rejectoverlap_training=Truewithsteps=0(suggestion inline).generator/vllm/engine.py:482-- overlapped-vs-blocking is encoded as a magic range of group ids. A blocking pass with 1M or more prompts would silently get the lowest priority. Add a one-line invariant check, or pass priority explicitly.tests/rl/unit_tests/cpu/test_async_controller.py:49-- this imports the private_controllerfrom another test module.test_blocking_validation_failure_stops_trainingadds little.
Questions
- With
final_pass_step = N + 1, a run later extended into the same W&B run id would log training step N+1 to a step that is already committed, and W&B drops such logs. Is extending a run that way a flow you care about? If so, log the awaited pass under the final step's row and let the final pass's keys win. Alternatively, accept the loss and say so in theValidationConfigdocstring.
Details
- Gate: the problem is real and concrete: on main, the pre-training pass blocks every training rollout (Terminal-Bench: 1h45m and no step 1). This resolves the existing
TODO: enable periodic validation with proper overlappingand the engine'sTODO: validation (priority -1) runs before training. No overlapping open PR found. - Correctness checked:
- Blocking mode awaits the pull it just created, so every rollout samples policy N.
- The overlapped pass awaits the same
pull_taskthe next step awaits; there is no deadlock, and a failed pull fails both. close()cancelling the pass also cancelsafter, as the comment says.pre_validation_taskis always done before.exception()is called. It is either logged in the loop or awaited asself._validation_task, including the zero-step resume case.- The pass row is logged before the next
commit(), and its keys don't overlap the training row. - The
max_num_seqssum branch applies only whenfreqis set or overlap is on, so the default is unchanged. - The console allow-lists use regex search, so
"timing/validation/"matches both new keys.
- Size: about 220 lines of controller logic plus about 480 lines of tests. Applying must-fix 2 removes
pass_failures, one log branch, and about 60 test lines.
Not verified: GPU behaviour of the CI config, and whether vLLM preemption starves overlapped passes on saturated generators (the PR's NOTE). A maintainer still needs to review this, since it touches the core RL controller and the generator.
0b9db7c to
122b437
Compare
|
Reply from claude: Addressed the 21:02 review in 122b437 (rebased on the new 1/2): a failed overlapped pass raises; @claude please review |
|
Claude finished @felipemello1's task in 2m 9s —— View job Approve -- please address the item below before merging: the earlier code findings are fixed in 122b437; the human-written summary is still empty. Review |
There was a problem hiding this comment.
Verdict: Approve -- please address the item below before merging. All code findings from the 21:02 review are fixed in 122b437, and the new commits introduce no new problems. The only item left is the empty human-written summary.
What this PR does. It adds ValidationConfig.freq for periodic validation. With overlap_training=True, the pre-training and periodic passes run as one asyncio task beside training, at the lowest vLLM priority (group ids from -1_000_000). Each pass is logged at the step it ends. A failed pass now fails the run in both modes.
Example. freq=2, overlap_training=True, 4 steps, pass 0 is slow:
step 1: pass 0 runs beside training
step 2: due, pass 0 still running -> validation_requested
step 3: pass 0 done -> logged at 3; pass "3" starts after pull 3 (policy >= 3)
step 4: last step: starts nothing
run(): await pass 3 -> logged at 4; final blocking pass logged at 5
If pass 3 raises (e.g. release_groups), _log_finished_validation re-raises: in the trainer loop at the step it ends, or in run() after training.
Earlier findings
- Overlapped pass failure swallowed: resolved.
_log_finished_validationcallstask.result()(controller.py:1074),pass_failuresis gone, andrun()reads.result(). overlap_trainingwithsteps=0: resolved (controller.py:639).- Magic id range with 1M+ blocking prompts: resolved by the
setup_asyncValueError(controller.py:690). The dataset size is only known there, so this is the earliest place it can be checked. - Private
_controllerimport, plus the low-value blocking-failure test: resolved. - W&B N+1 question: answered. The accepted cost is documented in the
ValidationConfigdocstring.
Must fix
- The PR description's "Summary (human-written)" section is still empty. The author has to fill it in (CONTRIBUTING.md, "AI-assisted contributions").
Details
Rechecked at HEAD:
run(): the awaited pass andpre_validation_task.result()run after thefinallythat cancels the loops. A pass error there propagates out ofrun(), andclose()then cancels nothing (_validation_taskis already None).- A crash in a training loop skips the await, and
close()cancels and drains the pass before the rollouter closes. A test covers this. - When the trainer exits early (NaN or the batcher closes), a running pass is still awaited and logged at
num_training_steps, the same step as the final pass on main. - When no rollout succeeds, the new min/max/mixed metrics are NaN (
Min/Max.from_list([])), and_log_reward_delta'snewest > oldestcheck is False, so nothing breaks. asyncio.to_thread(get_validation_samples)builds a fresh dataset object on each call, so it shares no iterator state with the training loader.
Not verified: GPU behaviour of rl_grpo_fsdp2_gen_tp2_no_compile with overlap (CI runs it), and how long overlapped passes take under vLLM preemption on saturated generators. A maintainer still needs to review this, since it touches the core RL controller and generator.
|
Reply from claude: Similar open PR: #5649 (vkuzo, draft) adds blocking periodic validation with the same await-pull mechanism. This PR also overlaps validation with training. #5649 also fixed the validation console key: the default allow list named |
|
Reply from claude: Merged the updated 1/2 (main 0d35b95 plus its two fixes) in 6f6104c and 1f32017. No conflicts. This PR's own diff did not change. Checked against main's #5531: 2-GPU overlapped run after the merge (6f6104c): passes started at steps 0, 3, 6, 9 and were logged at 1, 6, 9, 10. The final pass was logged at 11. Each pass landed in its step's W&B row. CI at this head: @claude please review |
|
Claude finished @felipemello1's task in 1m 25s —— View job Approve -- please address the item below before merging: the merge with main leaves the PR diff unchanged and composes correctly with #5531; the human-written summary is still empty. Review |
There was a problem hiding this comment.
Verdict: Approve -- please address the item below before merging. The merge with main (6f6104c, 1f32017) leaves this PR's own diff unchanged, it composes correctly with #5531, and the console-key fix (5406757) is correct. The only open item is still the empty human-written summary.
What changed since the last review (122b437).
- 5406757: the default
console_log_keys_validationnow namesvalidation_reward/_meanandvalidation_reward/_max, the keyscompute_rollout_metricsactually emits. The updated test uses the default list, so it would catch the mismatch if it came back. - Merge with main, including #5531. Main now sets
max_num_seqs = min(rollout_concurrency, 512)(controller.py:669). This PR still computesrollout_concurrencyas training + validation whenfreqoroverlap_trainingis set (controller.py:650), and as the max otherwise. So the default path matches main, and periodic or overlapped validation gets the sum, capped at 512. - The PR diff is 706/+70- before and after the merge, across the same 12 files. Nothing new to review in it.
Example (CI config at this head). rl_grpo_fsdp2_gen_tp2_no_compile, ValidationConfig(steps=20, freq=2, overlap_training=True), 5 steps:
pre-training pass (step 0) -> logged at 1
pass due at step 2 -> logged at 4
pass due at step 4 -> logged at 5 (awaited after the last step)
final blocking pass -> logged at 6
Must fix
- The PR description's "Summary (human-written)" section is still empty. The author has to fill it in (CONTRIBUTING.md, "AI-assisted contributions").
Details
- #5531 found an FA2 out-of-bounds write that depends on the value of
max_num_seqs: vLLM's profiling dummy batch splits 2048 tokens acrossmax_num_seqsrequests, and a dummy request with 65 or more tokens reaches the bug. This PR raisesmax_num_seqsonly for configs that setfreqoroverlap_training. In-repo, that is onlyrl_grpo_fsdp2_gen_tp2_no_compile, and that job passes at this head. A recipe that turns on periodic validation later, on an FA2 GPU, could land on a crashing value. That is #5531's open bug, not something this PR adds. - Earlier findings remain resolved at HEAD: a failed overlapped pass raises (
_log_finished_validationcallstask.result());steps=0withfreqoroverlap_trainingraises;setup_asyncrejects passes with 1M or more prompts (controller.py:645).
Not verified: how long overlapped passes take under vLLM preemption on saturated generators. A maintainer still needs to review this, since it touches the core RL controller and the generator.
1f32017 to
eaf27ff
Compare
| "validation_reward/_mean", | ||
| "validation_reward/_max", | ||
| "validation/response_length/mean", | ||
| "timing/validate", | ||
| "timing/validation/", |
There was a problem hiding this comment.
Why were the reward variable names changed?
There was a problem hiding this comment.
Reply from claude: These are console allow-list keys, not variables. The reward is emitted as validation_reward (compute_rollout_metrics), so main's default validation/reward/_mean never matched, and the console never printed the validation reward. The recipes already list validation_reward/_mean.
| down and restart every pass, so a pass runs in arrival order (not newest first): | ||
| - blocking validation: -1, -2, ... -> priority -1, before training; | ||
| - overlapped validation: -1_000_000, -1_000_001, ... -> priority 2**31 - 1, after training. |
There was a problem hiding this comment.
I don't think this is very clear.
There was a problem hiding this comment.
Reply from claude: Rewritten as a table: training group ids keep their own priority, and every validation request (a negative group id) gets one priority, 2**31 - 1, so it runs after all training, in arrival order.
|
|
||
|
|
||
| # Overlapped validation group ids count down from here; the engine schedules them after all training. | ||
| OVERLAPPED_VALIDATION_FIRST_GROUP_ID = -1_000_000 |
There was a problem hiding this comment.
What if we have over 1 million validation samples over the course of training?
There was a problem hiding this comment.
Reply from claude: The 1M offset is gone. Group ids are -(step * num_prompts + i + 1), built from the pass's step and the prompt index, so passes never share ids and there is no 1M limit.
| Example, `freq=25`, `overlap_training=True`, 100 steps: | ||
| step 0: pass 0 starts on policy 0; training starts at once. | ||
| step 7: pass 0 ends and is logged at step 7; its slowest rollouts sampled up to policy 6. | ||
| step 25: pass 25 starts on policy 25 or later. Had pass 0 still been running, pass 25 would | ||
| start at the end of the step in which pass 0 ends. Several validation steps that | ||
| come while one pass runs merge into one deferred pass. | ||
| step 100: a pass that ends in step 100, or is still running, is logged at step 100; the | ||
| final pass then logs at step 101. Accepted cost: a later run that extends this one | ||
| into the same W&B run id logs training step 101 to a committed row, and W&B drops it. | ||
| """ |
There was a problem hiding this comment.
The example here could have just been a diagram, like a Gantt diagram. There's no need for all those words.
There was a problem hiding this comment.
Reply from claude: ValidationConfig's docstring is now a Gantt chart drawn to scale (freq=25, passes of 60 steps), one block per mode, with the step each pass is logged at.
| step 25: pass 25 starts on policy 25 or later. Had pass 0 still been running, pass 25 would | ||
| start at the end of the step in which pass 0 ends. Several validation steps that | ||
| come while one pass runs merge into one deferred pass. |
There was a problem hiding this comment.
My first thought was that when steps accumulate, we should skip the stale ones. For example, if pass 0 finishes at step 60, we shouldn't start pass 25 and then pass 50; we should skip 25 and start 50 right away.
On second thought, I don't think that's right, and I don't think the current behavior is right either. If we want validation on every step, we should start a new validation on every step. Say we have 20 samples: start the 20 samples on step 1, then restart them on step 2, step 3 and step 4. If that blocks training, so be it; people should choose a lower validation frequency.
We could add a second flag, e.g. skip a validation if the previous one is still running, but I think it's too bloated and I'm not sure it's worth it. It's worth surveying what other libraries do.
There was a problem hiding this comment.
Reply from claude: Validation never stalls training now. By default every due pass starts, side by side with the running ones; a boolean flag keeps the merge. In other libraries that overlap validation with training, 2 of 3 start every due pass, and 1 runs one pass at a time and catches up later; none merges.
| overlap_training: bool = False | ||
| """False: training waits for each pass, so all its rollouts sample one policy. |
There was a problem hiding this comment.
Make it obvious that this is a blocking call.
There was a problem hiding this comment.
Reply from claude: The blocking mode is gone (overlap_training removed): training never waits for a pass.
| True: the pre-training and periodic passes run beside training on the same generators: | ||
| - at the lowest vLLM priority, so on busy generators a pass takes longer; | ||
| - a rollout's later tokens can sample a newer policy (`validation/max_policy_version`). | ||
| A failed pass fails the run in both modes. Keep False for a clean pre-training score.""" |
There was a problem hiding this comment.
The last part is true for both modes, but I think the part above it is wrong. The lower the priority value, the more important the request, isn't it? Since validations have negative priority, validations always come first, no?
There was a problem hiding this comment.
Reply from claude: In vLLM a smaller value runs first. Validation used to map to -1 (first) when blocking and to 231 - 1 (last) when overlapped. Now every validation request gets 231 - 1, so it always runs after training.
| # A blocking pass's group ids -1 .. -N must stay above the overlapped range, which the | ||
| # engine schedules after all training. | ||
| if num_validation_groups >= -OVERLAPPED_VALIDATION_FIRST_GROUP_ID: | ||
| raise ValueError( | ||
| f"validation has {num_validation_groups} prompts per pass; a blocking pass needs " | ||
| f"fewer than {-OVERLAPPED_VALIDATION_FIRST_GROUP_ID}. Lower validation.steps." | ||
| ) |
There was a problem hiding this comment.
Honestly, this seems a bit silly; there must be a better way of doing this. Why not pick 10 million instead of 1 million? I'm sure int32 can handle that. Can we avoid this counter?
There was a problem hiding this comment.
Reply from claude: Gone: no offset, no range check, no counter. Ids come from the step and the prompt index (see the types.py thread).
| if async_loop.validation.overlap_training: | ||
| # Generators already hold policy `start_step` (setup_async), so training can start right away. | ||
| pre_validation_task = self._start_validation(step=self.start_step) | ||
| pre_validation = {} # read from the task after training | ||
| else: | ||
| pre_validation = await self._validate_and_log(step=self.start_step) |
There was a problem hiding this comment.
I'm not a big fan of having two different ways of calling validation. I wonder if there's a more elegant way. I do understand why there's an if/else: one branch waits and the other doesn't.
There was a problem hiding this comment.
Reply from claude: One way now: _start_validation(step, after) starts every pass, and _log_finished_validation logs the ones that ended, oldest first. run() has no if/else.
| validation = self.config.async_loop.validation | ||
| # The last step starts no pass (the final pass after training covers it) and leaves a | ||
| # running or finished pass to run(), which logs it before the final pass. | ||
| if step < num_training_steps: | ||
| is_validation_step = ( | ||
| validation.freq is not None and step % validation.freq == 0 | ||
| ) | ||
| if not validation.overlap_training: | ||
| if is_validation_step: | ||
| # Pause training until the pass ends. Only this loop syncs weights, so every | ||
| # validation rollout samples this step's policy; training rollouts keep generating. | ||
| with sl.log_trace_span("validation_wait_for_pull"): | ||
| await pull_task | ||
| await self._validate_and_log(step=step) | ||
| else: | ||
| self._log_finished_validation(step=step) | ||
| if is_validation_step: | ||
| validation_requested = True | ||
| if self._validation_task is not None: | ||
| logger.info( | ||
| f"Validation step {step}: {self._validation_task.get_name()} is " | ||
| "still running; the next pass starts when it ends" | ||
| ) | ||
| if validation_requested and self._validation_task is None: | ||
| # The pass, not the trainer, waits for this step's weight pull. | ||
| self._start_validation(step=step, after=pull_task) | ||
| validation_requested = False |
There was a problem hiding this comment.
On the trainer loop function's changes: these look like too much. I'm sure it can be simpler than this.
There was a problem hiding this comment.
Reply from claude: The trainer-loop block is now about 9 lines: log the passes that ended, and start a pass at a due step unless the one-at-a-time flag is set and a pass is running. It never awaits a pass.
|
@claude review |
|
Claude finished @felipemello1's task in 2m 54s —— View job Request changes: @felipemello1's 10 review comments are still open at HEAD, four of which change the design, and the human-written summary is still empty. Review |
There was a problem hiding this comment.
Verdict: Request changes -- @felipemello1's 10 review comments from 06:20 are still open at HEAD eaf27ff. Four of them change the design (how due passes are scheduled, one validation call path, a simpler _trainer_loop, the group-id range), so the PR needs another look once they're addressed. I found no new correctness bugs at this head.
What this PR does. It adds ValidationConfig.freq for periodic validation. With overlap_training=True, the pre-training and periodic passes run as one asyncio task beside training. Their requests are scheduled after all training requests (group ids from -1_000_000, which map to vLLM priority 2**31-1). Each pass is logged at the step it ends, and steps that come due while a pass runs merge into one deferred pass.
Example. This shows the merge behaviour challenged in comment 5 below. freq=25, overlap on, pass 0 takes 60 steps:
HEAD: pass 0 logged at 60 -> due steps 25 and 50 merge -> one pass starts at 60 (policy >= 60)
proposed: step 25 is due, pass 0 still running -> trainer waits for pass 0, logs it at 25,
starts pass 25 (policy 25); the same happens at 50, 75, ...
Must fix
- The PR description's "Summary (human-written)" is still empty (CONTRIBUTING.md, "AI-assisted contributions").
- The 10 inline comments by @felipemello1 are unaddressed. My take on each:
- processor.py:88 (why rename the reward keys): the old defaults never matched anything.
compute_rollout_metricsemitsf"{prefix}_reward"(controller/metrics.py:279), so the keys arevalidation_reward/_mean, and every recipe already uses those names. It's a drive-by fix, but this PR has to edit that list anyway fortiming/validation/. Keep it. - types.py:50 (over 1M samples over training?): that case is fine. Ids restart at every pass (
controller.py:743), and only one pass is in flight at a time, so the limit is per pass.setup_asyncchecks it (controller.py:707). - controller.py:650 (why 1M, can we avoid it): 10M would work just as well; int32 headroom isn't the constraint. The range exists only because the group id is the only per-request value that reaches the engine. The other option makes priority a run-level setting: in overlap mode every pass can run last (the final pass runs after training), and in blocking mode every pass runs first. That would delete the constant, the
setup_asynccheck and the two-range docs, but it needs a flag threaded the waymax_num_seqsis (about 5 files). I'd keep the range and fix the docs. - types.py:65 (unclear docstring) and controller.py:169 (doesn't negative mean first?): the code is right:
_vllm_priority(engine.py:1097) maps ids <= -1M to 2**31-1, which runs last. The wording causes the confusion, since "lowest priority" reads as "lowest value". Spell out the mapping as a table (sketch below). - controller.py:155 (use a diagram) and :165 (say it blocks): agreed. Sketches below.
- controller.py:151 (merge vs. one pass per due step): I agree with the proposal. At a due step, wait for the running pass, log it, then start this step's pass. Each pass then starts on exactly policy N, and the merge state (
validation_requested, the "merge" docs, the deferred start) goes away. When a pass takes longer thanfreqsteps, training stalls; that tells the user to lowerfreq. A skip-if-running flag isn't needed. From memory, unverified at a pinned version: verl (trainer.test_freq) and OpenRLHF (eval_steps) both run eval in the train loop and block. I don't know of a library that merges deferred passes. - controller.py:918 and :1454 (two call paths, trainer loop too big): with the semantics above, both modes collapse into one helper. Blocking means "wait for the pass you just started". Sketch below.
- processor.py:88 (why rename the reward keys): the old defaults never matched anything.
Sketches
_trainer_loop (replaces L1428-1455) and run() pre-training (replaces L909-918):
# trainer loop
self._log_finished_validation(step=step) # no-op unless a pass ended
if validation.freq is not None and step % validation.freq == 0 and step < num_training_steps:
await self._validate(step=step, after=pull_task)
# run()
await self._validate(step=self.start_step)
async def _validate(self, *, step: int, after: asyncio.Task | None = None) -> None:
"""Start the pass for `step`. Blocking: wait for it. Overlapped: wait only for the previous one."""
if self._validation_task is not None:
with sl.log_trace_span("validation_wait_for_previous_pass"):
await asyncio.wait([self._validation_task])
self._log_finished_validation(step=step)
self._start_validation(step=step, after=after) # overlapped=config flag
if not self.config.async_loop.validation.overlap_training:
await asyncio.wait([self._validation_task])
self._log_finished_validation(step=step)_log_finished_validation can return the aggregated dict, so run() keeps the first pass's metrics for _log_reward_delta and the pre_validation = {} placeholder goes. This removes validation_requested, the "still running" branch, and the mode if/else in run(). The merge test (test_overlapped_validation_starts_no_pass_at_the_last_step) and part of test_overlapped_validation_runs_beside_training get rewritten.
ValidationConfig docstring:
freq=25, overlap_training=True, 100 steps
step 0 7 25 33 50 ... 100 101
train |=========================================|
pass 0 |====| logged at 7 (policies 0..6)
pass 25 |=====| starts after pull 25, logged at 33
final |==| logged at 100, or 101 if a pass
was still running at 100
overlap_training:
False (default): blocking. At each validation step the trainer stops until the pass ends.
Validation requests run before training (vLLM priority -1), so the pass samples policy `step`.
True: pre-training and periodic passes run beside training. Their requests run after all
training requests (vLLM priority 2**31 - 1), so on busy generators a pass takes longer,
and a rollout's later turns can sample a newer policy (`validation/max_policy_version`).
In both modes, a pass that fails as a whole fails the run.
EngineRequest.group_id:
Rollout group id; `_vllm_priority` (vllm/engine.py) maps it to a vLLM priority (smaller =
admitted first, preempted last):
training 0, 1, 2, ... -> group id (older groups first)
blocking validation -1, -2, ... -> -1 (before all training)
overlapped validation <= -1_000_000 -> 2**31 - 1 (after all training)
Ids restart every pass, so a pass runs in arrival order.
Not verified: GPU behaviour and how long passes take under vLLM preemption. A maintainer still needs to review this, since it touches the core RL controller and generator.
|
Reply from claude: requesting a review of the updated draft. @claude please review |
|
Claude finished @felipemello1's task in 2m 24s —— View job Approve: tianyu-l's 7 comments are fixed or answered, no new problems; review (a maintainer still needs to review). |
There was a problem hiding this comment.
Verdict: Approve -- tianyu-l's 7 comments are fixed in code or answered at 0cd2374, and I found no new correctness problems. Two of the answers still need tianyu-l's decision (see Questions). A maintainer still needs to review, because this touches the core RL controller.
What this PR does. Validation passes now run as asyncio tasks beside training instead of blocking the step. _maybe_run_validation(step, after_training=...) makes every scheduling decision. If a pass is still running when the next one is due, the new pass is deferred. At shutdown, an unfinished pass is cancelled and the final pass runs if validate_after_training is set. Validation groups use ids that count down from -1, so vLLM serves them at priority -1. Turn metrics are relabeled with one validation_ prefix rule.
Example (test_validation_schedule, freq=2, 8 steps):
step 0: pass@0 starts
step 2: due, pass@0 still running -> deferred
step 3: pass@0 logged, pass@3 starts
step 6: pass@3 logged, pass@6 starts
end: pass@6 cancelled; pass@8 runs only if validate_after_training
Earlier comments
- Validator naming in the TODO: resolved.
- Why ids count down from -1: resolved (comment names request-id and cache-salt collisions).
- One relabel rule: resolved. Checked against
metrics.py: turn metrics arrive unprefixed. - Resume reruns a pass: partly addressed (see Questions).
- Fold
validate_after_traininginto_maybe_run_validation: resolved by theafter_trainingkwarg. - Final push/pull when
validate_after_trainingis off: answered; the author offered a ~2-line skip. - Gather captures every task: answered. A pass that ends during close() is also fixed and tested.
- The human-written summary is now filled in: resolved.
Should consider
- Still open: search_r1 runs 500-prompt periodic passes at priority -1. The step-time cost is unmeasured; only a TODO in
vllm/engine.pycovers it.
Questions
- tianyu-l: in-repo recipes checkpoint at multiples of
freq, so a resumed run at step N still reruns pass@N. Pretraining skips the step it loads. Is that acceptable, or should resume skipstep == start_stepwhenstart_step > 0(~2 lines)? - tianyu-l: do you want the ~2-line skip of the final push/pull when
validate_after_trainingis off?
Details
Traced at HEAD:
- Steps passed to
_maybe_run_validationonly increase. - A failed pass raises through
task.result(), both from the trainer loop (controller.py:1384) and from the after_training call (controller.py:1002).test_failed_validation_pass_fails_trainingcovers this. - Cancelled tasks are skipped with an INFO line.
- The defer logic matches the docstring diagram.
- Resume at
num_training_stepsstarts no pass. - Group ids are unique across passes.
Minor, harmless: steps=0 with the default validate_at_step_0 logs an empty row, as main did. The console no longer prints a validation reward; the PR body says so.
Not verified: GPU step time while a pass is running.
…t running (review)
| self._is_validation_due = False | ||
| # Count down from -1, since training group ids count up from 0. A shared id would give two requests | ||
| # the same id (`group=5/rollout=0/turn=0`), which crashes the generator's engine loop, and would give | ||
| # two groups one pinned policy version (their prefix-cache salt). Negative ids also get vLLM priority -1. |
There was a problem hiding this comment.
lets make it explicit that negative IDs prioritize eval requests over training requests
There was a problem hiding this comment.
Reply from claude: Done in 0d8c9b0. The comment now ends: "Negative ids also get vLLM priority -1, so the generators serve validation requests before training requests."
| self.metrics_processor.log( | ||
| step=step, metrics=task.result(), is_validation=True | ||
| ) |
There was a problem hiding this comment.
is each task here a single prompt or its the whole validation? if its a single prompt, i am not sure how i feel about this continuous logging. I like it, but its also deceiving because when i see a number, i dont know if its the final or not.
There was a problem hiding this comment.
Reply from claude: The whole validation. One task is one validate(step) call over all its prompts, and its metrics are logged once, when it ends. So every W&B number is final. 0d8c9b0 makes the comment on _validation_tasks say so.
One thing can still mislead: a row sits at the step its validation ended (started at 50, logged at 90), and the weights changed in between. No key records the start step. If you want it, a validation/start_step key is one line in validate(). I didn't add it.
There was a problem hiding this comment.
Reply from claude: Added in 240e435: each validation row now logs validation/started_at_step. Example: the validation due at 50 waits for the running one, starts at 60 and is logged at 90, with validation/started_at_step = 60. It also tells apart the two rows that can land at the last step.
| if self._is_validation_due: | ||
| logger.info( | ||
| "A validation pass came due but never started: training ended first" | ||
| ) |
There was a problem hiding this comment.
what happens in this case? Will we log, on the same step, both this ongoing and the final one?
There was a problem hiding this comment.
Reply from claude: That validation never runs and is never logged. This INFO line is its only trace. At the last step N:
came due, waited for the running one never started, never logged (this line)
still running when training ends cancelled in run()'s finally, never logged
ended during the last step logged at N
validate_after_training=True runs now, also logged at N
So step N can get two validation rows (more with defer_new_if_not_finished=False). W&B keeps both. No code change.
There was a problem hiding this comment.
Reply from claude: Update: a7980bc removes this end-of-run INFO line (tianyu-l asked on the flag thread). The per-step line "Validation due at step N waits for the running one to end" still shows that it came due.
| ) | ||
|
|
||
| # Finish the last push and pull so generators hold the final weights for post-validation. | ||
| # Starts or logs passes; never waits for one (only after_training does). |
There was a problem hiding this comment.
i dont like too much this wording "pass". Can we rename it throughout the pr?
There was a problem hiding this comment.
Reply from claude: Done in 0d8c9b0: "pass" -> "validation" in every line the PR adds (docstrings, comments, log messages, task names, tests, recipes, the Terminal-Bench README, the vLLM TODO). The PR body and the TLDR image too.
| # A pass beside training would change the step times this recipe measures: validate at the end. | ||
| config.async_loop.validation = dataclasses.replace( | ||
| config.async_loop.validation, | ||
| validate_at_step_0=False, | ||
| validate_after_training=True, | ||
| ) |
There was a problem hiding this comment.
this "dataclasses.replace" looks a bit odd. We dont do that for other configs
There was a problem hiding this comment.
Reply from claude: Done in 0d8c9b0, with plain assignment, like config.async_loop.target_offpolicy_steps = 0 in the same file:
config.async_loop.validation.validate_at_step_0 = False
config.async_loop.validation.validate_after_training = TrueEach base builder makes a fresh ValidationConfig, so the base recipes keep their values (checked on CPU). The file still uses dataclasses.replace for the nested trainer and generator configs; for two scalar fields, assignment is simpler.
…p-validation/2-overlap-validation-1109
…ibute assignment in perf recipes (review)
|
Claude finished @felipemello1's task in 2m 21s —— View job Approve: felipemello1's 5 comments are addressed at 0d8c9b0 and nothing new needs fixing; tianyu-l's change request still stands. Review |
There was a problem hiding this comment.
Verdict: Approve -- the push ca7bd49..0d8c9b0 handles @felipemello1's 5 comments from 21:10, merges main cleanly, and changes no behavior. tianyu-l's CHANGES_REQUESTED review still stands, and two questions from the last review are still waiting for tianyu-l (below).
What changed since the last review.
controller.py:553-556: the group-id comment now says that negative ids get vLLM priority -1, so the generators serve validation requests before training requests.controller.py:546-548: the_validation_taskscomment now says one task is one whole validation, with all its prompts, and that its metrics are logged once. This answers the question at L1034: every logged number is final.- "pass" -> "validation" in every added line: docstrings, comments, log messages, task names, tests, recipes, the Terminal-Bench README and the vLLM TODO.
gh pr diff 5228now has no added line containing "pass" or "passes". The test parameter rename (start_pass->step_0_validation, metric keyspass_N->started_N) is mechanical. alphabet_sort.py:672-674, 956-958: plain attribute assignment instead ofdataclasses.replace. I checked that this is safe: both base builders (rl_grpo_qwen3_30b_a3b_varlen,rl_grpo_qwen3_5_9b_varlen) construct a freshValidationConfig(steps=20)on each call, andValidationConfigis not frozen. So the mutation can't leak into the base recipes.- The L1041 thread (two validation rows at step N) is answered with no code change. The behavior is the one the PR body's NOTE and the
validate_after_trainingdocstring describe. - The merge from main brings in #5886 (
local_compileonDAPOLoss), which isn't part of this PR's diff. The controller, generator and test changes in the push are wording only.
Example (unchanged, test_validation_schedule, freq=2, 8 steps, each validation ends 3 steps after it starts):
step 0: validation started at 0
step 2: due, the running one hasn't ended -> waits (INFO line)
step 3: validation from 0 logged at 3; validation started at 3
step 6: validation from 3 logged at 6; validation started at 6
end: validation from 6 cancelled; one more runs at 8 only with validate_after_training
Questions (still open for tianyu-l, from the last review)
- Resume: in-repo recipes checkpoint at multiples of
freq, so a resumed run reruns the validation at its start step, while pretraining skips the step it loads. Keep this, or skipstep == start_stepwhenstart_step > 0(~2 lines)? - Should the trainer skip the final push and pull when
validate_after_trainingis off (~2 lines)?
Should consider (still open)
search_r1.py:128: 500-prompt multi-turn validations every 50 steps at priority -1. The step-time cost is unmeasured; only the TODO invllm/engine.pytracks it.
Not verified: step time on GPU while a validation runs. A maintainer still needs to review this, since it changes the core RL controller.
|
Claude finished @felipemello1's task in 1m 4s —— View job Approve: the new |
There was a problem hiding this comment.
Verdict: Approve -- 240e435 adds validation/started_at_step as asked on the L1034 thread. It is correct and changes nothing else. tianyu-l's CHANGES_REQUESTED review still stands, and the two questions from earlier reviews are still waiting for tianyu-l.
What changed since 0d8c9b0. validate() now appends m.Metric("validation/started_at_step", m.NoReduce(step)) next to timing/validate (controller.py:866-868). The ValidationConfig docstring and the validate() docstring mention the new key.
Example (freq=25, each validation takes 30 steps, defer on):
validation due at 25 -> waits for the one from 0 -> starts at 30 -> logged at 60, started_at_step=30
validate_after_training=True, 100 steps:
one that ends during step 100 -> logged at 100, started_at_step=90
the one after training -> logged at 100, started_at_step=100
So the two rows that can land at step N now differ by this key.
Details
Checked at 240e435:
NoReduce.reduceraises if it gets more than one entry per key (observability/metrics/types.py:384). Each validation row is its ownmetrics_processor.logcall, andvalidate()appends the key once, so it gets exactly one entry. This is the same patterntiming/validatealready uses.stepis the step passed when the task is created:start_step, the trainer step whose metrics were just logged (_maybe_run_validation,controller.py:1069-1070), ornum_training_stepsfor the validation after training (L1047). A deferred validation records the step it actually started at, not the step it came due. That matches the docstring.steps == 0returns[]before the key is appended, so disabled validation still logs an empty row, as before.- No test checks the key. The rules don't call for one: a single appended metric breaks visibly, not silently.
Still open from earlier reviews
- Questions for tianyu-l: should a resumed run skip the validation at its start step? Should the trainer skip the last push and pull when
validate_after_trainingis off? Each is about 2 lines. search_r1.py:128(should consider): it runs 500-prompt validations every 50 steps at priority -1, and the step-time cost has not been measured.
Not verified: GPU step time while a validation runs. A maintainer still needs to review this, since it changes the core RL controller.
| step=step, metrics=metrics, is_validation=True | ||
| ) | ||
| return | ||
| # No validation starts at the last step: training ends right after. |
There was a problem hiding this comment.
we really should have a should_validate() method
https://github.com/pytorch/torchtitan/blob/main/torchtitan/components/validator.py#L73
There was a problem hiding this comment.
Reply from claude: Done in a7980bc: _should_validate(step) -> bool, like pretraining's should_validate. Step 0 follows validate_at_step_0; other steps, each multiple of freq. The last-step rule stays in the caller (_maybe_start_validation), because it must also stop a validation that came due earlier and is still waiting.
| async_loop = self.config.async_loop | ||
| validation = async_loop.validation | ||
| if after_training: | ||
| if self._is_validation_due: |
There was a problem hiding this comment.
I don't think we need this as class variable -- here it's just logging, which can be worked around?
There was a problem hiding this comment.
Reply from claude: Done in a7980bc. The after-training log line that read the flag is gone. The flag stays: it carries a validation that came due while another ran. Names are now is_due (_should_validate(step)), _has_pending_validation (came due, not started yet) and must_wait (another one runs and defer_new_if_not_finished is on).
Longer than freq: with the default defer_new_if_not_finished=True, at most one validation runs. Steps that come due while it runs collapse into one pending validation, which starts when it ends. freq=10 and 30-step validations: they start at 0, 30, 60. Never piles up. With False, every due one starts, so several overlap and slow training. Nothing caps them, and no recipe sets False (not measured).
| ) | ||
| async_loop = self.config.async_loop | ||
| validation = async_loop.validation | ||
| if after_training: |
There was a problem hiding this comment.
The if-else here mixes two quite different workflow together in one function. I think we should have a validator class, and make them two separate functions, e.g. this one could be after_training_validate().
I'm OK with this being a TODO.
There was a problem hiding this comment.
Reply from claude: Done in this PR instead of a TODO (a7980bc), about the same line count:
_maybe_start_validation(step): plain function, never waits; called at the start step and after each training step.async _maybe_validate_after_training(step): called once byrun()after it cancels the running ones.- Both first call
_log_ended_validations(step).
The after_training flag is gone. The Validator-class TODO stays; these become its methods.
|
@claude review my review |
There was a problem hiding this comment.
Verdict: Approve -- please address the items below before merging. All three of tianyu-l's points are local refactors of _maybe_run_validation. Two are correct as stated. The third is partly correct: the log line can go, but _is_validation_due has to stay. A maintainer still needs to review, since this changes the core RL controller. tianyu-l's earlier change request still stands.
What this PR does. It runs RL validation as asyncio tasks beside training. A validation that comes due while another is still running waits for it to finish (defer_new_if_not_finished). An optional blocking validation can also run after training.
Example. freq=25, and each validation takes 30 steps:
step 25: due, one is still running -> _is_validation_due = True (deferred)
step 30: running one ends -> deferred validation starts (state carried from 25)
without the attribute: nothing due at 30 -> the step-25 validation is dropped, next starts at 50
On tianyu-l's comments
controller.py:1052--should_validate(): correct. Extract a pure_should_validate(step) -> boolthat mirrorscomponents/validator.py:73(sketch inline).controller.py:1042--_is_validation_duenot needed as a class variable: partly correct. Delete the after-training log line (L1042-1045). Keep the attribute: L1059/L1067 need it to carry a deferred validation across steps. Without it, defer silently becomes skip (details inline).controller.py:1041-- split the two workflows: correct, and small enough to do here rather than as a TODO. Split it into a sync_maybe_start_validation(step)(that branch never awaits) and anasync _validate_after_training(step), sharing_log_ended_validations(step). This is roughly LoC-neutral.
Must fix
- Apply 1-3 above. Update every reference to the old name:
run()L977 and L1011,_trainer_loopL1393,test_async_controller.py:994, the call-graph docstring at L884, and the comment at L550.
Questions
- Still open for tianyu-l from earlier reviews:
- Should a resumed run skip the validation at its start step?
- Should the trainer skip the final push and pull when
validate_after_trainingis off?
Not verified: GPU step time while a validation runs (for example the 500-prompt validations every 50 steps in search_r1).
| step=step, metrics=metrics, is_validation=True | ||
| ) | ||
| return | ||
| # No validation starts at the last step: training ends right after. |
There was a problem hiding this comment.
Re tianyu-l's should_validate() comment: correct. L1052-1058 compute a pure schedule decision from step and the config, which is exactly what BaseValidator.should_validate does in pretraining (torchtitan/components/validator.py:73). If you pull it out, the schedule can be unit-tested without tasks, and it can move onto the Validator class from the L547 TODO unchanged:
def _should_validate(self, step: int) -> bool:
async_loop = self.config.async_loop
validation = async_loop.validation
# No validation starts at the last step: training ends right after.
if step >= async_loop.num_training_steps:
return False
if step == 0:
return validation.validate_at_step_0
return validation.freq is not None and step % validation.freq == 0The caller then becomes is_due = self._should_validate(step). The line count stays about the same.
| async_loop = self.config.async_loop | ||
| validation = async_loop.validation | ||
| if after_training: | ||
| if self._is_validation_due: |
There was a problem hiding this comment.
Re tianyu-l's "don't need this as a class variable": partly correct. At this line it is only used for logging, so L1042-1045 can be deleted. But the attribute itself is load-bearing at L1059 and L1067. It carries a validation that came due while another was running forward to the step where the running one ends. That carry-over is how defer_new_if_not_finished works.
Example: freq=25, and each validation takes 30 steps.
- With the attribute: due at 25, deferred, starts at 30 (matches the docstring Gantt in
ValidationConfig). - With only a per-step
is_due: at 30 nothing is due, so the step-25 validation is dropped and the next one starts at 50. Defer silently becomes skip, which is the oldskip_new_if_prev_not_finishedbehavior this PR replaced. The defer case intest_validation_schedulewould fail.
Some state across calls is unavoidable here. Any replacement (for example a "last due step" int) is the same thing under another name. So: keep _is_validation_due and delete the after-training log line.
There was a problem hiding this comment.
I see. I'm not against having a cross step flag / decision.
I just feel the current decision is confusing
- variable names are too similar and not precise, including is_due, is validation_due, is_deferred
- I still don't know what we do if validation takes more steps than validation frequency. It seems it won't be skipped ever? Then will we end up piling validation tasks infinitely?
| ) | ||
| async_loop = self.config.async_loop | ||
| validation = async_loop.validation | ||
| if after_training: |
There was a problem hiding this comment.
Re tianyu-l's "split the two workflows": correct, and small enough to do in this PR instead of leaving a TODO. The two branches share only the loop at the top that logs ended tasks. One branch awaits a blocking validation. The other only schedules a task and never awaits, so it doesn't need to be async:
def _log_ended_validations(self, step: int) -> None: ... # current L1028-1038
def _maybe_start_validation(self, step: int) -> None:
self._log_ended_validations(step)
is_due = self._should_validate(step)
... # current L1059-1074
async def _validate_after_training(self, step: int) -> None:
self._log_ended_validations(step)
if self.config.async_loop.validation.validate_after_training:
metrics = await self.validate(step=step)
self.metrics_processor.log(step=step, metrics=metrics, is_validation=True)This removes the after_training flag and the await at the two training-time call sites (run() start step and _trainer_loop L1393). It costs about the same number of lines. When the Validator class from the L547 TODO lands, these become its methods.
… and after-training methods (review)
|
Claude finished @felipemello1's task in 2m 19s —— View job Approve -- all three of tianyu-l's comments are resolved, with no new problems: review |
There was a problem hiding this comment.
Verdict: Approve -- a7980bc resolves all three of tianyu-l's comments and introduces no new problems. A maintainer still needs to review, since this changes the core RL controller, and tianyu-l's earlier change request still stands.
What this push does. It splits _maybe_run_validation(step, after_training=False) into four methods:
_should_validate(step): a pure check, mirroringcomponents/validator.py:73._log_ended_validations(step): shared by the two callers below._maybe_start_validation(step): sync, so it never waits.async _maybe_validate_after_training(step).
It also renames _is_validation_due to _has_pending_validation and is_deferred to must_wait, and deletes the after-training "came due but never started" log line. Behavior is unchanged.
Example. A call site in _trainer_loop, before and after:
await self._maybe_run_validation(step=step) # before: async, but this branch never awaited
self._maybe_start_validation(step=step) # after: sync, so the call site can't block training
Earlier items
- tianyu-l:
should_validate()-- resolved (controller.py:1018). The last-step rule still runs before the due/pending check (L1046), so a pending validation never starts at the last step either. - tianyu-l: the flag and its names -- resolved. The log line is gone and the state is named
_has_pending_validation/must_wait. The attribute stays, as it must, to carry a deferred validation across steps. - tianyu-l: split the two workflows -- resolved. No references to
_maybe_run_validation,after_training=,_is_validation_dueoris_deferredremain. The call-graph docstring (L885), the comment at L550,run()(L978, L1012),_trainer_loop(L1391) and both test files are updated. No caller stillawaits the sync method.
Should consider
controller.py:176-- on tianyu-l's pile-up question: pile-up only happens withdefer_new_if_not_finished=False, and no recipe sets that. Only the unit-test parametrization does. With the defaultTrue, at most one validation runs at a time. To remove the concern entirely, delete the flag and always defer (about 5 lines plus one test case), or name the user who needsFalse.- Still open:
search_r1.pyruns 500-prompt validations every 50 steps, and their step-time cost is unmeasured.
Questions
- Still open for tianyu-l from earlier reviews:
- Should a resumed run skip the validation at its start step?
- Should the trainer skip the final push and pull when
validate_after_trainingis off?
Not verified: GPU step time while a validation runs.
tianyu-l
left a comment
There was a problem hiding this comment.
finally I understood it!
| self._log_ended_validations(step=step) | ||
| if step >= self.config.async_loop.num_training_steps: | ||
| return | ||
| is_due = self._should_validate(step) |
There was a problem hiding this comment.
| is_due = self._should_validate(step) | |
| should_validate = self._should_validate(step) |
There was a problem hiding this comment.
Reply from claude: Done in 474428b: the local is should_validate now, at all 3 uses in _maybe_start_validation. RL CPU suite: 637 passed, 1 skipped.
|
Claude finished @felipemello1's task in 59s —— View job Approve: the push (a7980bc..474428b) only renames |
There was a problem hiding this comment.
Verdict: Approve -- the push (a7980bc..474428b) only renames a local variable, so behavior is unchanged.
What this push does. In Controller._maybe_start_validation (torchtitan/rl/controller/controller.py:1048-1057), the local is_due is now called should_validate, as tianyu-l suggested. All 3 uses were renamed, and no is_due is left in the file. No other file changed.
Example.
# before
is_due = self._should_validate(step)
self._has_pending_validation = self._has_pending_validation or is_due
# after
should_validate = self._should_validate(step)
self._has_pending_validation = self._has_pending_validation or should_validateStill open (from earlier reviews, not blocking)
defer_new_if_not_finished=Falselets validations pile up, and no recipe sets it.- search_r1 runs a 500-prompt validation every 50 steps, and the cost to step time hasn't been measured.
- Questions for tianyu-l: should a resumed run skip the validation at its start step? Should the trainer skip the final push/pull when
validate_after_trainingis off?
Not verified: GPU step time while a validation runs.
…er override; agent self-review; rl/transport (#6407) ## Summary (human-written) <!-- Write this yourself, not with an AI tool. 2-5 sentences: the problem, why this approach, and what you checked yourself. --> ## Why Since #5667, `@claude review` has reviewed 459 PRs. Of the 380 PRs it approved, 30 then got a formal "request changes" from a maintainer, and about 20 more got substantive inline asks. In nearly all of them the bot either saw the problem and approved anyway, or never asked the questions maintainers ask most ("does the repo already do this?", "who should own this?"). The opposite failure, the bot blocking something a maintainer was fine with, is rare: in the PRs we sampled, 2 of its 81 must-fix items were wrong and about a third were minor (the empty human-written summary was the biggest source). **Example** (#6112, controller sizes the rollout worker pool): ``` before: bot approved 10 times; tianyu-l then blocked: "the controller reads rollouter.rollouts_per_worker to compute a count it hands back to the Rollouter -- violates encapsulation" after: same commit, new skill -> Request changes, must-fix #1: "controller.py:589 -- wrong owner for the worker count ..." ``` There was also no way for a code owner to overrule the bot except dismissing its review in the GitHub UI, and a later `@claude review again` would block again. ## What changed **Review skill** (`.claude/skills/pr-review/`, `review-checklist.md`): - Verdict rules: Approve only when every remaining item is an edit the bot could write itself. Anything the author still owes (a design change, an unexplained golden change, evidence the PR rests on) is Request changes; anything only a maintainer can decide is Needs discussion. A hedge like "a maintainer should decide" can't come with Approve. - Always must-fix: a violated written rule, a silent wrong result, a second definition of an existing concept, a gate finding. - Design gate: new questions for the existing counterpart, in-repo ownership, and the design behind a bug; "ban only what doesn't work on main"; read the numbers behind a claim. The overlapping-PR search is mandatory and reported. - Re-review covers every commit since the last full review, including code taken from the bot's own suggestions. A scoped question gets a `COMMENT`, not a whole-PR verdict. - The bot fact-checks its own proposed fixes, and cites a source for claims about external tools or marks them unverified (never must-fix). - An empty "Summary (human-written)" is a one-line "Before merge" note that never affects the verdict. - Checklist: config ownership direction, general shared wrappers, dead code the PR creates, model variants as flavors, a mechanical pass over every new or changed function. **Code owner override** (`SKILL.md`, `claude-code.yml`, `CONTRIBUTING.md`): a code owner comments `@claude override` (optionally `@claude override 2,3: <reason>`); the bot approves if nothing else is open and doesn't re-raise the overridden items. A code owner's GitHub approval or "LGTM" is not an override, so a teammate can approve without the bot dropping its findings. Dismissing the bot's review still unblocks the PR, but isn't an override: the bot can't tell who dismissed it. **Agent self-review** (`CLAUDE.md`, `pr-description`): an agent preparing a PR runs `pr-review` in branch mode first and records unaddressed items in an optional "Self-review" section. PRs written without an agent are unaffected; a missing section is never a finding. Where each new rule comes from (maintainer asks the bot missed): | Change | PRs | | --- | --- | | No Approve with open design/evidence items or a "maintainer should decide" hedge | #6007, #5837, #5997, #5712, #5511, #5996 | | Author waiver can't clear a must-fix | #6201, #6202, #6203 | | Existing counterpart; one source of truth | #5228, #6169, #5881, #5823, #5824, #6059, #5812 | | Responsibility owner; config ownership direction | #6112, #6332, #5802, #5803, #6325 | | Fix the design behind the bug; a TODO doesn't justify a workaround | #5572, #5689, #5657 | | Fact-check the bot's own suggested fixes | #5740, #5802, #5511, #4819, #5543 | | Re-review covers all new commits; scoped asks don't approve | #5824, #5842 | | Mandatory overlap search | #5885, #6248 | | Ban only what doesn't work on main | #5543 | | Summary placeholder no longer a must-fix | #6119, #6174, #6112, #5868 | **Rules**: `design.md` gets the one-general-wrapper rule (moved from `models.md`, whose glob skipped `torchtitan/rl`), thin adapters, and the consumer owning its values; `config.md` gets ownership direction and "a Config doesn't read runtime state"; `direction.md` calls all-to-all the MoE reference implementation, so a new vendor-specific dispatch path (e.g. #6242) needs a reason the existing backends can't serve. **Area reviewers**: `.ci/` -> huydhn, wwwjn; `torchtitan/rl/transport/` -> d4l3k. **Mechanical, skim**: `torchtitan/rl/transport/` holds data movement between RL actors. - `rl/model_state_dict_transport.py` -> `rl/transport/model_state_dict.py` - `rl/MODEL_STATE_DICT_TRANSPORT.md` -> `rl/transport/MODEL_STATE_DICT_TRANSPORT.md` - `rl/trainer/rdma_microbatch.py` -> `rl/transport/rdma_microbatch.py` - tests: `tests/rl/unit_tests/cpu/test_{model_state_dict_transport,rdma_microbatch}.py` -> `tests/rl/unit_tests/cpu/transport/test_{model_state_dict,rdma_microbatch}.py` - imports, READMEs and `scripts/install_rl_env.sh` updated; no code changes. ## User-facing changes | Before | After | | --- | --- | | Overrule the bot: dismiss its review in the UI, and it blocks again on the next run | `@claude override [items]: <reason>`; the bot approves and doesn't re-raise them | | Empty human-written summary: bot must-fix | One "Before merge" line, no effect on the verdict | | `from torchtitan.rl.model_state_dict_transport import ...` | `from torchtitan.rl.transport.model_state_dict import ...` | | `from torchtitan.rl.trainer.rdma_microbatch import ...` | `from torchtitan.rl.transport.rdma_microbatch import ...` | ## Testing Backtest: the new skill run locally (nothing posted) on each PR at the commit and thread state the bot originally saw. | PR | Bot then | New skill | What the maintainer asked | | --- | --- | --- | --- | | #6112 | Approve | Request changes | worker-count ownership (caught) | | #5837 | Approve | Request changes | apply to `dp_shard` too (caught) | | #5572 | Approve | Request changes | delete the injection design (caught) | | #6201 | Approve after author waived pins | Request changes, waiver ignored | pins broke GPU tests after merge (caught) | | #6007 | Approve | Request changes | fold K3.1 into K3 (caught) | | #5543 | Request changes: "ban it" | Request changes: keep main's path | don't break gpt-oss + DeepEP (fixed) | | #6144, #5905 (controls) | Approve | Approve | -- | | #6137 (control) | Approve | Needs discussion | -- (merge gate on an upstream API) | Code owner override, simulated on #6201: override by a code owner lifts the named item; `@claude override` from the author changes nothing; a code owner's "LGTM" approval followed by "review again" keeps Request changes. Transport move: 83 RL CPU unit tests pass locally (`transport/test_model_state_dict.py`, `test_trainer.py`, `test_engine_loop.py`). `transport/test_rdma_microbatch.py`, `test_generator.py` and `test_batcher_actor.py` fail to collect in my env on `origin/main` too (stale attention-gym / Monarch), so CI is the check for those. ## Known issues / follow-ups - Open PRs that edit the moved files rebase cleanly (git follows the renames), but new imports of the old module paths will break: #6309 (adds a delta transport that should live in `rl/transport/`), #6237, #6176, #6177, #5862, and drafts #6127, #6393, #6163, #5764. - The Actions bot can't read dependency source (e.g. SGLang); follow-up for the workflow. ## Self-review pr-review (branch mode) at ad905a5: Needs discussion. Fixed: branch mode diffs against `origin/main` and skips description findings before a description exists; the "Config doesn't read runtime state" rule no longer contradicts hardware validation; dismissal dropped as an override form (the bot can't tell who dismissed); `test_rdma_microbatch.py` added to the transport area. Not addressed: - One concern per PR -- the five changes ship together at the maintainer's request. - Open PRs touching the moved files -- listed above; the maintainer will coordinate.
Summary (human-written)
Agent details
TLDR: Validation now runs beside training. The trainer loop never awaits it.
_maybe_start_validation(step)starts each due validation (step 0, everyfreqsteps) as a task and logs each one at the step it ends;_maybe_validate_after_trainingruns the optional one at the end. A newfreqadds a validation every N steps.Problem
Controller.runawaits a validation before the first step and another after the last one. Training waits for both. Periodic validation is a TODO on main.Solution
ValidationConfigkeepssteps(prompts per validation) and adds when validations run:freq,validate_at_step_0=True,validate_after_training=Falseanddefer_new_if_not_finished=True.Controller._maybe_start_validationruns at the start step and after each step's metrics, and never waits: it logs the validations that ended (_log_ended_validations), then starts a due validation (_should_validate) as an asyncio task._maybe_validate_after_trainingruns once after training: it logs the ones that ended, then runs and awaits thevalidate_after_trainingone. Each row also logsvalidation/started_at_step: in the image, the validation due at 50 starts at 60 and is logged at 90.validate_at_step_0. Turn it off when you already know that score.freq. A run resumed at step 25 withfreq=25runs a validation at 25; one resumed at 13 runs its first validation at 25. No validation starts at the last step.validate_after_training.defer_new_if_not_finished(an INFO line says so), else it starts too. With the default, at most one runs: freq=10 and validations of 30 steps start at 0, 30, 60._log_ended_validations, so the run fails. A failed group still only counts invalidation/group_failures.run()'sfinallycancels the validations still running. They are never logged, and an INFO line names each one._maybe_validate_after_trainingthen logs every validation that ended, also one that ended while thefinallyclosed the buffer.asyncio.to_thread), since training runs meanwhile._log_reward_delta(the console's pre/post reward lines) is deleted. W&B and TensorBoard get every validation key, rewards included. The console's default validation keys (validation/reward/*,MetricsProcessor.Config) don't matchvalidation_reward/*, so the console prints no validation reward until a separate open PR fixes those defaults.validate()and_collect_validation_rollouts, the metric keysvalidation_reward/*,validation_generator/*andtiming/validate, and validation's priority -1 in vLLM.What changes for existing recipes
freq; main always did. The in-repo recipes that setfreqcheckpoint at multiples of it, so their resumes still run that validation (see "You may ask"). No validation runs after training unlessvalidate_after_training=True; main always ran one.freq=25, search_r1freq=50. Terminal-Bench keeps only the step-0 validation.rl_grpo_qwen3_30b_a3b_deepep_search_r1_perf,rl_grpo_qwen3_30b_a3b_varlen_perf,rl_grpo_qwen3_6_27b_varlen_perf) validate only after training (validate_at_step_0=False, validate_after_training=True), so no validation runs beside the steps they time.validation_:generator/*->validation_generator/*(as on main), and a rubric'smath_verify/timeouts->validation_math_verify/timeouts. So a validation no longer writes to the training chart of the same key.rl_grpo_fsdp2_gen_tp2_no_compilesetsfreq=2, validate_after_training=True.Results
At 0cd2374 (later commits rename words in comments, logs and tests, add a TODO, add the
validation/started_at_stepkey, split the scheduling method, drop the end-of-run "came due but never started" line and merge main), 2 GPUs (trainer TP1 + generator TP1), Qwen3-0.6B alphabet sort, 5 steps, 20 prompts per validation,freq=2,validate_after_training=True(the CI job's validation settings). The run exits 0 in about 2 min.The default path (no validation after training) is covered by the CPU tests only.
The runs below used an earlier head of this PR. The schedule they show is the same here.
W&B e1l8kfrk. The same smoke on the base branch, whose validations block training (W&B 8gfrv6wl):
Step time while a validation runs: a 50-step, 4-GPU Qwen3.5-4B DAPO Math run of the same schedule (another draft that moves it into its own class) had a median step of 38.1 s on the 9 steps that overlapped a 30-prompt validation vs 36.3 s on the 39 steps that did not (+5%, W&B uzprmn9a).
You may ask:
validate_after_trainingscores the final one._should_validate? It must also stop a validation that came due earlier and still waits, so it sits in_maybe_start_validation.torchtitan/trainer.py:546), so it never validates the step it loads. Here that step's validation ran beside later steps, so a crash may have cut it off, and its score would be lost. Skipping the resume step is ~2 lines.validate_after_trainingtoo, so they stay as on main.NOTE:
max_concurrent_rollouts) for training rollouts only, so the 89-task start validation waits in that queue. Time there does not count against the rollout timeout: Verifiers 0.4.0 takes the server's slot before the episode timeout starts (verifiers/v1/env.py:336vs:261).close()if the rollouter shields them (the base Rollouter does,rollout/rollouter.py:266), and a validation after training waits behind them. The Verifiers rollouter cancels its env-server episodes instead. TODO at the cancel site.validate_after_training=True, a validation that ends during the last step is also logged at step N, just before the validation after training (two step-5 rows in the run above).validation/started_at_steptells them apart: N for the one after training, smaller for the other.Follow up
Validatorclass, like pretraining's (TODO inController.__init__).validate()).run()).run()).VLLMEngine)._trainer_loop).Test plan
New and changed tests (each fails when its rule is broken on purpose):
test_async_controller.py::test_validation_schedule(5 cases:defer_new_if_not_finishedon and off,validate_at_step_0off, a run resumed at step 2 (a multiple offreq) and at step 3)test_async_controller.py::test_run_ends_validation(5 cases: the start validation ends before training does, or while run()'sfinallycloses the buffer, and is logged; it is still running and is cancelled; then the validation after training runs; it failed, and run() raises its error)test_async_controller.py::test_validation_renames_turn_metrics_and_uses_fresh_group_ids(a rubric's key getsvalidation_, and two validations never share a group id)test_trainer_loop.py::test_failed_validation_fails_training