Skip to content

[rl] FULL graphs: cap each capture request at max_model_len - #5488

Merged
felipemello1 merged 4 commits into
mainfrom
felipemello1/inference-graph-sizes/1-drop-full-sizes-above-max-model-len
Nov 6, 2026
Merged

felipemello1 merged 4 commits into
mainfrom
felipemello1/inference-graph-sizes/1-drop-full-sizes-above-max-model-len

Conversation

@felipemello1

@felipemello1 felipemello1 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

TLDR: Under FULL CUDA graphs, vLLM captures each graph with fake requests whose sequence length is the whole graph size. When that is above max_model_len, attention reads past the request's KV block table: an illegal memory access, or a ValueError at engine start for GDN/KDA models. The generator now caps each fake request at max_model_len and keeps graphs up to max_num_batched_tokens, so no step runs eager.

max_model_len 1024, max_num_seqs 8, capture size 2048 (8 requests x 256 tokens)
vLLM's dummy:  each request seq_len 2048 -> reads 128 KV pages from a 64-page row
this PR:       each request seq_len 1024 -> reads its 64 pages
a real step:   8 prompts x 256 tokens, each at most 1024 long -> replays the 2048 graph

Problem

  1. FULL captures a graph for every size up to max_num_batched_tokens (2048 by default). Continuous batching packs several requests into one step, up to that budget.
  2. vLLM captures size N with a dummy batch: N tokens over min(N, max_num_seqs) requests, but every request gets seq_len = N (GPUModelRunner._dummy_run).
  3. Each request's KV block table holds max_model_len tokens. At max_model_len=1024, the 2048 dummy reads 128 pages from a 64-page row.
  4. Cost: on H100, an illegal memory access in the first capture warmup (GPT-OSS debug and Qwen3 debug, TP1). On GB300 with Qwen3.5 (GDN layers), a ValueError at engine start. Only setups with max_model_len below max_num_batched_tokens hit it: the 1024-token CI recipes. Shipped recipes use 2048 or more.

Solution

  1. TorchTitanGPUModelRunner._dummy_run passes vLLM's own profile_seq_lens = max_model_len to a mixed dummy batch bigger than max_model_len. Uniform decode dummies (one token per request) are unchanged.
  2. FULL graph sizes still go up to max_num_batched_tokens, capped at max_num_seqs * max_model_len: no step holds more. So every step the scheduler can build has a graph.
  3. Explicit capture_sizes above max_num_seqs * max_model_len raise.
  4. A TODO at the override: drop it once vLLM caps the dummy's sequence lengths.

Results

max_model_len 1024, FULL, max_num_seqs 8, max_num_batched_tokens 2048 (default)
                                  main                                         this PR
Qwen3.5-0.8B, TP1, 1x GB300       ValueError at engine start:                  captures [1 ... 1024, 2048], generates
                                  "got 2048 and 1280" (GDN block-table check)
  • Earlier head of this PR (graphs capped at max_model_len), H100, TP1: main hit an illegal memory access in capture for GPT-OSS debug and Qwen3 debug (memcheck: 1,056 errors in the paged-KV load); that head ran with 0 errors, but steps above 1024 tokens ran eager.

You may ask:

  • Why not cap the graph sizes at max_model_len, as an earlier version did? Steps that pack more tokens than max_model_len would run eager.
  • Why not fix it in vLLM? It belongs there: the override goes once vLLM caps the dummy (TODO at the site).

NOTE: memcheck was not rerun on this head (the GB300 host has compute-sanitizer 12.8; the stack is CUDA 13.2). Measured on GB300 and H100; not on B200.

Test plan

pytest tests/rl/unit_tests/cpu   # 563 passed; test_cuda_graph_full_mode_caps_sizes_at_the_largest_step
# 1 GPU: a recipe wrapping rl_grpo_qwen3_5_9b_varlen with the Qwen3.5-0.8B generator, TP1, max_context_length 1024
torchrun --nproc-per-node=1 -m torchtitan.rl.generate --module <recipe module> --config <config> --max-num-seqs 8 --max-tokens 16

