Skip to content

[WIP] [rl] Rollout workers compute and record each group's rollouts - #6301

Open
wwwjn wants to merge 3 commits into
wwwjn/rl-rdma-objectfrom
wwwjn/data-plane/2-slim-group
Open

wwwjn wants to merge 3 commits into
wwwjn/rl-rdma-objectfrom
wwwjn/data-plane/2-slim-group

Conversation

@wwwjn

@wwwjn wwwjn commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Human note:

  • This PR moves metrics of each rollout from controller to rollout workers.
  • This makes controller don't need to access the actual data of each rollout, build the foundation of bypassing controller read the actual data/rollout content
6301_hops > from claude: the image predates 6e2d4ba, where recording moved into the workers too.

TLDR: Each rollout worker computes its groups' rollout metrics and records them to its own rollout_samples.rank_<N>.jsonl; the controller no longer encodes or writes rollouts. This lets #6303 keep the arrays off the controller. At T1 the recorder's encode (127-132 ms per step) leaves the controller's event loop and controller CPU per step drops 2-3%.

# PR Independent? Needs
0 RDMA object for microbatches and prompts (#5862) yes -
1 Rollout workers compute and record each group's rollouts (#6301, this PR) yes - (stacked on 0 for merge order only)
2 Split the batcher into a metadata half and a bytes half (#6302) yes 0 (its batcher code)
3 Trainer DP replica leaders read their rollouts from the rollout workers and pack them (#6303) no 1, 2
4 Read the next step's rollout groups during the optimizer step (#6324) no 3
5 Trainer leaders read large rollout groups by RDMA over torch transport (#6469) no 3 (stacked on 4 for merge order only)
6 Prompt image files share the rollout worker's torch transport pool (#6334) no 5

Merge bottom-up. T1 numbers include #6269 (on main) on both sides.

Problem

  1. The controller runs compute_rollout_metrics and the recorder's encode and write on its event loop, for training and validation.
  2. Both read the group's arrays.
  3. [WIP] [rl] Trainer DP replica leaders read their rollouts from the rollout workers and pack them #6303 leaves the controller only each group's metadata and a ref.
  4. Cost: at T1 the recorder's encode alone is 127-132 ms per step on the controller.

Solution

  1. BaseRolloutWorker.run_and_record_group (rollout/rollouter.py) runs run_group, adds compute_rollout_metrics to group.metrics and records the group. The Monarch actor only calls it.
  2. Each worker builds its own RolloutSampleRecorder in setup_async (start_recorder) from BaseRolloutWorker.Config.recorder and dump_folder, writing rollout_samples.rank_<N>.jsonl. The controller config no longer has rollout_recorder. Rollouter.close closes the recorders before stopping the workers.
  3. The controller builds no recorder. run_group_rollouts takes is_validation (each JSONL line carries it).
  4. compute_rollout_metrics moves from controller/metrics.py to rollout/metrics.py, next to its only caller.
  5. validation/* metrics are now per group, merged when logged: equal up to float summation order. Metric names are unchanged.
before: worker --group--> controller: metrics + encode + write --group--> batcher
after:  worker: metrics + encode + write --group--> controller --group--> batcher

Results

T1: Qwen3-0.6B alphabet sort, 256 prompts x 4, 4 A100s per run, medians steps 4-12; #5862 -> this PR (swapped pair)
measured on the previous revision (encode in the workers, write still on the controller)
  recorder encode (ms/step)    127 / 132 on controller -> 127 / 129 summed over workers
  controller CPU per step (s)  6.04 -> 5.85; 6.03 -> 5.90
  controller GC per step (ms)  272 -> 333; 307 -> 385
  batcher_add_group (ms/call)  5.7 -> 5.4; 5.3 -> 5.7
  trainer batch wait (ms)      10.2 -> 10.3; 11.2 -> 10.7
correctness on this head (6e2d4ba08) vs #5862 (04a45a450): rl_grpo_qwen3_0_6b_varlen_batch_invariant, seed 42,
deterministic, 10 steps, trainer TP 2 + generator TP 2, plus one validation (8 prompts x 2) after training
  TensorBoard: 92/92 shared non-timing tags equal at every step, including the 47 validation tags
  recorded rollouts: the same 184 lines (168 training, 16 validation), as a set; order differs

NOTE:

Test plan

  • pytest tests/rl/unit_tests/cpu: 778 passed, 8 skipped, 4 failed. The 4 also fail on main locally: a torch_checkpointing.storage.fsspec_storage import error.
  • test_verifiers.py with Verifiers installed: 65 passed.
  • test_run_and_record_group.py: the worker adds the rollout metrics and records the group (training and validation); per-group validation metrics merge to the whole-batch values.

@wwwjn

wwwjn commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

@claude review

@claude

claude Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @wwwjn's task in 2m 48s —— View job


Approve -- please address the items below before merging (the human-written summary is still a placeholder). 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 -- please address the items below before merging. The fields this PR drops are read only by worker-side scoring and controller-side logging, the training sample builder's equivalence is now tested, and the remaining items are small edits. A maintainer still needs to review.

What this PR does. RolloutWorkerActor.run_group now finishes training groups itself. It computes rollout/* metrics with compute_rollout_metrics, encodes the recorder's JSONL lines with the new RolloutSampleEncoder, then returns a slim copy of the group. The slim copy has no messages, env_rewards, per-turn metrics, reward_breakdown or logs, and keeps one bytes object per image hash. The controller appends the lines and hands the slim group to the work buffer. Validation passes for_training=False and works as before.

Example. One training group, G=8, every rollout carrying a 1 MiB image:

before: worker -> pickle(8 x image, messages, reward_breakdown, logs, turn metrics) -> controller
        controller: compute_rollout_metrics + recorder encode on the event loop -> add_group pickles it all again
after:  worker: compute_rollout_metrics + encode -> slim_rollout_group
        worker -> pickle(1 x image, arrays, group.metrics) + JSONL str -> controller
        controller: recorder.append_lines(str) -> add_group pickles only the slim group

I checked that nothing after the controller reads a dropped field. reward_breakdown and turn.metrics are read only in controller/metrics.py:312,328, which now runs in the worker. env_rewards and completion_message are read only by rubrics inside score_group, before slimming. TrainingSampleBuilder and the batcher read only arrays, images, reward and advantage.

Must fix

  1. PR description: "Human note: TODO (Jiani)" is still the placeholder. The human-written summary needs to be filled in (CLAUDE.md, PR Expectations 2).

Should consider

  • torchtitan/rl/rollout/finished_group.py:93 -- for_training leaves two ways to record rollouts. Please add a TODO for the follow-up that drops it (inline comment).
  • tests/rl/unit_tests/cpu/test_finished_group.py:171 -- the validation test duplicates coverage in test_async_controller.py; consider deleting it (inline comment).

Questions

  • Each worker now builds the RolloutSampleRecorder.Config.filter itself (recorder.py:971). KeepExtremeRewardsFilter is stateless and was already called with one group at a time, so recorder output is unchanged. A user filter that keeps state across calls, such as a per-step budget, would now see only one worker's groups. Is that worth one sentence on the filter's config docstring?

Not verified: the GPU timing and bitwise-loss results in the description (I couldn't run them).

Comment thread torchtitan/rl/rollout/finished_group.py Outdated
then slim it. Validation groups are returned as is: the controller computes their metrics
and records them.
"""
if not for_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.

This flag means there are now two ways to record rollouts: training groups are encoded in the worker and written with append_lines, and validation groups are encoded in the controller with record. The worker could finish validation groups too. RolloutSampleEncoder.encode already takes is_validation, and the controller only needs a prefix (plus the validation_ rename of turn metrics) to reduce the per-group Metrics. That would remove for_training from four signatures, RolloutSampleRecorder.record, and the full-group branch here. The PR description already calls this a follow-up, so please add a TODO here so the flag doesn't become permanent.

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.

from claude: Obsolete: the for_training flag is gone; workers record training and validation groups the same way (6e2d4ba).

assert len(pickle.dumps(finished)) < 2 * _IMAGE_BYTES


def test_finish_rollout_group_for_validation_returns_the_full_group() -> None:

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.

This test only checks the one-line if not for_training: return branch. test_async_controller.py::test_validation_renames_turn_metrics_and_uses_fresh_group_ids already asserts that validation passes for_training=False and uses the full group. Consider deleting it (rules/tests.md: tests must guard an otherwise-unguarded invariant).

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.

from claude: Obsolete: test_finished_group.py is deleted in 6e2d4ba.

@wwwjn
wwwjn force-pushed the wwwjn/data-plane/2-slim-group branch from a27d1a5 to 1aa70dd Compare November 20, 2026 22:29
@wwwjn

wwwjn commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

@claude review again

@claude

claude Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @wwwjn's task in 1m 6s —— View job


Approve -- the earlier code items are fixed; only the human-written summary placeholder is still open. 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 -- please address the item below before merging. All three code items from the last review are fixed at 1aa70dd, and the new commit adds no new problems. The human-written summary is still a placeholder. A maintainer still needs to review.

Earlier items

  • Fixed: finished_group.py:864 now has a TODO to finish validation groups in the worker and then drop for_training and RolloutSampleRecorder.record.
  • Fixed: the duplicate validation test in test_finished_group.py is deleted. test_async_controller.py::test_validation_renames_turn_metrics_and_uses_fresh_group_ids still covers that path: it asserts for_training=False and uses the full group.
  • Fixed: recorder.py:901 now says on RolloutSampleRecorder.Config.filter that each worker builds its own filter, so a filter that keeps state across calls sees only its own worker's groups.
  • Still open: "Human note: TODO (Jiani)" in the description (see below).

New since the last review. I checked every caller of Rollouter.setup_async, run_group_rollouts and RolloutSampleRecorder.record again. The only Rollouter subclass in the repo is VerifiersRollouter, and it forwards rollout_recorder_config. VerifiersRolloutWorker.setup_async (examples/verifiers/rollouter.py:216) is the worker-level hook, which never receives the recorder config. Validation still records in the controller (controller.py:949). payload/rollout_group_array_bytes counts images by id(image.data). That deduplicates correctly on the controller because pickle keeps shared references when it unpickles. Validation groups aren't slimmed, so their image count is unchanged.

Must fix

  1. PR description: "Human note: TODO (Jiani)" is still the template placeholder. The author needs to write the human summary (CLAUDE.md, PR Expectations 2).

Not verified: the GPU timing and bitwise-loss results in the description.

@wwwjn
wwwjn force-pushed the wwwjn/data-plane/2-slim-group branch from 1aa70dd to 9491bde Compare November 23, 2026 20:35
@wwwjn
wwwjn added this pull request to stack #6343 November 23, 2026 21:31
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/2-slim-group branch from 9491bde to d49c187 Compare November 24, 2026 17:53
@wwwjn
wwwjn removed this pull request from stack #6343 November 24, 2026 20:05
@wwwjn wwwjn closed this Nov 24, 2026
@wwwjn wwwjn reopened this Nov 24, 2026
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/2-slim-group branch from d49c187 to 6f31766 Compare November 24, 2026 23:01
@wwwjn
wwwjn changed the base branch from wwwjn/data-plane/1-slots-by-group-id to wwwjn/data-plane/1a-release-slots-by-group-id November 24, 2026 23:01
@wwwjn wwwjn changed the title [rl] Rollout workers return a slim group [rl] Rollout workers compute each training group's rollout metrics and recorder lines Nov 24, 2026
@wwwjn
wwwjn marked this pull request as ready for review November 30, 2026 19:38
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Nov 30, 2026
@github-actions
github-actions Bot requested a review from pzhan9 November 30, 2026 19:38
@wwwjn
wwwjn force-pushed the wwwjn/data-plane/2-slim-group branch from e286df2 to 35d85be Compare November 30, 2026 19:58
@wwwjn

wwwjn commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

@claude review again

@claude

claude Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @wwwjn's task in 1m 22s —— View job


Approve: the human-written summary is now filled in and nothing else is open; there is one optional suggestion to move compute_rollout_metrics. 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 last open item is resolved: the human-written summary is now filled in. The rebased, squashed head 35d85be keeps the same design I reviewed at e286df2, and I found no new problems. A maintainer still needs to review.

What this PR does. RolloutWorkerActor.run_group passes every scored group, training or validation, through finish_rollout_group. That function extends group.metrics with compute_rollout_metrics, using the prefix rollout or validation, and sets the new RolloutGroup.recorder_lines with RolloutSampleEncoder. The controller then only calls recorder.append_lines. For training it clears the lines before the group goes to the batcher. For validation it concatenates the per-group metrics and applies the same validation_ rename to turn metrics.

Example.

before: worker -> group -> controller: group.metrics += compute_rollout_metrics(...); recorder.record([group])
after:  worker: finish_rollout_group(group, is_validation=False, encoder)  # metrics + lines
        controller: recorder.append_lines(group.recorder_lines); group.recorder_lines = ""

Earlier items

  • Fixed: the human-written summary in the description.
  • Still fixed: the RolloutSampleEncoder docstring (recorder.py:153), the note on Config.filter about per-worker filters, the trimmed test_finished_group.py fixture, and the deletion of _settle.

Should consider

  • torchtitan/rl/rollout/finished_group.py:11 -- compute_rollout_metrics now has only one production caller, in the rollout package. Consider moving it out of controller/metrics.py (see the inline comment).
Details

Re-checked at 35d85be:

  • Callers of Rollouter.setup_async / run_group_rollouts: the controller (controller.py:860, :936, :1305), VerifiersRollouter.setup_async, which forwards rollout_recorder_config, and the tests. Worker-level setup_async and run_group (BaseRolloutWorker, MessageEnvRolloutWorker, VerifiersRolloutWorker) don't take the new arguments: RolloutWorkerActor consumes them. So test_rollout_worker.py and test_alphabet_sort.py need no change.
  • RolloutSampleRecorder.record has no remaining callers in torchtitan/ or torchtitan_recipes/.
  • Validation groups have negative ids, so flush_process_metrics adds no worker metrics to them. The validation_ rename in _collect_validation_rollouts therefore only touches turn metrics, as before.

Overlap search: finish_rollout_group and "rollout recorder" find only this stack (#6302, #6303, #6334) and unrelated RL PRs.

Not verified: the GPU timing, bitwise-loss and rollout_samples.jsonl results in the description.

Comment thread torchtitan/rl/rollout/finished_group.py Outdated

from __future__ import annotations

from torchtitan.rl.controller.metrics import compute_rollout_metrics

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.

After this PR the controller no longer calls compute_rollout_metrics. The validation path (controller.py:965) now just concatenates group.metrics. That leaves this file as its only production caller, so the rollout worker imports torchtitan.rl.controller.metrics to get code only the worker runs. rules/design.md says to group code by owner. Consider moving compute_rollout_metrics (lines 239-end of controller/metrics.py, with its private helpers) into torchtitan/rl/rollout/, next to finish_rollout_group, and updating the two test imports (test_metrics.py, test_finished_group.py). It is a mechanical move with no logic change. A follow-up PR in this stack is also fine.

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.

from claude: Moved to torchtitan/rl/rollout/metrics.py in 6e2d4ba.

rollout_recorder_config: RolloutSampleRecorder.Config,
vision_processor_config: VisionProcessor.Config | None = None,
) -> None:
self._encoder = RolloutSampleEncoder(rollout_recorder_config)

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.

monarch/ folder should only host thin actor wrapper -- the actual logic should go to rollouter.py

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.

from claude: Done in 6e2d4ba: the actor's run_group only calls BaseRolloutWorker.run_and_record_group (rollouter.py), which runs the group, adds its rollout metrics and records it.

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

recorder_lines: str = ""
"""The group's `RolloutSampleRecorder` JSONL lines, encoded by the rollout worker that scored
it (`finish_rollout_group`); the controller appends them."""

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.

This makes controller don't need to access the actual data of each rollout, build the foundation of bypassing controller read the actual data/rollout content

What's the eventual design?

  • before this PR, the controller receives rollout, and do the transformation and recording
  • after this PR, the controller receives the recording as recorder_lines, which doesn't bypass controller at all

I wonder if we should consider putting recorder as part of rollouter / rollout worker and move the recording entirely off controller?

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.

from claude: Moved recording entirely off the controller in 6e2d4ba: each rollout worker owns a RolloutSampleRecorder and writes rollout_samples.rank_<N>.jsonl; recorder_lines and RolloutSampleEncoder are gone. Eventual design: the controller only gets each group's metadata + a ref (#6303), and the bytes stay in the worker until a trainer leader reads them. Checked on a 10-step bitwise run: same 184 recorded lines as the base (as a set), loss and validation metrics identical.

…aseRolloutWorker

Review fixes:
- The Monarch actor is a thin wrapper again: BaseRolloutWorker.run_and_record_group
  runs the group, adds its rollout metrics and records it (was
  finish_rollout_group, called from the actor).
- Each rollout worker owns a RolloutSampleRecorder and writes the training and
  validation groups it runs to rollout_samples.rank_<N>.jsonl under
  dump_folder. The controller no longer records anything, so rollout content
  never passes through it for recording: RolloutSampleEncoder,
  RolloutGroup.recorder_lines and append_lines are gone, and the recorder is
  back to main's record() API. Rollouter.close closes the workers' recorders
  before stopping them.
- compute_rollout_metrics moves to torchtitan/rl/rollout/metrics.py, next to
  its only caller.
@wwwjn wwwjn changed the title [rl] Rollout workers compute each group's rollout metrics and recorder lines [WIP] [rl] Rollout workers compute each group's rollout metrics and recorder lines Dec 1, 2026
@wwwjn wwwjn changed the title [WIP] [rl] Rollout workers compute each group's rollout metrics and recorder lines [WIP] [rl] Rollout workers compute and record each group's rollouts Dec 1, 2026
@wwwjn

wwwjn commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

from claude: Recorder moved into the rollout workers and the finish step into BaseRolloutWorker in 6e2d4ba; description updated. @claude review

@claude

claude Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @wwwjn's task in 2m 28s —— View job


Approve -- please address the item below before merging: move rollout_recorder from Controller.Config to BaseRolloutWorker.Config so it isn't passed through four signatures that only forward it. 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 -- please address the item below before merging. 6e2d4ba takes recording off the controller completely and leaves the Monarch actor as a thin wrapper, which answers both of @tianyu-l's comments. One mechanical config-ownership item is left. A maintainer still needs to review, and @tianyu-l's CHANGES_REQUESTED still stands until they re-review.

What changed since the last review. finish_rollout_group, RolloutSampleEncoder, RolloutGroup.recorder_lines and append_lines are gone. BaseRolloutWorker.run_and_record_group (rollouter.py:550) runs run_group, extends group.metrics with compute_rollout_metrics (now in rollout/metrics.py), and calls self._recorder.record(...). Each worker builds its own recorder in setup_async via start_recorder, writing to rollout_samples.rank_<N>.jsonl. Rollouter.close calls worker_actors.close after the in-flight calls finish and before it stops the pool. The actor only forwards, and adds worker_rank=current_rank().rank plus a close endpoint.

Example.

before (35d85be): worker: metrics + encode -> group.recorder_lines -> controller: append_lines(...)
after  (6e2d4ba): worker k: metrics + recorder.record(...) -> rollout_samples.rank_k.jsonl
                  controller: receives the group with metrics, writes nothing

Earlier items

  • Fixed: compute_rollout_metrics moved to torchtitan/rl/rollout/metrics.py (unchanged move).
  • Addressed (@tianyu-l): the actor is a thin wrapper (rollout_worker.py:86), and the controller no longer receives or writes recorder content.

Must fix

  1. torchtitan/rl/controller/controller.py:363 -- rollout_recorder stays on Controller.Config even though only the rollout worker reads it, so it is passed through four forwarding signatures. Move it to BaseRolloutWorker.Config (see the inline comment).
Details
  • Every BaseRolloutWorker.setup_async override starts the recorder. The base and VerifiersRolloutWorker both call start_recorder, and MessageEnvRolloutWorker doesn't override setup_async. Nothing else in torchtitan/ or torchtitan_recipes/ calls RolloutSampleRecorder.Config.build.
  • Failure path: if record raises in the worker, run_and_record_group raises, and _rollout_loop turns that into the one-failure-metric group. This matches the old behavior when the controller's record raised.
  • Shutdown edge: if a run_group call is still running after _RUN_GROUP_DRAIN_TIMEOUT_S, close cancels only the controller-side call. The worker can then call record after its recorder is closed, and the executor raises "cannot schedule new futures after shutdown". The worker is stopped right after, so that group is lost either way. This costs one log line, not data.
  • Validation metrics: test_validation_metrics_merged_over_groups_equal_the_whole_batch guards the per-group merge equivalence. That is a real invariant: the validation/* values must not change.
  • Overlap search ("rollout_recorder", "RolloutSampleRecorder"): #6302 (this stack), plus #5303 and #6378, which change recorder encoding. Those two will need a small rebase over the worker_rank constructor change.

Not verified: the GPU timing results and the 10-step bitwise / 184-recorded-lines comparison in the description.

Comment thread torchtitan/rl/controller/controller.py Outdated
Comment on lines +363 to +368
rollout_recorder: RolloutSampleRecorder.Config = field(
default_factory=RolloutSampleRecorder.Config
)
"""JSONL recorder to save sampled rollouts to disk for further inspection and debugging."""
"""JSONL recorder to save sampled rollouts to disk for further inspection and debugging. Each
rollout worker records the groups it runs to its own file under `dump_folder`, e.g.
`rollout_samples.rank_3.jsonl`."""

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.

Only the rollout worker reads this config now, but it still lives on Controller.Config. So it gets passed down through four signatures that only forward it: Controller.setup_async -> Rollouter.setup_async (and VerifiersRollouter.setup_async) -> RolloutWorkerActor.setup_async -> BaseRolloutWorker.setup_async / VerifiersRolloutWorker.setup_async. rules/config.md says a component owns its config, and a function takes only the config it reads.

The worker config already reaches every worker at spawn, so you can move the field there:

# BaseRolloutWorker.Config
recorder: RolloutSampleRecorder.Config = field(default_factory=RolloutSampleRecorder.Config)
"""JSONL recorder for the groups this worker runs; each worker writes its own file under
`dump_dir`, e.g. `rollout_samples.rank_3.jsonl`."""

Then keep config.recorder in __init__ and have start_recorder(dump_dir=..., worker_rank=...) build from it. That removes rollout_recorder_config from all five signatures and deletes this field. Only dump_dir (from the controller) and worker_rank (from the actor) still need to be passed in. In-repo users to update: the three rollout_recorder= sites in torchtitan_recipes/rl/verifiers_terminal_bench.py (they become rollouter.worker.recorder), test_shutdown.py:136, and the tests that pass rollout_recorder_config=.

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.

from claude: Moved it to BaseRolloutWorker.Config.recorder. Controller.Config.rollout_recorder and the forwarding args are gone; the terminal-bench recipe sets recorder= on its worker config.

…tWorker.Config

Only the rollout worker reads it now, so it no longer passes through
Controller/Rollouter/actor setup_async. Each worker builds its recorder from
its own Config.recorder; setup_async still gets dump_dir and worker_rank.
@wwwjn

wwwjn commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

from claude: Changes since the last review (485eec8):

  • The recorder config moved from Controller.Config.rollout_recorder to BaseRolloutWorker.Config.recorder. Controller, Rollouter, the actor and the Verifiers rollouter no longer pass it through setup_async; the terminal-bench recipe sets it on its worker config.
  • GPU gate (bitwise recipe, 10 steps + one validation) on the stack top: the 184 recorded lines are the same multiset as the [WIP][rl] One RDMA object for microbatches and prompts; rollout workers send images as RDMA handles #5862 base, and 92/92 non-timing TensorBoard tags are identical.

@claude review

@claude

claude Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @wwwjn's task in 56s —— View job


Approve: the recorder config now lives on BaseRolloutWorker.Config, which closes the last open item; no new problems. 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 -- 485eec8 moves the recorder config onto the rollout worker's own config, which fixes the last open item, and I found no new problems. A maintainer still needs to review. @tianyu-l's CHANGES_REQUESTED stays in place until they re-review.

What changed since the last review. Controller.Config.rollout_recorder is gone and BaseRolloutWorker.Config.recorder replaces it. BaseRolloutWorker.__init__ saves it as self._recorder_config. start_recorder(*, dump_dir, worker_rank) now builds the recorder from that saved config. rollout_recorder_config is removed from five setup_async signatures: Controller -> Rollouter / VerifiersRollouter -> RolloutWorkerActor -> BaseRolloutWorker / VerifiersRolloutWorker. The terminal-bench recipe now sets the filter once, in _terminal_bench_rollouter_config, instead of in three Controller.Config sites.

Example.

before: Controller.Config(rollout_recorder=RolloutSampleRecorder.Config(filter=...), rollouter=...)
        -> setup_async(rollout_recorder_config=...) x4 -> worker.start_recorder(config, dump_dir, rank)
after:  VerifiersRolloutWorker.Config(..., recorder=RolloutSampleRecorder.Config(filter=...))
        -> worker.start_recorder(dump_dir=..., worker_rank=...)  # builds from self._recorder_config

Earlier items

  • Fixed: rollout_recorder moved from Controller.Config to BaseRolloutWorker.Config.recorder, and the forwarding arguments are removed.
Details
  • No rollout_recorder or rollout_recorder_config references are left in torchtitan/, torchtitan_recipes/, tests/ or the docs. I also found no --override strings that target the old path.
  • VerifiersRolloutWorker.__init__ calls super().__init__(config), so _recorder_config is set before its setup_async calls start_recorder. VerifiersRolloutWorker.Config subclasses BaseRolloutWorker.Config, so it inherits recorder.
  • All three terminal-bench recipes build their rollouter through _terminal_bench_rollouter_config. So all three keep the KeepExtremeRewardsFilter(keep_errors=True) filter, as before.
  • The tests set _recorder_config by hand only where they skip __init__ (object.__new__, or a _LoopBlockingWorker that doesn't score).
  • Overlap search ("rollout_recorder"): only this PR and #6302 (same stack).

Not verified: the GPU gate in the trigger comment (the 184 recorded lines and the 92/92 TensorBoard tags).

This branch has not been deployed

No deployments
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