Skip to content

[rl] Generator aborts a request whose caller left (11/14) - #5509

Closed
felipemello1 wants to merge 7 commits into
felipemello1/http/3-generate-over-httpfrom
felipemello1/http/5-abort-when-caller-left
Closed

felipemello1 wants to merge 7 commits into
felipemello1/http/3-generate-over-httpfrom
felipemello1/http/5-abort-when-caller-left

Conversation

@felipemello1

@felipemello1 felipemello1 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

TLDR: A generate call cancelled after the engine loop took its request (e.g. a Verifiers harness that hit timeout.rollout closed its POST) now aborts the request on every rank of its replica and frees its KV, instead of generating it to the end for nobody.

Stack (14 PRs, merge bottom-up; this PR is in bold)

PRs 2-7 don't need the HTTP design and can be reviewed now. PRs 8-14 wait on the design discussion on PRs 9 and 10.

# PR Independent? Needs (stack positions)
1 Verifiers 0.4.0 (merged) yes —
2 Verifiers: release each finished rollout's routing session yes — (resolves its test overlap with 1)
3 Verifiers generation server: no per-request access log yes —
4 Verifiers generation server: faster request path, required sampling params yes — (resolves its test overlap with 1-3)
5 Rollout workers write structured logs yes —
6 Drain in-flight rollouts during shutdown yes —
7 Rollouts that fail outside the policy are recorded, not trained no 2 (resolves its overlap with 4-6)
8 Generator drains itself before a hot_swap=False weight load yes —
9 Move GenerationServer to torchtitan/rl/generator yes, in code — (it moves the file 3 and 4 edit)
10 Every generate call goes over HTTP to its generator no 1, 2, 3, 4, 7, 8, 9
11 Generator aborts a request whose caller left no 10
12 Cancel a rollout group on its worker no 5, 6, 7, 10
13 Run Verifiers groups in rollout workers no 7, 10, 12
14 Optional native rollout timeout no 7, 13

Problem

  1. The cancel reaches the generator. Since PR 10, a caller that leaves closes its HTTP connection, and the server cancels Generator.generate.
  2. Queued requests are skipped. The engine loop drops a request whose caller left while it was still on the queue.
  3. Taken requests run to the end. GenerationEngine has no abort, so a taken request keeps a sequence's KV and decode steps until it ends.
  4. Draining loads too. With hot_swap=False, a request parked by a draining load whose caller left is still generated after the load.

Solution

  1. One message. A generate cancelled after the loop took its request puts a RequestAbortMessage(request_id) on the queue.
  2. Parked: rank 0 fails its reply and drops it; it never reaches an engine.
  3. Admitted: the next decision's aborted_request_ids makes every rank call engine.abort_requests(ids); rank 0 fails the reply and frees its DP reservation.
  4. Engine API: GenerationEngine.abort_requests(ids) returns the ids it ran (default []); VLLMEngine aborts one id per call, so every TP rank frees blocks in the same order.
  5. Unchanged: calls that aren't cancelled, requests still on the queue, loads, routing.
caller leaves -> EngineLoop.generate cancelled
  still on the queue        -> the loop skips it                                    (unchanged)
  taken, parked by a drain  -> rank 0 fails it; never admitted after the load       (new)
  admitted                  -> next decision's aborted_request_ids
                               every rank: engine.abort_requests(ids)                (new)
                               the TP rank 0 that ran it reports it -> rank 0 fails the reply

Results
Numerics: bitwise vs main when no call is cancelled; a cancel removes that request from the batch, so other requests' tokens can differ, as with any load change.

GPU, with PRs 12 and 14 (native rollouts reach this path only through a group cancel or a rollout timeout):
alphabet sort, Qwen3-0.6B, trainer TP2 + one TP4 generator, rollout_timeout_s=0.5 (generate p50/p99 0.25/0.50 s), 5 steps
training steps                            5 of 5, no errors
rollout timeouts (worker log)             568
decisions with aborts                     14; every one aborted more than one request
per TP rank: ids asked / aborted          490 / 300 (the rest had already finished)
TP ranks agreeing on every decision       4 of 4