@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 added this pull request to stack #5496 October 18, 2026 04:18
Under FULL, the generator captures every size up to max_num_batched_tokens
(2048 by default). vLLM captures a size with dummy requests as long as the
size, so when max_model_len is smaller, attention reads past each dummy's KV
block table: an illegal memory access during capture on H100 (GPT-OSS and
Qwen3 debug models at max_model_len 1024).

get_vllm_compilation_config now takes max_model_len. In FULL, the capture cap
is at most max_model_len and larger sizes (explicit capture_sizes, or
max_num_seqs) are dropped with a warning; it raises if none is left.
FULL_DECODE_ONLY is unchanged: its dummies are one-token requests.
@felipemello1
felipemello1 force-pushed the felipemello1/inference-graph-sizes/1-drop-full-sizes-above-max-model-len branch from cd21e39 to cb5ef25 Compare November 6, 2026 01:31
@felipemello1

Copy link
Copy Markdown
Contributor Author

@claude please review

@claude

claude Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

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


Approve (please address the items before merging): 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 fix is at the right layer: torchtitan raises the FULL capture cap past max_model_len, and this filter brings it back under. It updates every callsite. The only missing piece is the upstream TODO. A maintainer still needs to review.

What this PR does. Under FULL CUDA graphs, torchtitan extends the capture cap to max_num_batched_tokens (default 2048). The PR's diagnosis is that vLLM captures each size with dummy requests that long, so when max_model_len is below the cap, those dummies read past their KV block table row. The PR clamps the cap to max_model_len and drops capture sizes above it. FULL_DECODE_ONLY is unchanged. All 3 production/test callers now pass max_model_len=model.max_context_length.

Example.

FULL, max_num_seqs=8, max_num_batched_tokens unset (2048), max_model_len=1024
  before: sizes [1, 2, 4, ..., 1024, 2048]  -> 2048-token dummy reads 128 pages of a 64-page row
  after:  sizes [1, 2, 4, ..., 1024]        -> steps with >1024 tokens run eager
FULL, capture_sizes=[512, 2048], max_model_len=1024
  before: [512, 2048]   after: [512] + warning
FULL, capture_sizes=[2048], max_model_len=1024
  before: [2048]        after: ValueError

Must fix

  1. torchtitan/rl/generator/vllm/config.py:149 -- this works around vLLM's capture dummy run and has no TODO with an upstream vLLM issue link (principle 3). Details inline.

Should consider

  • torchtitan/rl/generator/vllm/config.py:151-163 -- for explicit capture_sizes above max_model_len, raise instead of warning and dropping them. Details inline.
  • torchtitan/rl/generator/vllm/attention/linear_attention.py:156-166 (not in diff) -- the GDN/KDA max_seq_len > block-table capacity check exists to catch exactly this capture overrun ("CUDA graph capture sizes (bounded by max_num_batched_tokens) must not exceed max_model_len"). Its error message names the old bound. With this PR, capture should no longer reach that check, and real requests are bounded by max_model_len. If you agree no other path reaches it, delete it here so the invariant is enforced in one place. Otherwise, update the message to point at this filter.

Questions

  • With max_num_seqs=8 and a 2048-token capture, I'd expect vLLM's _dummy_run to split the tokens across min(num_tokens, max_num_seqs) requests (about 256 each). That would fit in a 1024-token row. Your memcheck shows a 2048-token read. Which vLLM code path builds one request of length size (or sets seq_lens to it)? If the dummy length actually depends on max_num_seqs, the bound size <= max_model_len is stricter than needed. Either way, put the answer in the upstream issue.
Details
  • Gate: the problem is real on main (memcheck shows 1,056 errors). Layer: native vLLM's default cap (min(2 * max_num_seqs, 512)) wouldn't reach max_model_len for these recipes; torchtitan's extension to max_num_batched_tokens is what crosses it, so filtering in our config is reasonable. The vLLM runner still builds an out-of-bounds dummy without complaint, so it's worth reporting upstream.
  • Callsites: engine.py:295, generate.py:176 and test_bitwise_parity.py:262 all pass max_context_length, the same value used for engine_kwargs["max_model_len"]. All 15 test callers updated.
  • The max_num_seqs > max_model_len case also drops the exact decode-batch size under FULL. The controller caps max_num_seqs at 512, so this only affects max_model_len < 512.
  • The new test guards an otherwise silent out-of-bounds read: the 1024-token CI recipes don't fault. It earns its place.

Not verified: vLLM's dummy-run request layout (vLLM isn't installed here), and the GPU results.

Comment thread torchtitan/rl/generator/vllm/config.py Outdated
Comment on lines +149 to +150
if self.mode == "FULL":
removed_sizes = [size for size in sizes if size > max_model_len]

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 works around vLLM behavior: during FULL capture, the dummy run builds requests longer than max_model_len, so they overrun the KV block table. The PR description says so ("That's vLLM's runner"), but the code has no TODO, and CLAUDE.md principle 3 requires a TODO with an upstream issue link for vLLM gaps. Without one, nobody will know to delete this filter once vLLM caps the dummy length. It also tells readers where the "dummy requests as long as the size" claim comes from (please name the vLLM function in the issue).

Suggested change
if self.mode == "FULL":
removed_sizes = [size for size in sizes if size > max_model_len]
if self.mode == "FULL":
# TODO: vLLM's FULL capture dummy run builds requests as long as the capture
# size without capping them at max_model_len. Drop this once vLLM caps them:
# <vLLM issue link>
removed_sizes = [size for size in sizes if size > max_model_len]

Comment thread torchtitan/rl/generator/vllm/config.py Outdated
Comment on lines +151 to +163
if removed_sizes:
logger.warning(
"CUDA graph capture sizes %s are removed because they exceed "
"max_model_len %d",
removed_sizes,
max_model_len,
)
sizes = [size for size in sizes if size <= max_model_len]
if not sizes:
raise ValueError(
f"No CUDA graph capture sizes are <= max_model_len {max_model_len}; "
f"got capture_sizes {self.capture_sizes}"
)

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.

Should consider: on the auto-derived path, line 130 already caps cap at max_model_len. So this block only drops something when (a) the user set capture_sizes explicitly, or (b) max_num_seqs > max_model_len. In case (a), the user asked for a size that can't be captured, and principle 8 says to raise rather than warn and continue. No in-repo recipe sets capture_sizes, so raising breaks nothing. The "Why not raise" argument in the description covers only the auto path (the 1024-token CI recipes). One option: raise when any explicit size is above max_model_len, and keep the silent filter for the auto path only. That also removes the "none left" branch for explicit sizes. (The ESP filter below does warn-and-drop on explicit sizes too, but that's pre-existing, so not this PR's concern.)

Address review:
- TODO naming vLLM's GPUModelRunner._dummy_run, which gives every capture
  dummy request a sequence length equal to the capture size.
- Explicit cuda_graph.capture_sizes above max_model_len now raise in FULL mode
  instead of being dropped with a warning. Auto sizes stop at the cap.
- The GDN/KDA block-table check's message points at VLLMCudaGraphConfig.
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: @claude please review again. Changes in aa074ae:

  • TODO at the cap naming vLLM's GPUModelRunner._dummy_run. The upstream issue link is pending (Felipe files it).
  • Explicit capture_sizes above max_model_len now raise in FULL. Auto sizes stop at the cap; the drop-and-warn block is gone.
  • The GDN/KDA block-table check's message now points at VLLMCudaGraphConfig. Kept the check: it guards input from vLLM.
  • Your question: the dummy length does not depend on max_num_seqs. A non-uniform capture of N tokens splits them over min(N, max_num_seqs) requests, but sets every request's seq_lens to max_query_len = N (vllm/v1/worker/gpu_model_runner.py lines 5917, 5943 and 6056 at the pinned 9f03b51; same on vLLM main).

@claude

claude Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

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


Approve (please add the vLLM issue link to the TODO before merging): 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 add the vLLM issue link to the TODO before merging. aa074ae resolves both earlier findings at HEAD and adds no new problems. A maintainer still needs to review.

Earlier items

  • Must fix, TODO at the vLLM workaround (config.py:130-132): partly resolved. The TODO is there and names GPUModelRunner._dummy_run, but it still has no upstream issue link. Principle 3 asks for one. Since you're filing the issue, add the link in this PR, not in a follow-up.
  • Should consider, raise on explicit sizes: resolved. config.py:140-144 raises in FULL when max(capture_sizes) > max_model_len. Auto sizes stop at cap. The drop-and-warn block and its "none left" branch are gone.
  • Should consider, GDN/KDA check: resolved. The message now points at VLLMCudaGraphConfig. Keeping the check as a guard on vLLM's input is reasonable.
  • Question about the dummy length: answered. Each dummy's seq_lens is max_query_len = N, whatever max_num_seqs is, so the size <= max_model_len bound is tight, not stricter than needed. Put the three line references in the upstream issue.

Example (HEAD)

FULL, max_num_seqs=8,    max_model_len=1000, auto     -> [1, 2, ..., 512, 1000]
FULL, max_num_seqs=1500, max_model_len=1000, auto     -> [..., 512, 1000]   (1500 dropped by the cap filter)
FULL, capture_sizes=[512, 2048], max_model_len=1000   -> ValueError
FULL_DECODE_ONLY, max_num_seqs=1500                   -> [..., 1024, 1500]  (unchanged)
Details
  • config.py:156: the new size <= cap filter only removes anything in FULL when max_num_seqs > max_model_len. In FULL_DECODE_ONLY cap == max_num_seqs, so it's a no-op there. The ESP divisibility filter runs after it. Powers of 2 up to 512 survive any power-of-2 ESP degree, so the "no sizes left" raise can't newly trigger for the auto path.
  • Callsites: engine.py:295 and generate.py:176 pass the same max_context_length they put in engine_kwargs["max_model_len"] (engine.py:269, generate.py:167). So does test_bitwise_parity.py:262. No in-repo recipe sets capture_sizes, so the new raise breaks no recipe. The GPU GDN tests build vLLM CompilationConfig directly and skip this path.

Not verified: the vLLM _dummy_run line references (vLLM isn't installed here), and the GPU results.

@felipemello1
felipemello1 marked this pull request as ready for review November 6, 2026 02:10
@pytorch-bot pytorch-bot Bot added the ciflow/fake-pg Run 1-GPU Fake PG integration tests label Nov 6, 2026
@github-actions
github-actions Bot requested review from liangel-02 and pzhan9 November 6, 2026 02:11
@tianyu-l

tianyu-l commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

@claude

The PR's diagnosis is that vLLM captures each size with dummy requests that long, so when max_model_len is below the cap, those dummies read past their KV block table row.

This may make sense, but I want to check one thing.

max_context_lenghth=1024 means the longest causal KV should be capped at 1024, but model input, at least for training, could be more than that, because of packing.

Are we saying that in inference, continuous batching would never pack multiple prefill sequences together as one model input? It'd be hard to believe for me.

But if that's not the case, why cudagraph capture would cap at max_context_length, instead of real possible longest number of tokens, potentially with many prefill requests packed together?

@claude

claude Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 45s —— View job


You're right: continuous batching does pack several prefills into one step, up to max_num_batched_tokens, and this PR doesn't change that. The max_model_len bound is there because vLLM's capture dummies are built wrong, not because real steps are that small. It's a workaround, and the cost is that large packed steps run eager.

Details

What the PR caps, and what it doesn't

  • Scheduler budget: unchanged. engine.py:274-275 and generate.py:169-170 still pass max_num_batched_tokens (default 2048) to vLLM. A step can still pack, say, 8 prefills of 256 tokens = 2048 tokens.
  • CUDA graph sizes: capped. Under FULL, config.py:133 stops graph capture at min(max(max_num_seqs, max_num_batched_tokens), max_model_len). A step bigger than the largest captured size runs eager. It still runs correctly, just without a graph. The PR description lists this as the cost: "a step with more tokens than max_model_len (several prompts at once) runs eager."

Why capture can't go past max_model_len today

The problem is how vLLM builds its capture inputs. In GPUModelRunner._dummy_run, capturing size N splits the N tokens over min(N, max_num_seqs) dummy requests but sets each request's seq_lens to N (Felipe's line references: gpu_model_runner.py 5917, 5943, 6056 at the pinned commit).

max_model_len=1024 (64 pages of 16 tokens per block-table row), capture N=2048, max_num_seqs=8
  real packed step:  8 requests x 256 tokens, each seq_len <= 1024   -> fits in its row
  vLLM capture dummy: 8 requests x 256 tokens, each seq_len = 2048   -> reads 128 pages from a 64-page row

