Skip to content

[rl] Optional native rollout timeout - #5512

Draft
felipemello1 wants to merge 1 commit into
felipemello1/parked-rollout-worker-basefrom
felipemello1/http/7-native-rollout-timeout
Draft

felipemello1 wants to merge 1 commit into
felipemello1/parked-rollout-worker-basefrom
felipemello1/http/7-native-rollout-timeout

Conversation

@felipemello1

@felipemello1 felipemello1 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary (human-written)

Agent details

Parked outside the stack: no recipe sets rollout_timeout_s yet. Its base is felipemello1/parked-rollout-worker-base, a frozen copy of the stack up to "Rollouter: keep one handle per rollout worker" in its earlier order (Verifiers 0.4.0, with the row-0 router copy). Don't merge it: port it onto main when it is unparked. Delete that branch once #5507 and #5512 are both ported or closed.

TLDR: MessageEnvRolloutWorker.Config.rollout_timeout_s ends a native rollout that runs past it, keeps its finished turns, and stops waiting for its generate call. A liveness guard against a hung env or generator, like Verifiers' timeout.rollout for the Verifiers path; off by default.

Problem

  1. A native rollout runs env.init(), then alternates a generate call and env.step until the env is terminal.
  2. Only a single env step has a deadline (TokenEnv step_timeout_s, 1800 s). env.init() and the generate call have none.
  3. A generate call or an env that never returns holds its rollout, and its group's buffer slot, forever.

Solution

  1. MessageEnvRolloutWorker.Config.rollout_timeout_s (default None) puts env.init() and every turn, not score_group, under one asyncio.timeout.
  2. Past it, the rollout ends as ERROR_TIMEOUT with its finished turns (a turn finishes when its env step returns), and the session is still released. The turn being cut is dropped: it has no parsed message yet, so a rubric would score an empty reply. step_timeout_s fires after the parse and keeps that turn, so set it below rollout_timeout_s to train hung env steps.
  3. A timeout before the first finished turn ends as ERROR_INFRA, with the reason in Rollout.logs["error"]: with no tokens, an ERROR_TIMEOUT would get a reward and make the sample builder drop its whole group.
  4. A TimeoutError raised by env.init() or the generate call before the deadline is not a rollout timeout: it ends as ERROR_INFRA ("Rollouts that fail outside the policy are recorded, not trained"). TokenEnv.step_timeout_s still owns step timeouts.
  5. Why a cut after a finished turn is trained (ERROR_TIMEOUT): a timeout can't tell who hung, and the policy can cause the hang (e.g. a command that never returns). A hang in the first env step is the policy's too, but it is ERROR_INFRA because no turn is left to train. The rollout_timeout_s docstring says so.
  6. The generator still finishes a timed-out request (see the rollout_timeout_s docstring).
  7. Unchanged: Verifiers rollouts, which use Verifiers' timeout.rollout and keep the trace. One difference stays: a Verifiers timeout keeps the cut turn (its trace has the message), while this deadline drops it. rollout_timeout_s is on MessageEnvRolloutWorker.Config, not the base class, so a Verifiers config can't set it.

Results
Numerics: bitwise vs main: rollout_timeout_s defaults to None, and no recipe sets it. Not run on GPU at this head.

Shutdown probe, Monarch 0.7.0, CPU: a real rollout worker and a stand-in generator that holds every call
until the generators close (a hung generator). The rollout timeout cuts the calls, and run_group returns.
Then the generators close (the generator answers every held call), and Rollouter.close runs:
  200 cut calls                             exit 130: "undeliverable message for generator.generate()"
  1 cut call                                exit 0
  200 cut calls, 5 s between closing the    exit 0; the generator answered 200 of 200
    generators and Rollouter.close

You may ask:

  • Who sets it? No in-repo recipe yet. It bounds the two steps nothing else bounds today: env.init(), and a generate call whose reply never comes (a stuck generator or a lost reply). Env steps already have step_timeout_s.
  • Why off by default? A cut biases training toward short rollouts; set it well above the p99 rollout time.

NOTE:

  • A cut generate call is still answered later, at the latest when the generators close (e.g. a call on a hung generator). So any cut can race the end of the run, not only a cut right before it. If the answer reaches a worker that already stopped, Monarch fails the generator and the job exits 130 (Results, TODO(monarch) at the deadline). A Verifiers call the agent gives up on can do the same (TODO in generation_server.py).
  • A cut also cancels the look-aside GenerateFn, so its finally releases the call's router reservation while the generator still runs the call (look-aside's TODO in _make_generate_fn). Until that call ends, the router counts one call fewer on that generator. This PR is the first in-tree code that cuts a generate call.
  • Main's Rollouter.close is safe for native rollouts only because run_group returns after every answer; a cut breaks that. Until Monarch issue 5301 is fixed, each worker would have to keep its unanswered calls and close wait for them, as "Cancel a rollout group on its worker" does.
  • Most of the diff re-indents the rollout loop under async with; hide whitespace (?w=1) to read it.
  • asyncio.to_thread work inside env.step keeps running past the timeout, as with step_timeout_s.
  • The deadline counts generation time too, so a loaded generator can cut healthy rollouts. The rollout_timeout_s docstring says so.
  • With session_kv_holder on, a rollout cut right after it sent a generate call can release its session before the engine admits that call. This PR adds a TODO in engine_loop.py for this race. A Verifiers call sent right before the agent gives up on it (e.g. its rollout timeout) can hit it too, on main as well.

Open for the maintainer:

  • A review asked whether every expiry should be ERROR_INFRA. Today a stall after the first finished turn is ERROR_TIMEOUT, so its partial rollout is scored and trained.

Test plan

pytest tests/rl/unit_tests/cpu   # verifiers 0.4.0, at this position: 707 passed, 1 skipped
  • test_rollout_timeout on a 2-turn env: stall at turn 0 -> ERROR_INFRA, 0 turns; stall at turn 1 -> ERROR_TIMEOUT, 1 turn; a TimeoutError raised at turn 1 before the deadline -> ERROR_INFRA, 1 turn. The session is released in all three, and each ERROR_INFRA rollout records why.
  • test_a_rollout_timeout_in_an_env_step_drops_the_cut_turn (2 cases): the env step hangs in turn 0 or turn 1. The cut turn is dropped: turn 0 -> ERROR_INFRA, no turns; turn 1 -> ERROR_TIMEOUT, and the finished turn keeps its env reply.

@felipemello1
felipemello1 added this pull request to stack #5513 October 18, 2026 23:32
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 18, 2026
@felipemello1
felipemello1 force-pushed the felipemello1/http/6-verifiers-groups-in-workers branch from ee23f54 to 740beed Compare October 19, 2026 00:38
@felipemello1
felipemello1 force-pushed the felipemello1/http/7-native-rollout-timeout branch from a9cd35c to 9839941 Compare October 19, 2026 00:38
@felipemello1
felipemello1 force-pushed the felipemello1/http/6-verifiers-groups-in-workers branch from 740beed to c81435b Compare October 19, 2026 01:16
@felipemello1
felipemello1 force-pushed the felipemello1/http/7-native-rollout-timeout branch from 9839941 to 70a1b3a Compare October 19, 2026 01:16
@felipemello1 felipemello1 changed the title [rl] Optional native rollout timeout [rl] Optional native rollout timeout (13/14) Oct 19, 2026
@felipemello1
felipemello1 force-pushed the felipemello1/http/6-verifiers-groups-in-workers branch from c81435b to bb79416 Compare October 23, 2026 07:34
@felipemello1
felipemello1 force-pushed the felipemello1/http/7-native-rollout-timeout branch from 70a1b3a to a3f5b24 Compare October 23, 2026 07:34
@felipemello1
felipemello1 removed this pull request from stack #5513 October 27, 2026 14:27
@felipemello1
felipemello1 force-pushed the felipemello1/http/6-verifiers-groups-in-workers branch from bb79416 to 67abd3e Compare October 27, 2026 14:32
@felipemello1
felipemello1 force-pushed the felipemello1/http/7-native-rollout-timeout branch from a3f5b24 to 7b48f60 Compare October 27, 2026 14:32
@felipemello1 felipemello1 changed the title [rl] Optional native rollout timeout (13/14) [rl] Optional native rollout timeout (14/14) Oct 27, 2026
@felipemello1
felipemello1 added this pull request to stack #5639 October 27, 2026 14:33
@felipemello1
felipemello1 force-pushed the felipemello1/http/6-verifiers-groups-in-workers branch from 67abd3e to e77d87d Compare November 5, 2026 00:38
@felipemello1
felipemello1 force-pushed the felipemello1/http/7-native-rollout-timeout branch from 7b48f60 to 8932f4e Compare November 5, 2026 00:39
@felipemello1
felipemello1 removed this pull request from stack #5639 November 5, 2026 07:53
@felipemello1
felipemello1 force-pushed the felipemello1/http/7-native-rollout-timeout branch from 08837ea to 910f98e Compare November 5, 2026 07:53
@felipemello1
felipemello1 changed the base branch from felipemello1/http/6-verifiers-groups-in-workers to felipemello1/http/4-cancel-group November 5, 2026 07:53
@felipemello1
felipemello1 added this pull request to stack #5857 November 5, 2026 07:54
@felipemello1 felipemello1 changed the title [rl] Optional native rollout timeout (14/14) [rl] Optional native rollout timeout (9/10) Nov 5, 2026
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude review. This PR was re-cut onto PR 7: it no longer depends on the HTTP generation PRs, so the code and the body changed.

@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @felipemello1's task in 2m 15s —— View job


Needs discussion -- review posted.

@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: Needs discussion -- the code is correct as written, but this adds a config field with no consumer and no observed hang, and its status semantics (train vs not train) need a maintainer decision.

What this PR does. Adds RolloutWorker.Config.rollout_timeout_s (default None). When set, env.init() and every generate call plus env.step in a native rollout run under one asyncio.timeout. When it expires, the rollout ends as ERROR_TIMEOUT and keeps its completed turns, or as ERROR_SYSTEM if it has no turns yet. A TimeoutError raised before the deadline is still ERROR_SYSTEM. The session is released in every case.

Example. rollout_timeout_s=60, 2-turn env, and the generator never replies at turn 1:

before: the rollout, its group, and the group's buffer slot wait forever
after:  at t=60s -> Rollout(status=ERROR_TIMEOUT, turns=[turn0]) -> scored, advantaged, trained
        same stall at turn 0 -> Rollout(status=ERROR_SYSTEM, turns=[], logs={"error": ...}) -> not trained

Must fix

  1. The PR description: "Summary (human-written)" is empty.
  2. torchtitan/rl/rollout/rollouter.py:333 has no consumer. No recipe sets the field, and the description gives no observed hang ("Who sets it? No in-repo recipe yet"). Please name the run or user that hit a hung env.init() or a lost generate reply. If nobody has, drop the field until someone does. If the real case is a lost reply, a deadline on the generate call in Controller._make_generate_fn (next to the existing cancel TODO) fixes the cause instead of bounding the whole rollout. env.init() could get a deadline in TokenEnv next to step_timeout_s, which already owns per-call env deadlines (token_env.py:104 asks whether timeouts belong in that layer at all).

Should consider

  • rollouter.py:577-584 -- the trained-or-not choice depends on len(turns). A stall at turn 3, which is a system failure, trains on a partial trajectory with a reward. Making every expiry ERROR_SYSTEM is simpler and matches the field's stated purpose (see inline).

