Repository navigation
[TRTLLM-17086][feat] Agg Helix KV cache, part 1: prefill allocation and sizing - #20923
Merged
asfiyab-nvidia merged 7 commits intoOct 24, 2026
Merged
Conversation
Narrow the Helix guard in KVCacheManagerV2.resize_context to requests sliced to this rank's tokens, so requests holding the full prompt on every rank can allocate KV during prefill. Reject Helix outside disaggregated generation servers at startup until aggregated Helix serving is complete. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Asfiya Baig <asfiyab@nvidia.com>
…v var Keep rejecting Helix outside disaggregated generation servers at startup, but let developers bypass the check with TRTLLM_HELIX_AGG_EXPERIMENTAL=1 while aggregated Helix serving is being built. Signed-off-by: Asfiya Baig <asfiyab@nvidia.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Under aggregated Helix, lower the default free_gpu_memory_fraction to 0.6 so the unprofiled KV budget leaves room for prefill activations. Add MambaHybridCacheManagerV2 quota-to-token tests under Helix. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Asfiya Baig <asfiyab@nvidia.com>
Route aggregated Helix requests through merge_requests_to_llm_requests so every CP rank holds the full prompt; disaggregated Helix keeps slicing via merge_helix_requests. The resize_context guard now raises only under disaggregated Helix, so every rank reaches the same decision. Signed-off-by: Asfiya Baig <asfiyab@nvidia.com>
Signed-off-by: Asfiya Baig <asfiyab@nvidia.com>
Aggregated Helix sizes prefill KV in global ledger blocks, which only KVCacheManagerV2 keeps. Reject any other resolved manager, including a V2 manager that fell back to V1, when the KvCacheCreator is built. Disaggregated Helix keeps V1. Add the Helix fields that the startup gate and the request routing now read to the test fakes that stand in for Mapping and PyExecutor. Signed-off-by: Asfiya Baig <asfiyab@nvidia.com>
The aggregated Helix context phase gathers cached KV across CP ranks only in the chunked-context path, so reject aggregated Helix without chunked prefill when the KvCacheCreator is built. Read the setting from the model engine, which reflects the MLA SM-version fallback. Signed-off-by: Asfiya Baig <asfiyab@nvidia.com>
asfiyab-nvidia
requested review from
JunyiXu-nv,
SimengLiu-nv,
Tabrizian,
lori-ren,
lowsfer and
reasonsolo
October 24, 2026 00:09
1 task done
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: [TRTLLM-17086][feat] Agg Helix KV cache, part 1: prefill allocation and sizing
Epic: TRTLLM-17086 (part of TRTLLM-16624, Helix for aggregated serving), design doc
Tickets: TRTLLM-17124, TRTLLM-17126
Summary
First step toward running Helix context parallelism in aggregated serving, on the KV cache side. In aggregated serving, requests now keep the full prompt on every CP rank instead of being sliced per rank, so KVCacheManagerV2 can allocate prefill KV in global ledger blocks. Agg Helix stays off by default until it is validated end to end.
Changes
TRTLLM-17124: allow prefill KV allocation for agg Helix requests
merge_requests: aggregated Helix requests are merged withmerge_requests_to_llm_requests, so every CP rank holds the full prompt (prompt_len == total_input_len_cp). Disaggregated Helix still usesmerge_helix_requests, which deals the prompt's blocks round-robin across ranks.PyExecutorpassesis_disagg=self.kv_cache_transceiver is not None.KVCacheManagerV2.resize_context: the Helix guard now raises only under disaggregated serving (self.is_disagg), where requests hold just this rank's slice. Aggregated requests allocate as usual, sized in global ledger tokens. The check uses the serving mode rather than the two lengths, so every rank reaches the same decision.create_py_executor: Helix outside disaggregated serving fails at startup unlessTRTLLM_HELIX_AGG_EXPERIMENTAL=1(development only).TRTLLM-17126: Helix KV cache sizing for aggregated serving
_configure_helix_kv_cache_capacity: under agg Helix, afree_gpu_memory_fractionof 0.9 (the default) is lowered to 0.6, with a warning, to leave room for prefill activations, since Helix skips memory profiling. The check compares values becausetrtllm-servealways passes 0.9, so an explicit 0.9 is lowered too; any other fraction is used as given. An explicitmax_tokensormax_gpu_total_bytesstill overrides it.Temporary pieces (removed in TRTLLM-17127)
TRTLLM_HELIX_AGG_EXPERIMENTAL._HELIX_AGG_FREE_GPU_MEMORY_FRACTION), which profiling will replace.Not affected
Disaggregated Helix: requests are still sliced by
merge_helix_requests, generation servers never callresize_context, and the fraction override applies only when the server is not disaggregated.Test Coverage
test_request_utils.py: aggregated Helix keeps the full prompt on every CP rank (prompt_len == total_input_len_cp); the existing sliced case now runs as disaggregated.test_kv_cache_manager_v2_helix_superblock.py: aggregated Helix request accepted; disaggregated Helix request rejected, including a slice that equals the full prompt.test_mamba_cache_manager_v2_helix.py(new):MambaHybridCacheManagerV2quota-to-token conversion under Helix for cp=2/4/8. It returns whole ledger blocks of global tokens and charges KDA state per request slot.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)
If PR introduces API changes, an appropriate PR label is added - either
api-compatibleorapi-breaking. Forapi-breaking, includeBREAKINGin the PR title.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.