A real 2048-token step is always valid: the scheduler keeps every request's KV at or below max_model_len. So a graph captured at 2048 would replay correctly on it. The only thing that overruns the block table is the dummy used to capture that graph.

So the bound is too strict for real inputs

You're correct that the right capture cap is max_num_batched_tokens. max_model_len is a stand-in that stops the bad dummy from being built. It only matters when max_model_len is below the capture cap. Every shipped recipe uses at least 2048, so in practice it's the 1024-token CI recipes. Once vLLM caps each dummy's seq_lens at max_model_len (or at a realistic per-request length), the bound can go and capture can return to max_num_batched_tokens. That's what the TODO at config.py:130-132 says.

Two follow-ups I'd suggest:

  1. File the upstream vLLM issue with those line references, and put its link in the TODO (already asked for in the last review).
  2. Reword the TODO and the docstring at config.py:89-91 so they say the bound is a capture-time workaround and that real packed steps above max_model_len are valid but run eager. As written, "one past max_model_len overruns its KV block table" can be read as a limit on real inputs. My earlier review summary has the same ambiguity.

Not verified: the vLLM _dummy_run line numbers (vLLM isn't installed here). I'm relying on Felipe's reading plus the memcheck result in the PR description.

@tianyu-l

tianyu-l commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

It's a workaround, and the cost is that large packed steps run eager.

Are we sure this is OK and doesn't bring regression on some workload?

Also it seems we should fix the problem in vllm rather than here.

…capture sizes

Continuous batching packs several requests into one step, up to
max_num_batched_tokens. Capping capture sizes at max_model_len left steps
above it without a graph (eager).

- TorchTitanGPUModelRunner._dummy_run passes vLLM's profile_seq_lens =
  max_model_len to a mixed dummy batch larger than max_model_len. vLLM gives
  each dummy request seq_len = the whole batch, past its KV block table.
- VLLMCudaGraphConfig: FULL captures up to max_num_batched_tokens again,
  bounded by max_num_seqs * max_model_len (no step holds more). Explicit sizes
  above that raise.
@felipemello1

Copy link
Copy Markdown
Contributor Author

Reply from claude: You're right on both points, thanks. Changed in 8aaca73.

why cudagraph capture would cap at max_context_length, instead of real possible longest number of tokens

It shouldn't. Continuous batching packs requests into one step up to max_num_batched_tokens. The PR now keeps graphs up to that budget, capped at max_num_seqs * max_model_len (the most tokens a step can hold). So no step runs eager.

Are we sure this is OK and doesn't bring regression on some workload? ... fix the problem in vllm

The only bad input was the capture dummy: vLLM gives each dummy request seq_len = the whole capture size (GPUModelRunner._dummy_run, vllm/v1/worker/gpu_model_runner.py lines 5917, 5943, 6056 at the pinned 9f03b51). The PR now uses vLLM's own profile_seq_lens argument (same function, line 6036) to cap each dummy request at max_model_len. A real packed step has every request within max_model_len, so the captured graph replays it correctly.

Check, 1x GB300, Qwen3.5-0.8B, max_model_len 1024, default 2048-token budget, FULL:

  • main: fails at engine start (GDN block-table check: sequence length 2048 > capacity 1280).
  • this head: captures [1, 2, 4, ..., 1024, 2048] and generates.

Agreed it belongs in vLLM: the override has a TODO to go once vLLM caps the dummy, and a vLLM issue is drafted.

@claude please review again (head 8aaca73).

@claude

claude Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

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


Approve (please add the vLLM issue link to the TODO and an H100 rerun of the original failing config on this head before merging): 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. 8aaca73 fixes the bad input itself, the capture dummy, so FULL graphs again cover the full max_num_batched_tokens budget. This answers tianyu-l's point that real steps pack several prefills. A maintainer (tianyu-l) still needs to review.

What this PR does. TorchTitanGPUModelRunner._dummy_run overrides vLLM's private _dummy_run. For a mixed (non-uniform-decode) dummy batch above max_model_len, it passes profile_seq_lens=max_model_len, so no dummy request reads past its KV block table row. FULL capture sizes go up to max_num_batched_tokens, capped at max_num_seqs * max_model_len. Explicit sizes above that cap raise.

Example.

FULL, max_model_len=1024, max_num_seqs=8, budget 2048
  main:     capture 2048 as 8 x 256 tokens, each seq_len 2048 -> 128 pages from a 64-page row
  previous: sizes capped at 1024 -> steps of 1025..2048 tokens run eager
  HEAD:     capture 2048 as 8 x 256 tokens, each seq_len 1024; sizes [1, ..., 1024, 2048]
FULL, max_num_seqs=1, max_model_len=1000 -> sizes [..., 512, 1000]; capture_sizes=[2048] -> ValueError

Must fix

  1. torchtitan/rl/generator/vllm/worker.py:130: still open. The TODO has no vLLM issue link. It now also covers overriding a private vLLM method (_dummy_run) and its profile_seq_lens kwarg (principle 3). Add the link once the drafted issue is filed.
  2. Evidence at this head for the original failure: the Results section shows only Qwen3.5 (GDN) on GB300. The illegal memory access on H100 (GPT-OSS debug and Qwen3 debug, TP1, max_model_len 1024) was only checked against the earlier head, which never captured 2048. This head captures 2048 again through a different mechanism. Rerun one of those configs on this head without memcheck and add the result. The original fault reproduced without memcheck, so a clean run is enough.

Should consider

  • torchtitan/rl/generator/vllm/worker.py:131-136: in an edge case, the largest dummy request can still get a query longer than its seq_len. Make that case raise. Details inline.
Details
  • Maintainer comments (tianyu-l): "cap at the real longest step, not max_context_length" is resolved in code (config.py:133). "Regression on some workload?": at HEAD, no step runs eager that didn't on main, and graphs up to the budget are captured as on main. The only change is the dummy's seq_len during capture. "Fix it in vLLM": agreed by the author; it depends on item 1.
  • Why the max_num_seqs * max_model_len cap is needed and not just cosmetic: with max_num_seqs=1, a 2048 capture would be one request with query 2048 and seq_len 1024. The cap prevents that.
  • Uniform-decode dummies keep seq_len = 1, and an explicit profile_seq_lens (vLLM's profile_run) is passed through. Dummies at or below max_model_len are unchanged.
  • linear_attention.py:164-165: the new message is accurate. Keeping the check as a guard is fine.
  • The new CPU test guards the cap arithmetic. The override itself has no CPU coverage; the GB300 run is its evidence.

Not verified: vLLM's _dummy_run request split and how it applies profile_seq_lens (vLLM isn't installed here), and all GPU results.

Comment on lines +131 to +136
if (
profile_seq_lens is None
and not uniform_decode
and num_tokens > self.max_model_len
):
profile_seq_lens = self.max_model_len

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.

Should consider (unverified: depends on how vLLM splits the dummy's tokens). The max_num_seqs * max_model_len cap in config.py:133 guarantees the average dummy request fits in max_model_len, not the largest one. If vLLM gives the remainder to the last request ([n // r] * r, last += n % r), a size near the cap that max_num_seqs doesn't divide gives that request a query longer than the seq_len set here:

max_num_seqs=3, max_model_len=1000, max_num_batched_tokens=2999 -> cap 2999
dummy: queries [999, 999, 1001], each seq_len 1000 -> last query_len > seq_len

Then num_computed_tokens goes negative for that request during capture. Recipes with power-of-2 max_num_seqs don't hit this, so a full fix isn't needed. Make it fail loudly instead, either by asserting here that the largest dummy request fits (num_tokens // num_reqs + num_tokens % num_reqs <= self.max_model_len, with num_reqs = min(num_tokens, self.max_num_reqs)) or by tightening the cap in config.py.

@felipemello1 felipemello1 changed the title [rl] Drop FULL CUDA graph capture sizes above max_model_len [rl] FULL graphs: cap each capture request at max_model_len Nov 6, 2026
Comment on lines +126 to +128
max_model_len=1024, capture 2048 tokens as 8 requests of 256
vLLM: each seq_len 2048 -> reads 128 KV pages from a 64-page row
here: each seq_len 1024 -> reads its 64 pages

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.

hmmmm really sounds a vllm "bug / feature", which we would prefer not to play with.

If you created a vllm issue, could you link it here?

@felipemello1
felipemello1 merged commit da4cd4b into main Nov 6, 2026
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