Skip to content

[rl] Periodic validation beside training - #5228

Merged
felipemello1 merged 14 commits into
mainfrom
felipemello1/overlap-validation/2-overlap-validation
Nov 10, 2026
Merged

felipemello1 merged 14 commits into
mainfrom
felipemello1/overlap-validation/2-overlap-validation

Conversation

@felipemello1

@felipemello1 felipemello1 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary (human-written)

  1. Vaiidatiion is currently a mess. We need to remove it from the controller and make it its own actor
  2. This PR wants to focus on one thing only: allow generation to run besides training, as a way to gather signal without having to worry about loading ckpts in some other job
  3. currently we support validation on start and end. This is very wasteful, because training doesnt start (or end) until validation finishes. For terminal bench, this is >1h each.
  4. So now validation is non blocking. Follow up PR should think about a proper design to make some Validator config, that users can easily swap.

Agent details

TLDR: Validation now runs beside training. The trainer loop never awaits it. _maybe_start_validation(step) starts each due validation (step 0, every freq steps) as a task and logs each one at the step it ends; _maybe_validate_after_training runs the optional one at the end. A new freq adds a validation every N steps.

main awaits a validation before step 1 and after the last step; this PR runs each due validation beside training, logs it at the step it ends (due at 50, logged at 90), and cancels one still running when training ends

Problem

  1. Controller.run awaits a validation before the first step and another after the last one. Training waits for both. Periodic validation is a TODO on main.
  2. On Terminal-Bench 2.1, a validation is 89 tasks of up to 120 agent turns. On a 35B-A3B run, no training step had started ~1 h 45 min after launch.
  3. The validation after training keeps the trainer GPUs idle. In a 2-GPU Qwen3.5-4B smoke, it took 132.8 s for 16 prompts (W&B 8gfrv6wl).

