[None][feat] DSA: adaptive indexer prefill chunk size for long sequences - #15683
Merged
lfr-0531 merged 1 commit intoJun 28, 2026
Conversation
The indexer's fp8_fp4_mqa_logits / fp8_mqa_logits activation memory scales with indexer_max_chunk_size * K_compressed (the compressed KV length of the current request). For very long sequences this can OOM: e.g. a ~500K-token request with the default 32K chunk size needs ~16GB of activation memory. The previous workaround was to uniformly lower indexer_max_chunk_size (e.g. to 8K), but that costs prefill throughput for the common case where the vast majority of requests are far below these lengths. Instead, select the indexer prefill chunk size per-batch based on the largest compressed KV length among the context requests: - max K_compressed > 512K -> 8K chunk - 256K <= max K_compressed <= 512K -> 16K chunk - max K_compressed < 256K -> configured chunk size (unchanged) The heuristic only ever reduces the configured chunk size (never increases it), so the common case keeps its larger, higher-throughput chunk. It is applied only on the indexer's own chunking path (not the MLA chunked-prefill path, which already bounds chunk size) and is safe to vary per-batch because the prefill path does not use CUDA graphs. Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com> (cherry picked from commit ff0e8a5)
longlee0622
approved these changes
Jun 28, 2026
lfr-0531
merged commit Jun 28, 2026
54efe57
into
NVIDIA:feat/deepseek_v4_bench
9 of 10 checks passed
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.
@coderabbitai summary
Description
Cherry-pick of the core change from #15459 (already merged to
feat/deepseek_v4) ontofeat/deepseek_v4_bench. The CI-infra-only changes from that PR (bandit# nosec, thegb200-x4-splitnode-pool swap) are intentionally not included — this is thedsa.pychange only.The DSA indexer's
fp8(_fp4)_mqa_logitsactivation memory scales withindexer_max_chunk_size * K_compressed(the compressed KV length of the request). For very long sequences this OOMs — e.g. a ~500K-token request at the default 32K chunk size needs ~16GB of activation memory. Uniformly loweringindexer_max_chunk_size(e.g. to 8K) avoids the OOM but sacrifices prefill throughput for the common case, where the vast majority of requests are far below these lengths.This change makes the indexer prefill chunk size adaptive per-batch, keyed on the largest compressed KV length among the context requests:
> 512K[256K, 512K]< 256KImplementation notes:
select_indexer_chunk_size(configured_chunk_size, max_k_compressed)indsa.py; thresholds centralized in_INDEXER_CHUNK_SIZE_HEURISTICfor easy tuning.indexer_max_chunk_sizestill acts as an upper bound.Indexer.prepare_for_chunked_prefill, on the indexer's own chunking path only. The MLA chunked-prefill path is untouched (it already bounds the chunk to the MLA chunk size).max K_compressedis read fromindexer_params.kv_lens(already available host-side during prefill prepare; no extra device sync).Test Coverage
tests/unittest/_torch/attention/sparse/dsa/test_dsa_indexer.py.feat/deepseek_v4; this PR is an identical cherry-pick of thatdsa.pychange.PR Checklist
Please review the following before submitting your PR:
PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.
PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.
Test cases are provided for new code paths (see test instructions)
Any new dependencies have been scanned for license and vulnerabilities
CODEOWNERS updated if ownership changes
Documentation updated as needed
Update tava architecture diagram if there is a significant design change in PR.
The reviewers assigned automatically/manually are appropriate for the PR.
Please check this after reviewing the above items as appropriate for this PR.
GitHub Bot Help
To see a list of available CI bot commands, please comment
/bot help.