Questions

  • Should the native and Verifiers paths agree on a zero-turn timeout? On the native path it is ERROR_SYSTEM (group kept). On the Verifiers path it is ERROR (examples/verifiers/rollouter.py:375), and the sample builder then drops the whole group, which is what the comment at rollouter.py:578 says this PR avoids. PR 10 moves Verifiers groups into rollout workers, so this difference will show up next to the native one.
Details
  • Cancel interaction (PR 8): an external cancel is a CancelledError, which except Exception doesn't catch, and asyncio.timeout re-raises it when its own deadline hasn't expired, so cancel_group behaves the same as before. The nested asyncio.wait_for in TokenEnv.step only catches its own TimeoutError; the outer expiry reaches it as a CancelledError and passes through.
  • asyncio.timeout(None) is a no-op, and requires-python >= 3.11, so asyncio.timeout and expired() are available. When the field is None the behavior is unchanged, so the bitwise-numerics claim holds by construction.
  • Tests: the three parametrized CPU cases are cheap and cover the branches that would regress silently (zero-turn vs n-turn timeout, an early TimeoutError not counted as a timeout). The four rollout_timeout_s=None additions are needed because SimpleNamespace configs don't fall back to defaults.

Not verified: behavior under a real Monarch generator (no GPU run).

Comment thread torchtitan/rl/rollout/rollouter.py Outdated
Comment on lines +577 to +584
if timeout.expired():
# With no turn there are no tokens to train. As ERROR_TIMEOUT it would get a reward,
# and the sample builder would drop its whole group for having no completion tokens.
status = (
RolloutStatus.ERROR_TIMEOUT if turns else RolloutStatus.ERROR_SYSTEM
)
if not turns:
logs["error"] = "rollout_timeout_s passed before the first turn"

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 status depends on len(turns), and that doesn't fit what the field is for. The docstring calls rollout_timeout_s a guard against "a hung env or generator", and PR 7 defines ERROR_SYSTEM as a failure outside the policy. Under this branch, a rollout whose generator stalls at turn 3 ends as ERROR_TIMEOUT: the rubric scores the partial trajectory, it gets an advantage, and it trains. That is the short-rollout bias the docstring warns about, and the policy didn't cause it. The same stall at turn 0 ends as ERROR_SYSTEM and doesn't train.

If every rollout_timeout_s expiry were ERROR_SYSTEM, the turns branch and its comment would go away, the group would still be kept (the sample builder skips ERROR_SYSTEM without dropping the group), and the types.py comment would reduce to "or it passed rollout_timeout_s". TokenEnv.step_timeout_s would keep ERROR_TIMEOUT for a slow env step, which the policy can plausibly cause.

Suggested change
if timeout.expired():
# With no turn there are no tokens to train. As ERROR_TIMEOUT it would get a reward,
# and the sample builder would drop its whole group for having no completion tokens.
status = (
RolloutStatus.ERROR_TIMEOUT if turns else RolloutStatus.ERROR_SYSTEM
)
if not turns:
logs["error"] = "rollout_timeout_s passed before the first turn"
if timeout.expired():
# A hung env or generator is not the policy's doing: keep the group, don't train it.
status = RolloutStatus.ERROR_SYSTEM
logs["error"] = f"rollout_timeout_s passed after {len(turns)} turn(s)"

(and update the logger.warning below to match). If you want ERROR_TIMEOUT to match Verifiers' timeout.rollout, please say so in the docstring. Note that Verifiers sends a zero-turn timeout to ERROR (examples/verifiers/rollouter.py:375), not ERROR_SYSTEM, so the two paths still disagree.

@felipemello1
felipemello1 force-pushed the felipemello1/http/7-native-rollout-timeout branch from 3b01212 to e83efcf Compare November 5, 2026 11:15
@felipemello1
felipemello1 removed this pull request from stack #5857 November 6, 2026 04:05
@felipemello1
felipemello1 force-pushed the felipemello1/http/4-cancel-group branch from 6691335 to ee8da84 Compare November 6, 2026 04:05
@felipemello1
felipemello1 force-pushed the felipemello1/http/7-native-rollout-timeout branch from fc51806 to aac4c28 Compare November 6, 2026 04:05
@felipemello1
felipemello1 added this pull request to stack #5878 November 6, 2026 04:06
@felipemello1
felipemello1 force-pushed the felipemello1/http/4-cancel-group branch from 55d19be to 6fb7960 Compare November 10, 2026 22:41
@felipemello1
felipemello1 force-pushed the felipemello1/http/7-native-rollout-timeout branch from 717ad61 to a9db346 Compare November 10, 2026 22:42
@felipemello1
felipemello1 force-pushed the felipemello1/http/4-cancel-group branch from 6fb7960 to f5e1684 Compare November 11, 2026 01:38
@felipemello1
felipemello1 force-pushed the felipemello1/http/7-native-rollout-timeout branch from a9db346 to eef051a Compare November 11, 2026 01:39
@felipemello1
felipemello1 force-pushed the felipemello1/http/4-cancel-group branch from f5e1684 to 21f6ee2 Compare November 11, 2026 01:53
@felipemello1
felipemello1 force-pushed the felipemello1/http/7-native-rollout-timeout branch from eef051a to cdbc73a Compare November 11, 2026 01:54
@felipemello1
felipemello1 force-pushed the felipemello1/http/4-cancel-group branch from 21f6ee2 to c67edf2 Compare November 11, 2026 02:03
@felipemello1
felipemello1 force-pushed the felipemello1/http/7-native-rollout-timeout branch 2 times, most recently from cdbc73a to 38cf105 Compare November 11, 2026 02:03
@felipemello1
felipemello1 force-pushed the felipemello1/http/4-cancel-group branch from c67edf2 to 74a1555 Compare November 11, 2026 03:31
@felipemello1
felipemello1 force-pushed the felipemello1/http/7-native-rollout-timeout branch from 38cf105 to 5e6d7f4 Compare November 11, 2026 03:32
@felipemello1
felipemello1 force-pushed the felipemello1/http/4-cancel-group branch from 74a1555 to 904294c Compare November 11, 2026 04:39
@felipemello1
felipemello1 force-pushed the felipemello1/http/7-native-rollout-timeout branch from 5e6d7f4 to 2960536 Compare November 11, 2026 04:40
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: On the open question (should a timed-out rollout train?): yes, on purpose.

  • After a finished turn, a deadline is the policy's: it took too long, e.g. a command that never ends. It trains as ERROR_TIMEOUT, at error_reward if set. The stack's Verifiers path does the same for the agent's deadline. With error_reward unset, the rubric scores the partial rollout, as for any ERROR_TIMEOUT.
  • Before any finished turn there is nothing to train, so it is ERROR_INFRA.
  • The base PR ("Rollouts that fail outside the policy are recorded, not trained") now says why in the RolloutStatus docstring: ERROR_TIMEOUT trains, ERROR_ABORT doesn't. It also stops training ERROR_ABORT.

The other point (no recipe sets rollout_timeout_s yet) is the maintainer's call. This PR stays outside the stack until a run needs it.

@felipemello1
felipemello1 changed the base branch from felipemello1/http/4-cancel-group to main November 11, 2026 06:29
@felipemello1
felipemello1 force-pushed the felipemello1/http/7-native-rollout-timeout branch from 2960536 to 97a13e7 Compare November 11, 2026 06:30
@felipemello1
felipemello1 changed the base branch from main to felipemello1/http/4-cancel-group November 11, 2026 06:30
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review. This PR now sits on the rebuilt "Cancel a rollout group on its worker". The only code change is the conflict resolution in controller.py. The body points at the TODO in RolloutWorkerActor.run_group. A new NOTE says that, with session_kv_holder on, a timeout cut right after a generate call can hit the release race named in engine_loop.py.

@claude

claude Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

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


Needs discussion -- review posted.

@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: Needs discussion -- the rebase onto the rebuilt base changes no behavior, and the body's new pointers are accurate. Two questions are still the maintainer's: the field has no user yet, and whether a timed-out rollout should train.

What changed since the last review. I compared HEAD (97a13e7) with e1a8f34:

  • The PR now touches 2 files, rollouter.py and test_rollout_worker.py. controller.py is gone from the diff: the generate-call TODO it used to add now lives in the base, in RolloutWorkerActor.run_group (torchtitan/rl/actors/monarch/rollout_worker.py:78-80).
  • The rollouter.py hunks are the same as before: the deadline.expired() branch, the docstring table keyed on finished turns, and the turn appended only after env.step returns. The tests are the same too.

I checked both of the body's new pointers at the base:

  • Generate-call TODO. The base wraps each call in asyncio.shield and keeps it in _generate_calls. So when the deadline fires, the rollout stops waiting, the request keeps decoding, and wait_for_generate_calls covers its reply at close. close bounds that wait with _SHUTDOWN_DRAIN_TIMEOUT_S (rollouter.py:212), so a reply that never comes cannot hang shutdown.
  • Release-race NOTE. The engine_loop.py:345 TODO describes this case: a release runs before the cut rollout's generate call is admitted.

No new problems.

Example (unchanged): rollout_timeout_s=60, a 2-turn env.

generator hangs, turn 0   ERROR_INFRA, [], logs["error"] set   -> group kept, not trained
env.step hangs, turn 0    ERROR_INFRA, []                      (cut turn dropped)
env.step hangs, turn 1    ERROR_TIMEOUT, [t0]                  -> scored, trained
TimeoutError raised early ERROR_INFRA, turns kept so far

Must fix (still open)

  1. PR description: "Summary (human-written)" is still empty.
  2. torchtitan/rl/rollout/rollouter.py:345: nothing uses the field yet ("Parked outside the stack: no recipe sets rollout_timeout_s yet"). A knob should land together with its first user (CLAUDE.md principle 2, config.md "Few Knobs"). This is the maintainer's call, as the author said, so it stays open until a recipe or run needs it.

Should consider (answered by the author, left to the maintainer)

  • rollouter.py:647-651: whether a rollout trains depends on len(turns). The 2026-11-11 reply explains the choice: after a finished turn the policy may have caused the hang, and with no finished turn there is nothing to train. The base's RolloutStatus docstring now records it. The reasoning is consistent with the code. I'm not reopening it.
Details
  • With this field set, a cut rollout's request keeps decoding during normal training, not just after a shutdown or cancel_group cancel. Per the base TODO, it can pin its group's cache salt again. The body discloses this ("The generator still finishes a timed-out request").
  • A reply that never arrives (the lost-reply case this field targets) leaves its future in _generate_calls until close. The future is small, and close is bounded, so no action is needed.
  • The earlier analysis still holds at HEAD:
    • An external cancel passes through except Exception, and asyncio.timeout re-raises it when its own deadline hasn't expired.
    • The nested TokenEnv.step deadline doesn't catch the outer expiry.
    • asyncio.timeout(None) is a no-op, so the default gives bitwise-identical numerics by construction.

Not verified: behavior with a real Monarch generator (no GPU run).

@felipemello1
felipemello1 force-pushed the felipemello1/http/4-cancel-group branch from 39b031b to 7423b81 Compare November 11, 2026 08:40
@felipemello1
felipemello1 force-pushed the felipemello1/http/7-native-rollout-timeout branch from 97a13e7 to 2984935 Compare November 11, 2026 08:41
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review. This push replays the PR onto main: the rollout fakes take main's Prompt, and the send-time-raise test is gone, as on PR 3.

@claude

claude Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

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


Needs discussion -- review posted.

@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: Needs discussion -- the replay onto main (2984935) changes no behavior, and the fakes match main's Prompt API. Two questions are still the maintainer's: nothing uses the field yet, and whether a timed-out rollout should train.