You may ask:

  • Why exactly once with DP > 1? vLLM drops a request from its id map inside the step() that finishes it, so an abort after the finish (or on a replica that doesn't run it) skips it; finish and abort reports travel on one port from the same sender.
  • Why not report aborts through process_rejected_requests? It logs one warning per request, and aborts come in bursts.
  • Why not keep the partial completion? The caller left, so nobody reads it.

NOTE:

  • An aborted admitted request no longer counts toward a draining load, so the load stops waiting for work nobody wants.
  • Native rollouts and shutdown cancel a generator call only with PR 12, since a Monarch call runs to completion even when its caller is cancelled. With it, a native shutdown aborted 68 in-flight requests on 6 TP1 generators within 100 ms of post-training validation's start.
  • DP > 1 and Verifiers-harness timeouts are tested on CPU only.
  • VLLMEngine.abort_requests reads vLLM internals (OutputProcessor.external_req_ids, LLMEngine.abort_request); a CPU test fails if either moves.
  • A request that finishes in the same burst its caller leaves resolves normally; its abort is a no-op.

Test plan

pytest tests/rl/unit_tests/cpu   # verifiers 0.4.0, at this position (local, 11-04): 634 passed, 4 skipped
  • 6 new in test_engine_loop.py: parked request never admitted (draining and non-draining load, DP=2), admitted request aborted, abort after the finish is a no-op, cancel while the generator closes, HTTP client hang-up after admission, peer DP replica aborts.
  • 4 new in test_generator.py: only this replica's requests aborted (one id per vLLM call, in order), vLLM still has the internals it reads, aborted replies fail without a warning, peer TP rank 1 doesn't report.

@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/3-generate-over-http branch from 66f7d01 to 15817d3 Compare October 18, 2026 23:31
@felipemello1
felipemello1 force-pushed the felipemello1/http/5-abort-when-caller-left branch from 0309c31 to e1ce3b5 Compare October 18, 2026 23:31
@felipemello1
felipemello1 added this pull request to stack #5513 October 18, 2026 23:32
@felipemello1
felipemello1 force-pushed the felipemello1/http/3-generate-over-http branch from 15817d3 to 9df6ee4 Compare October 19, 2026 00:38
@felipemello1
felipemello1 force-pushed the felipemello1/http/5-abort-when-caller-left branch from e1ce3b5 to 18f4e80 Compare October 19, 2026 00:38
@felipemello1
felipemello1 force-pushed the felipemello1/http/3-generate-over-http branch from 9df6ee4 to d0ac2ea Compare October 19, 2026 01:16
@felipemello1
felipemello1 force-pushed the felipemello1/http/5-abort-when-caller-left branch from 18f4e80 to 3cd6910 Compare October 19, 2026 01:16
@felipemello1 felipemello1 changed the title [rl] Generator aborts a request whose caller left [rl] Generator aborts a request whose caller left (10/14) Oct 19, 2026
@felipemello1
felipemello1 force-pushed the felipemello1/http/5-abort-when-caller-left branch from 3cd6910 to feaee20 Compare October 22, 2026 23:31
@felipemello1
felipemello1 force-pushed the felipemello1/http/3-generate-over-http branch from 2703106 to f35c21c Compare October 23, 2026 07:34
@felipemello1
felipemello1 force-pushed the felipemello1/http/5-abort-when-caller-left branch from feaee20 to 115c064 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/3-generate-over-http branch from f35c21c to a683e38 Compare October 27, 2026 14:31
@felipemello1
felipemello1 force-pushed the felipemello1/http/5-abort-when-caller-left branch from 115c064 to 6c784be Compare October 27, 2026 14:31
@felipemello1 felipemello1 changed the title [rl] Generator aborts a request whose caller left (10/14) [rl] Generator aborts a request whose caller left (11/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/3-generate-over-http branch from a683e38 to 6fe0b09 Compare November 5, 2026 00:37
@felipemello1
felipemello1 force-pushed the felipemello1/http/5-abort-when-caller-left branch from 6c784be to 4d94d82 Compare November 5, 2026 00:38
@felipemello1
felipemello1 removed this pull request from stack #5639 November 5, 2026 07:53
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: Superseded: this PR aborts a request when its HTTP caller disconnects, and that HTTP path (#5506) is closing in favor of #5990's look-aside routing and the #5520 -> #5876 stack. Aborting a generator request whose caller left is still worth doing, since a cancelled group's requests keep their KV until they finish; it can come back as a follow-up on #5990's API. Closing.

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