[None][fix] Size the trtllm-gen multi-CTA KV counter buffer for beam search - #17014
Draft
pranav-nvidia wants to merge 1 commit into
Draft
[None][fix] Size the trtllm-gen multi-CTA KV counter buffer for beam search#17014pranav-nvidia wants to merge 1 commit into
pranav-nvidia wants to merge 1 commit into
Conversation
…search The trtllm-gen decode kernel keeps one multi-CTA KV counter per attention head per decoder sequence, but the buffer was sized from the request count alone. Beam search expands each request into beam_width sequences, so the kernel rejects the buffer at warmup with TVM_FFI_CHECK(multi_ctas_kv_counter_size >= counter_bytes) The max(..., multi_processor_count) floor hides the missing factor at small batch, so this only reproduces past a threshold: with 6 decoder heads and 148 SMs, beam 2 passes up to max_batch_size 8 and fails from 16 up. Every in-tree beam-search test runs below that threshold, so CI does not cover it. Signed-off-by: Pranav Shrestha <254760092+pranav-nvidia@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The trtllm-gen decode kernel keeps one multi-CTA KV counter per attention head per decoder sequence.
_get_multi_ctas_kv_counter_sizewas sized frommetadata.max_num_requestsalone, omitting the beam-width expansion, so beam search rejects the buffer at warmup with:The
max(..., multi_processor_count)floor hides the missing factor at small batch, so the failure appears as a threshold rather than a universal beam-search break. With 6 decoder heads on a 148-SM part at beam 2:max_batch_sizemax(6B, 148)6·B·2Not model-specific: any model reaching
num_heads · batch · beam_width > SM countunder beam search hits it. Present since the function was introduced in487330e8a03(2026-06-09); ships in v1.3.0rc19–rc22.The fix passes
metadata.max_num_requests * metadata.beam_widthat the single call site. Sizing up is safe — the kernel check is>=, and for cross-attention (K/V not beam-packed) the only cost is4 · num_heads · batch · (beam − 1)bytes.Test Coverage
tests/unittest/_torch/attention/test_fmha_page_index.py— two cases: the old sizing under-allocates for a beam-expanded batch above the SM floor, and the multi-processor floor is preserved at batch 1.max_batch_size16 and 32 go fail → pass, 8 stays passing.Why CI missed it: every in-tree beam test sits in the masked region — the disagg beam test uses
max_beam_width=2at low concurrency,test_cli_flowbeam tests target the legacy CLI, and the Whisperbeam_searchcase usesmax_batch_size=2.PR Checklist
[JIRA/NVBUG/None][type] summaryGitHub Bot Help
/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...