What changed since the last review. I compared HEAD (2984935) with 97a13e7:

  • _run_single_rollout now calls generate_fn(prompt=env_step.next_prompt, ...) and keeps prompt_delta_images / prompt_delta_image_placeholders on each turn. Both come from the base, and this PR only re-indents them under async with deadline:.
  • The test fakes (_TwoTurnTokenEnv, _StepHangsTokenEnv) build TokenEnvOutput(next_prompt=Prompt(token_ids=...)). generate_then_stall(prompt, **kwargs) takes prompt by keyword, which matches the call site. Prompt is exported from torchtitan/rl/rollout/__init__.py.
  • test_multiturn_images.py only gets the rollout_timeout_s=None line that SimpleNamespace configs need.
  • The deadline.expired() branch, the docstring table and the turn-append order are the same as before. test_rollout_timeout has 3 cases and test_a_rollout_timeout_in_an_env_step_drops_the_cut_turn has 2. Removing the send-time-raise case leaves a gap: no test now checks that a TimeoutError before the deadline is ERROR_INFRA with 0 turns. The (1, _raise_timeout, ERROR_INFRA, 1) case covers the same else branch, so nothing important goes unguarded.

No new problems.

Example (unchanged): rollout_timeout_s=60, a 2-turn env.

generator hangs, turn 0          ERROR_INFRA, [], logs["error"] set  -> group kept, not trained
env.step hangs, turn 0           ERROR_INFRA, []                     (cut turn dropped)
env.step hangs, turn 1           ERROR_TIMEOUT, [t0]                 -> scored, trained
TimeoutError raised before limit ERROR_INFRA, turns kept so far

Must fix (still open)

  1. PR description: "Summary (human-written)" is still empty.
  2. torchtitan/rl/rollout/rollouter.py:348: nothing uses the field yet ("Parked outside the stack: no recipe sets rollout_timeout_s yet"). A knob should land together with its first user (CLAUDE.md principle 2, config.md "Few Knobs"). The author left this to the maintainer, so it stays open until a recipe or run needs it.

Should consider (answered by the author, left to the maintainer)

  • rollouter.py:653-662: whether a rollout trains depends on len(turns). The 2026-11-11 reply explains why, and the reasoning matches the code. I'm not reopening it.
Details
  • The earlier analysis still holds at HEAD:
    • An external cancel passes through except Exception, and asyncio.timeout re-raises it when its own deadline hasn't expired.
    • The nested TokenEnv.step deadline doesn't catch the outer expiry.
    • asyncio.timeout(None) is a no-op, so the default gives bitwise-identical numerics by construction.
  • The PR base is still felipemello1/http/4-cancel-group (merge-base 7423b81), so "replays onto main" describes the base, which was rebuilt on main.

Not verified: I couldn't run the CPU tests here (the command needed approval), and nothing ran on a real Monarch generator.

@felipemello1
felipemello1 changed the base branch from felipemello1/http/4-cancel-group to main November 11, 2026 20:20
@felipemello1
felipemello1 force-pushed the felipemello1/http/7-native-rollout-timeout branch from 2984935 to f8082cf Compare November 11, 2026 20:21
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: Parking this PR as a draft, outside the stack.

Why:

  • No recipe sets rollout_timeout_s. Every sandbox recipe we run (Terminal-Bench, SWE-rebench V2) goes through the Verifiers path, whose agent timeout already bounds a stuck rollout.
  • Native rollouts already bound each env step (step_timeout_s, 1800 s). A generate call that never answers needs a generator that stays alive but stuck, and that hangs every request on it. A per-rollout timeout would hide that, not fix it.
  • Without the call tracking in "Cancel a rollout group on its worker" (also parked), a timeout cut can leave the router owing an answer to a worker that already stopped, at shutdown. In a CPU probe, 200 cut calls exited 130 and 1 cut call exited 0.

To unpark: a native recipe that needs a cap on one rollout's total time, e.g. a native env with a sandbox or a slow external tool. Fix the shutdown race first: cut only env steps, or track the cut calls.

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

1 participant