Solution

  1. ValidationConfig keeps steps (prompts per validation) and adds when validations run: freq, validate_at_step_0=True, validate_after_training=False and defer_new_if_not_finished=True.
  2. Controller._maybe_start_validation runs 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_training runs once after training: it logs the ones that ended, then runs and awaits the validate_after_training one. Each row also logs validation/started_at_step: in the image, the validation due at 50 starts at 60 and is logged at 90.
  3. When a validation is due:
    • step 0: if validate_at_step_0. Turn it off when you already know that score.
    • other steps, a resumed run's first step included: at each multiple of freq. A run resumed at step 25 with freq=25 runs a validation at 25; one resumed at 13 runs its first validation at 25. No validation starts at the last step.
    • after training: if validate_after_training.
    • a validation is running: a due validation waits for it if 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.
  4. A failed validation raises from the next _log_ended_validations, so the run fails. A failed group still only counts in validation/group_failures.
  5. run()'s finally cancels the validations still running. They are never logged, and an INFO line names each one. _maybe_validate_after_training then logs every validation that ended, also one that ended while the finally closed the buffer.
  6. Validation group ids come from one counter that counts down from -1. Training ids count up from 0, so the two never share an id. Validations that run at the same time never share one either.
  7. The prompts are built off the event loop (asyncio.to_thread), since training runs meanwhile.
  8. _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 match validation_reward/*, so the console prints no validation reward until a separate open PR fixes those defaults.
  9. Unchanged: the signatures of validate() and _collect_validation_rollouts, the metric keys validation_reward/*, validation_generator/* and timing/validate, and validation's priority -1 in vLLM.

What changes for existing recipes

  • Every recipe with validation gets one at step 0, beside training. A resumed run validates at its first step only if that step is a multiple of freq; main always did. The in-repo recipes that set freq checkpoint at multiples of it, so their resumes still run that validation (see "You may ask"). No validation runs after training unless validate_after_training=True; main always ran one.
  • dapo_math and verifiers_dapo_math add freq=25, search_r1 freq=50. Terminal-Bench keeps only the step-0 validation.
  • The 3 perf recipes (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.
  • The generators serve validation requests first (priority -1), so steps slow down while a validation runs (Results).
  • A validation's score can span several policies: the weights change while it runs.
  • Validation prefixes every turn metric with validation_: generator/* -> validation_generator/* (as on main), and a rubric's math_verify/timeouts -> validation_math_verify/timeouts. So a validation no longer writes to the training chart of the same key.
  • CI: rl_grpo_fsdp2_gen_tp2_no_compile sets freq=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_step key, 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.

validation        started at  logged at  timing/validate  validation_reward/_mean
start (due at 0)  step 0      step 1     3.12 s           0.19
due at 2          step 2      step 5     3.62 s           0.20
due at 4          -           -          waited for the validation above (INFO line); at the end: "came due but never started: training ended first"
after training    step 5      step 5     3.17 s           0.28

keys in each validation row: 16 validation_generator/*, 13 validation/* (+1 at head: validation/started_at_step), 6 validation_reward*, 0 validation/generator/*
0 "Task exception was never retrieved", 0 tracebacks

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.

2 GPUs (1 trainer, 1 generator), Qwen3.5-4B-Base DAPO Math, 3 steps, 16 AIME 2025 prompts per validation,
freq=1, a validation at step 0, validate_after_training=True. W&B rows read through the API.

validation        started at  logged at  validation_reward/_mean  timing/validate  group_failures
start (due at 0)  step 0      step 1     0.1875 (3/16)            280.1 s          0
due at 1          step 1      -          cancelled: still running when training ended
due at 2          -           -          waited for the validation above (INFO line), then dropped
after training    step 3      step 3     0.1875 (3/16)            141.9 s          0

W&B e1l8kfrk. The same smoke on the base branch, whose validations block training (W&B 8gfrv6wl):

timing/step/total/mean   step 1    step 2   step 3
base (blocking)          231.8 s   79.6 s   145.0 s   plus an 18.1 s validation before step 1 and a 132.8 s validation after step 3
this PR                  363.1 s   50.8 s   74.8 s    the start validation ran beside step 1; the one started at 1 beside steps 2-3
  • Step 1 is the cold start. The start validation's requests went first (priority -1), so step 1 waited 280.6 s for its batch vs 173.7 s on the base.
  • Steps 2-3 ran beside a validation and were not slower. One run of 3 steps is noisy.

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:

  • Why cancel a validation still running at the end instead of waiting for it? Waiting keeps every GPU idle to score an older policy. validate_after_training scores the final one.
  • Why not give a validation fewer generator slots? It still starts all its prompts at once, as on main. Reading prompts as slots free up is a follow-up (below).
  • Why isn't the last-step rule in _should_validate? It must also stop a validation that came due earlier and still waits, so it sits in _maybe_start_validation.
  • Why does a resumed run still validate at its first step? Pretraining checks only after steps it trains (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.
  • Why still push and pull the last step's weights when no validation follows? Only the validation after training reads them. Skipping them would make the trainer loop read validate_after_training too, so they stay as on main.

NOTE:

  • Terminal-Bench sizes its env server (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:336 vs :261).
  • A cancelled validation loses its result, and its groups stay pinned in the generators. Its rollouts keep running until 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.
  • With 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_step tells them apart: N for the one after training, smaller for the other.
  • After a resume at exactly the last step, no start validation runs.
  • Open drafts that change validation in the controller need a rebase after this lands.

Follow up

  • Move validation into a Validator class, like pretraining's (TODO in Controller.__init__).
  • Read prompts as slots free up, which also bounds the slots a validation takes in the generators and in a rollouter's own limit (TODO in validate()).
  • Abort a cancelled validation's rollouts and release its groups (TODO in run()).
  • On resume, restart the validation the previous run left running (TODO in run()).
  • Measure the step-time cost of priority -1 for a long validation; consider a priority between training groups (TODO in VLLMEngine).
  • If the trainer loop raises (e.g. a failed push, forward/backward, optimizer step or validation), cancel or await the push and pull still in flight. Today they keep running during teardown (TODO in _trainer_loop).

Test plan

python -m pytest tests/rl/unit_tests/cpu -q -p no:cacheprovider
    # 581 passed, 7 skipped (main: 570 passed, 7 skipped)
python -m pytest -q -p no:cacheprovider tests/rl/unit_tests/cpu/test_verifiers.py \
    tests/rl/unit_tests/cpu/test_verifiers_example.py tests/rl/unit_tests/cpu/test_verifiers_terminal_bench.py \
    tests/rl/unit_tests/cpu/test_verifiers_terminal_bench_prepare_tmax.py tests/rl/unit_tests/cpu/test_model_defaults.py
    # in a venv with verifiers: 61 passed (main: 61 passed)
pre-commit run --files <the 11 changed files>
    # every hook passes except pyrefly, which fails the same way on main
pyrefly check
    # 2 errors, the same 2 on main: torchtitan/distributed/fsdp.py:593, torchtitan/models/common/attention/gdn.py:139

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_finished on and off, validate_at_step_0 off, a run resumed at step 2 (a multiple of freq) and at step 3)
  • test_async_controller.py::test_run_ends_validation (5 cases: the start validation ends before training does, or while run()'s finally closes 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 gets validation_, and two validations never share a group id)
  • test_trainer_loop.py::test_failed_validation_fails_training

@pytorch-bot pytorch-bot Bot added the ciflow/rl label Oct 9, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 9, 2026
@felipemello1
felipemello1 added this pull request to stack #5229 October 9, 2026 16:22
@felipemello1
felipemello1 force-pushed the felipemello1/overlap-validation/2-overlap-validation branch from 659a06b to 10f5b69 Compare October 11, 2026 19:28
@felipemello1
felipemello1 force-pushed the felipemello1/overlap-validation/2-overlap-validation branch from 571b6df to 0b9db7c Compare November 2, 2026 20:56
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: Rebased on main and the W&B fix below it. Changes since the last head:

  • Ported to main's generator split: the overlapped-validation group-id threshold lives in generator/types.py, and the id-to-priority mapping is private to generator/vllm/engine.py.
  • In overlap mode the validation task now waits for its step's weight pull itself, so the trainer doesn't stall on validation steps; blocking mode keeps the wait (now traced).
  • ValidationConfig rejects freq with steps=0; the CI config rl_grpo_fsdp2_gen_tp2_no_compile turns on ValidationConfig(steps=20, freq=2, overlap_training=True) (added ciflow/rl to run it).
    RL CPU tests: 515 passed / 9 skipped. Not run yet on GPU: the 2-GPU smoke and the 8-GPU CI config (CI runs the latter).

@claude please review

@claude

claude Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

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

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. The PR description's "Summary (human-written)" is empty. The author needs to fill it in (see CONTRIBUTING.md, "AI-assisted contributions").
  2. torchtitan/rl/controller/controller.py:1070 -- a failed overlapped pass is logged, then ignored. Prompt-level errors are already counted in validation/group_failures, so what reaches this branch is infrastructure failure, for example release_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 lets validation/pass_failures and two tests go.

Should consider

  • controller.py:171 -- also reject overlap_training=True with steps=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 _controller from another test module. test_blocking_validation_failure_stops_training adds 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 the ValidationConfig docstring.
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 overlapping and the engine's TODO: 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_task the next step awaits; there is no deadlock, and a failed pull fails both.
    • close() cancelling the pass also cancels after, as the comment says.
    • pre_validation_task is always done before .exception() is called. It is either logged in the loop or awaited as self._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_seqs sum branch applies only when freq is 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.

Comment thread torchtitan/rl/controller/controller.py Resolved
Comment thread torchtitan/rl/controller/controller.py Resolved
Comment thread torchtitan/rl/generator/vllm/engine.py Resolved
@felipemello1
felipemello1 force-pushed the felipemello1/overlap-validation/2-overlap-validation branch from 0b9db7c to 122b437 Compare November 2, 2026 21:10
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: Addressed the 21:02 review in 122b437 (rebased on the new 1/2): a failed overlapped pass raises; overlap_training with steps=0 raises; a pass with 1M+ prompts raises in setup_async; the test helper is public; the N+1 W&B case is documented in ValidationConfig. RL CPU tests: 513 passed / 9 skipped.

@claude please review

@claude

claude Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

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

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_validation calls task.result() (controller.py:1074), pass_failures is gone, and run() reads .result().
  • overlap_training with steps=0: resolved (controller.py:639).
  • Magic id range with 1M+ blocking prompts: resolved by the setup_async ValueError (controller.py:690). The dataset size is only known there, so this is the earliest place it can be checked.
  • Private _controller import, plus the low-value blocking-failure test: resolved.
  • W&B N+1 question: answered. The accepted cost is documented in the ValidationConfig docstring.

Must fix

  1. 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 and pre_validation_task.result() run after the finally that cancels the loops. A pass error there propagates out of run(), and close() then cancels nothing (_validation_task is 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's newest > oldest check 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.

@felipemello1

Copy link
Copy Markdown
Contributor Author

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 validation/reward/_mean, but the metric is validation_reward, so the reward never printed. That fix is now in this PR (5406757). The two PRs edit the same lines, so whichever lands second rebases.

@felipemello1

Copy link
Copy Markdown
Contributor Author

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: max_num_seqs = min(rollout_concurrency, 512) still gets this PR's sum of training and validation rollouts. The body's NOTE now names the 512 cap.

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: rl_grpo_fsdp2_gen_tp2_no_compile started passes at 0, 2, 4, logged them at 1, 4, 5, and logged the final pass at 6. Lint and every RL job pass. RL CPU: 553 passed, 8 skipped (main: 544 passed, 8 skipped).

@claude please review

@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

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

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_validation now names validation_reward/_mean and validation_reward/_max, the keys compute_rollout_metrics actually 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 computes rollout_concurrency as training + validation when freq or overlap_training is 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

  1. 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 across max_num_seqs requests, and a dummy request with 65 or more tokens reaches the bug. This PR raises max_num_seqs only for configs that set freq or overlap_training. In-repo, that is only rl_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_validation calls task.result()); steps=0 with freq or overlap_training raises; setup_async rejects 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.

@felipemello1
felipemello1 removed this pull request from stack #5229 November 6, 2026 06:19
@felipemello1
felipemello1 changed the base branch from felipemello1/overlap-validation/1-wandb-commit to main November 6, 2026 06:19
@felipemello1
felipemello1 force-pushed the felipemello1/overlap-validation/2-overlap-validation branch from 1f32017 to eaf27ff Compare November 6, 2026 06:20
@felipemello1 felipemello1 changed the title [rl] Periodic validation, optionally overlapped with training (2/2) [rl] Periodic validation, optionally overlapped with training Nov 6, 2026
Comment on lines +85 to +88
"validation_reward/_mean",
"validation_reward/_max",
"validation/response_length/mean",
"timing/validate",
"timing/validation/",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were the reward variable names changed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reply from claude: Dropped this change from the PR. The same fix is open in #4938, #5473 and #5649, so it lands with one of those.

Comment thread torchtitan/rl/generator/types.py Outdated
Comment on lines +63 to +65
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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is very clear.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread torchtitan/rl/generator/types.py Outdated


# Overlapped validation group ids count down from here; the engine schedules them after all training.
OVERLAPPED_VALIDATION_FIRST_GROUP_ID = -1_000_000

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we have over 1 million validation samples over the course of training?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread torchtitan/rl/controller/controller.py Outdated
Comment on lines +146 to +155
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.
"""

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example here could have just been a diagram, like a Gantt diagram. There's no need for all those words.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread torchtitan/rl/controller/controller.py Outdated
Comment on lines +149 to +151
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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread torchtitan/rl/controller/controller.py Outdated
Comment on lines +164 to +165
overlap_training: bool = False
"""False: training waits for each pass, so all its rollouts sample one policy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it obvious that this is a blocking call.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reply from claude: The blocking mode is gone (overlap_training removed): training never waits for a pass.

Comment thread torchtitan/rl/controller/controller.py Outdated
Comment on lines +166 to +169
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."""

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread torchtitan/rl/controller/controller.py Outdated
Comment on lines +644 to +650
# 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."
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment thread torchtitan/rl/controller/controller.py Outdated
Comment on lines +913 to +918
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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread torchtitan/rl/controller/controller.py Outdated
Comment on lines +1428 to +1454
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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the trainer loop function's changes: these look like too much. I'm sure it can be simpler than this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@felipemello1

Copy link
Copy Markdown
Contributor Author

@claude review

@claude

claude Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

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

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. The PR description's "Summary (human-written)" is still empty (CONTRIBUTING.md, "AI-assisted contributions").
  2. 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_metrics emits f"{prefix}_reward" (controller/metrics.py:279), so the keys are validation_reward/_mean, and every recipe already uses those names. It's a drive-by fix, but this PR has to edit that list anyway for timing/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_async checks 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_async check and the two-range docs, but it needs a flag threaded the way max_num_seqs is (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 than freq steps, training stalls; that tells the user to lower freq. 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.
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.

@felipemello1 felipemello1 changed the title [rl] Periodic validation, optionally overlapped with training [rl] Periodic validation beside training Nov 6, 2026
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: requesting a review of the updated draft.

@claude please review

@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review. This push (83e5108..0cd2374, 7 commits) addresses tianyu-l's 7 comments; each thread has a reply naming its commit.

@claude

claude Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

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).

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Validator naming in the TODO: resolved.
  2. Why ids count down from -1: resolved (comment names request-id and cache-salt collisions).
  3. One relabel rule: resolved. Checked against metrics.py: turn metrics arrive unprefixed.
  4. Resume reruns a pass: partly addressed (see Questions).
  5. Fold validate_after_training into _maybe_run_validation: resolved by the after_training kwarg.
  6. Final push/pull when validate_after_training is off: answered; the author offered a ~2-line skip.
  7. 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.py covers 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 skip step == start_step when start_step > 0 (~2 lines)?
  • tianyu-l: do you want the ~2-line skip of the final push/pull when validate_after_training is off?
Details

Traced at HEAD:

  • Steps passed to _maybe_run_validation only 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_training covers this.
  • Cancelled tasks are skipped with an INFO line.
  • The defer logic matches the docstring diagram.
  • Resume at num_training_steps starts 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.

Comment thread torchtitan/rl/controller/controller.py Outdated
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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets make it explicit that negative IDs prioritize eval requests over training requests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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."

Comment on lines +1029 to +1031
self.metrics_processor.log(
step=step, metrics=task.result(), is_validation=True
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread torchtitan/rl/controller/controller.py Outdated
Comment on lines +1035 to +1038
if self._is_validation_due:
logger.info(
"A validation pass came due but never started: training ended first"
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens in this case? Will we log, on the same step, both this ongoing and the final one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread torchtitan/rl/controller/controller.py Outdated
)

# 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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont like too much this wording "pass". Can we rename it throughout the pr?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread torchtitan_recipes/rl/alphabet_sort.py Outdated
Comment on lines +959 to +964
# 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,
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this "dataclasses.replace" looks a bit odd. We dont do that for other configs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = True

Each 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.

Felipe Mello added 2 commits November 9, 2026 13:11
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review. This push (ca7bd49..0d8c9b0) merges main and addresses felipemello1's 5 comments from today; each thread has a reply.

@claude

claude Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

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

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_tasks comment 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 5228 now has no added line containing "pass" or "passes". The test parameter rename (start_pass -> step_0_validation, metric keys pass_N -> started_N) is mechanical.
  • alphabet_sort.py:672-674, 956-958: plain attribute assignment instead of dataclasses.replace. I checked that this is safe: both base builders (rl_grpo_qwen3_30b_a3b_varlen, rl_grpo_qwen3_5_9b_varlen) construct a fresh ValidationConfig(steps=20) on each call, and ValidationConfig is 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_training docstring describe.
  • The merge from main brings in #5886 (local_compile on DAPOLoss), 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 skip step == start_step when start_step > 0 (~2 lines)?
  • Should the trainer skip the final push and pull when validate_after_training is 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 in vllm/engine.py tracks 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.

@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review. This push (0d8c9b0..240e435) adds a validation/started_at_step key to each validation row, as asked on the L1034 thread.

@claude

claude Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 1m 4s —— View job


Approve: the new validation/started_at_step key at 240e435 is correct and introduces no new problems; tianyu-l's change request still stands. Review

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.reduce raises if it gets more than one entry per key (observability/metrics/types.py:384). Each validation row is its own metrics_processor.log call, and validate() appends the key once, so it gets exactly one entry. This is the same pattern timing/validate already uses.
  • step is 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), or num_training_steps for 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 == 0 returns [] 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_training is 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.

Comment thread torchtitan/rl/controller/controller.py Outdated
step=step, metrics=metrics, is_validation=True
)
return
# No validation starts at the last step: training ends right after.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread torchtitan/rl/controller/controller.py Outdated
async_loop = self.config.async_loop
validation = async_loop.validation
if after_training:
if self._is_validation_due:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this as class variable -- here it's just logging, which can be worked around?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment thread torchtitan/rl/controller/controller.py Outdated
)
async_loop = self.config.async_loop
validation = async_loop.validation
if after_training:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 by run() 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.

@tianyu-l

tianyu-l commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

@claude review my review

@claude

claude Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 3m 4s —— View job


Approve -- please address the items before merging (tianyu-l's should_validate() and split comments are correct; _is_validation_due must stay for defer carry-over, only the log line goes): review --

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. controller.py:1052 -- should_validate(): correct. Extract a pure _should_validate(step) -> bool that mirrors components/validator.py:73 (sketch inline).
  2. controller.py:1042 -- _is_validation_due not 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).
  3. 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 an async _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_loop L1393, 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_training is off?

Not verified: GPU step time while a validation runs (for example the 500-prompt validations every 50 steps in search_r1).

Comment thread torchtitan/rl/controller/controller.py Outdated
step=step, metrics=metrics, is_validation=True
)
return
# No validation starts at the last step: training ends right after.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 == 0

The caller then becomes is_due = self._should_validate(step). The line count stays about the same.

Comment thread torchtitan/rl/controller/controller.py Outdated
async_loop = self.config.async_loop
validation = async_loop.validation
if after_training:
if self._is_validation_due:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 old skip_new_if_prev_not_finished behavior this PR replaced. The defer case in test_validation_schedule would 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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread torchtitan/rl/controller/controller.py Outdated
)
async_loop = self.config.async_loop
validation = async_loop.validation
if after_training:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review. This push (240e435..a7980bc) addresses tianyu-l's 3 comments from today (should_validate, the flag and its names, the split); each thread has a reply.

@claude

claude Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

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

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, mirroring components/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_due or is_deferred remain. The call-graph docstring (L885), the comment at L550, run() (L978, L1012), _trainer_loop (L1391) and both test files are updated. No caller still awaits the sync method.

Should consider

  • controller.py:176 -- on tianyu-l's pile-up question: pile-up only happens with defer_new_if_not_finished=False, and no recipe sets that. Only the unit-test parametrization does. With the default True, 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 needs False.
  • Still open: search_r1.py runs 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_training is off?

Not verified: GPU step time while a validation runs.

@tianyu-l tianyu-l left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

finally I understood it!

Comment thread torchtitan/rl/controller/controller.py Outdated
self._log_ended_validations(step=step)
if step >= self.config.async_loop.num_training_steps:
return
is_due = self._should_validate(step)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
is_due = self._should_validate(step)
should_validate = self._should_validate(step)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review. This push (a7980bc..474428b) renames the local is_due to should_validate, as tianyu-l suggested.

@claude

claude Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 59s —— View job


Approve: the push (a7980bc..474428b) only renames is_due to should_validate, and behavior is unchanged. See the review.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_validate

Still open (from earlier reviews, not blocking)

  • defer_new_if_not_finished=False lets 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_training is off?

Not verified: GPU step time while a validation runs.

@felipemello1
felipemello1 merged commit a144a4e into main Nov 10, 2026
tianyu-l added a commit that referenced this pull request Nov 26, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rl CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants