Skip to content

feat: pause episodes instead of cancelling on overload - #4807

Open
mikasenghaas wants to merge 5 commits into
mainfrom
feat/pause-dont-cancel
Open

mikasenghaas wants to merge 5 commits into
mainfrom
feat/pause-dont-cancel

Conversation

@mikasenghaas

@mikasenghaas mikasenghaas commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Summary

  • When the concurrency controller sheds load, the dispatcher now pauses the youngest groups' episodes instead of cancelling them (Dispatcher.pause_inflight). Shedding happens when a queue is still above 50% after a drained trim, or after a third throughput drop.
  • A paused episode sends no new model call, and a call already on the engines finishes. It gives back its permit and keeps all its progress. Paused episodes resume, oldest pause first, before any new episode is admitted (resume_paused).
  • The dispatcher's pause state follows the worker. A pause the worker did not apply (its run was still on the wire) takes its permit back. A pause whose answer was lost is undone with a resume. A resume is repeated until the worker answers.
  • Paused time does not count toward the generation lifetime that the trainer target is derived from.
  • A new env worker pause request goes through Env.pause → EnvClient.pause → pool → worker, to the worker that holds the run. The worker flips that episode's verifiers Pause (feat: pause an episode's model calls verifiers#3284). A pause that arrives before the run's slot exists still applies.
  • The controller's "cancel" tier is renamed "shed" (QUEUE_SHED, trim(shed=)), and overload is no longer a group cancellation reason.
  • On the env side (feat: pause an episode's model calls verifiers#3284), a paused episode's box stops at a memory checkpoint until the episode resumes, so a long pause holds no sandbox compute.
  • New gauge dispatcher/paused/train. docs/inference.md describes the pause.
  • Bumps deps/verifiers to feat: pause an episode's model calls verifiers#3284.

Verification

ScaleSWE A/B on Qwen3.6-35B-A3B (recipes/qwen3.6-35b-a3b/rl.toml + gpu/h200.toml + data/swe.toml, no evals), with the box stop of PrimeIntellect-ai/verifiers#3284. Each arm ran on 1 trainer node + 1 inference node, and both arms ran at the same time. To force an overload, both arms started with initial_inflight = 1024, about 3x the knee this setup settles at. A bench-only patch (not in this PR) made the controller's first queue trim take the shed tier. The controller climbed to about 1,500 episodes in flight and then cut to about 200 in both arms, 90 s apart. Both runs stopped about 97 min after the cut.

cancel (main) pause (this PR)
Episodes shed at the cut 1,287 cancelled 1,302 paused
Model calls in shed episodes 25,846 lost 25,848 kept
Episode time in shed episodes ~257 h lost ~269 h kept
Shed episodes that went on to finish 0 1,283 ok, 1 failed, 18 still running at stop
Boxes stopped while paused – 1,299: stop 7.4 s median, wake 10.5 s median (89.6 s max), 0 wake failures, longest stop 61.5 min
Sandboxes running after the cut (mean) 250 191 (plus 399 stopped on average until the backlog drained)
Time to the 7th trainer batch after the cut 95.7 min 66.0 min (−31%)
Trainer batches in the ~97 min after the cut 7 9
Mean step time, steps fully after the cut 14.7 min (steps 4–9) 11.8 min (steps 3–10)
Tokens generated per trained step after the cut 2.91M 2.19M (−25%)
Max staleness after the cut 2–4 2–9, one higher each step
---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#257de0, #f47230"
---
xychart-beta
    title "Trainer batches finished after the overload cut"
    x-axis "Minutes since the cut" [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
    y-axis "Batches" 0 --> 10
    line [0, 1, 1, 2, 3, 4, 4, 5, 5, 6, 7]
    line [0, 1, 2, 3, 4, 5, 6, 7, 7, 8, 9]
Loading
---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#257de0, #f47230"
---
xychart-beta
    title "Shed episodes that finished (of ~1,300)"
    x-axis "Minutes since the cut" [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
    y-axis "Episodes" 0 --> 1400
    line [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    line [0, 81, 303, 522, 663, 843, 1083, 1209, 1253, 1272, 1282]
Loading

Blue: cancel (main). Orange: pause (this PR).

---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#257de0, #f47230, #00b894"
---
xychart-beta
    title "Sandboxes after the cut (about 1,450 running before it in both arms)"
    x-axis "Minutes since the cut" [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95]
    y-axis "Sandboxes" 0 --> 1300
    line [190, 211, 217, 218, 215, 253, 258, 258, 258, 275, 291, 296, 297, 297, 256, 259, 255, 225, 223]
    line [194, 207, 218, 223, 194, 168, 194, 195, 204, 220, 222, 205, 196, 171, 169, 148, 147, 169, 177]
    line [1206, 1098, 948, 807, 706, 628, 532, 468, 372, 248, 128, 40, 0, 0, 0, 0, 0, 0, 0]
Loading

Blue: running, cancel. Orange: running, pause. Green: stopped at a memory checkpoint, pause. The stopped boxes hold no compute and keep their episodes' progress.

What the A/B shows:

  • Faster steps while the backlog drains. The paused episodes resumed over 62 min. At each batch after the cut, the pause arm was ahead, by up to 30 min at the 7th batch. It used 25% fewer generated tokens per trained step, because the cancel arm regrew the contexts it had thrown away.
  • No extra sandbox compute. The paused boxes stopped within a minute of the cut. The pause arm then ran about as many sandboxes as the cancel arm for 25 min, and fewer after that. The stopped boxes held 646 box-hours that the previous version of this PR kept running.
  • The gain is one-off. It lasts while resumed episodes fill the slots. The pause arm's step 10, after the backlog drained, took 17.7 min.
  • Lower cap with pausing. The controller again held a lower cap with pausing (147–225 against 190–297). Resumed episodes carry long contexts, so each slot generates fewer tokens per second, and the controller rejects its steps up. This takes back part of the gain.
  • Higher staleness. Resumed episodes carry older policy versions. Max staleness rose by one each step with pausing, to 9 at step 10. That is still inside the recipe's max_staleness = 16, so no token was masked. Under a tighter bound, the oldest resumed tokens would be masked.
  • One failed episode in each arm. In the cancel arm, a sandbox create failed. In the pause arm, the platform terminated one box 3 min after it woke, with no termination reason recorded. Its wake had succeeded.

An earlier run without the box stop (boxes of paused episodes kept running) gave the same picture: 2.99M against 2.31M tokens per trained step, and the 7th batch at +90 against +72 min.

Unit tests: tests/unit/orchestrator/test_concurrency.py, including the new test_overload_pauses_the_youngest_groups_and_resumes_them_first. They were run as plain functions on the login node; CI runs the full suites.

🤖 Generated with Claude Code


Note

High Risk
Changes overload recovery, permit accounting, and env-worker RPC ordering for in-flight rollouts—core scheduling under load—with behavior that affects trainer throughput and staleness.

Overview
Overload shedding no longer drops train groups: the concurrency controller’s on_overload hook calls Dispatcher.pause_inflight, which pauses the youngest in-flight train episodes, releases their permits, and later resume_paused (oldest first) before admitting new work. Paused time is tracked (paused_s) so trainer sizing ignores it, and dispatcher/paused/train is exposed as a gauge.

A full pause/resume wire path is added (PauseRequest/PauseResponse, env pool routing like cancel, worker Pause on RunSlot, EnvClient.pause / multi-replica routing). Terminology shifts from cancel to shed (QUEUE_SHED, trim(..., shed=)), and overload is removed as a CancelReason.

Docs in docs/inference.md describe pause semantics (progress kept, no new model calls, permit returned). Tests rename shed expectations and add dispatcher pause/resume edge-case coverage.

Reviewed by Cursor Bugbot for commit ebd1852. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread src/prime_rl/orchestrator/dispatcher.py Resolved
Comment thread src/prime_rl/orchestrator/dispatcher.py Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 901f3a0. Configure here.

Comment thread src/prime_rl/orchestrator/dispatcher.py Resolved
mikasenghaas and others added 4 commits December 3, 2026 21:05
When the concurrency controller sheds load (a queue still above 50 %
after a drained trim, or a third throughput drop), the dispatcher now
pauses the youngest groups' episodes instead of cancelling them. A
paused episode sends no new model call, gives back its permit and
keeps its progress; paused episodes resume, oldest pause first, before
any new episode is admitted.

The env worker pool routes a new `pause` request to the worker holding
the run, which flips the episode's verifiers `Pause`. The controller's
cancelling tier is renamed to shedding, and `overload` is no longer a
group cancellation reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bump verifiers to stop the box of a paused episode at a memory
checkpoint until the episode resumes, so a long pause holds no sandbox
compute.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pause the worker did not apply (its run was still on the wire) left
the episode running without a permit; a resume that failed left it
paused on the worker while its group waited for it. Now a missed
pause takes its permit back, a pause whose answer was lost is undone
with a resume, and a resume is repeated until the worker answers.

Paused time no longer counts toward the generation lifetime that the
trainer target derives from. Bump verifiers for its review fixes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pause that missed or lost its answer took the permit back and queued
a resume even when a later resume or pause for the same episode was
already queued, undoing it. Recover only when no later message follows:
a later one sets both the dispatcher's count and the worker's state.
Bump verifiers for its review fixes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mikasenghaas
mikasenghaas force-pushed the feat/pause-dont-cancel branch from 13e1a2d to 390361e Compare December 3, 2026 21:10
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant