[None][feat] Add KV cache manager V2 support for DSA - #16060
Conversation
8ff6b1c to
69404fe
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #58215 [ run ] triggered by Bot. Commit: |
|
PR_Github #58215 [ run ] completed with state
|
69404fe to
767b3be
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #60273 [ run ] triggered by Bot. Commit: |
|
PR_Github #60273 [ run ] completed with state
|
767b3be to
eeadb01
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #60657 [ run ] triggered by Bot. Commit: |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe PR adds DSA support for V1 and V2 KV cache managers. It updates indexer cache sizing and mappings, draft replay metadata handling, stable pool mapping, manager selection, model defaults, tests, and documentation. ChangesDSA cache manager contracts and V2 implementation
Indexer offsets and full-KV mappings
KV cache manager selection and compatibility
Stable pool representatives and mapping validation
Indexer mappings and draft replay restoration
Kernel documentation and supporting metadata
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant LLMConfig
participant get_sparse_attn_kv_cache_manager
participant DSACacheManagerV2
participant DSAtrtllmAttentionMetadata
participant prepare_attn_metadata_for_draft_replay
LLMConfig->>get_sparse_attn_kv_cache_manager: select KV cache manager V2
get_sparse_attn_kv_cache_manager->>DSACacheManagerV2: construct DSA V2 manager
DSACacheManagerV2->>DSAtrtllmAttentionMetadata: provide page parameters and cache buffers
prepare_attn_metadata_for_draft_replay->>DSAtrtllmAttentionMetadata: bind draft buffers and recompute mappings
DSAtrtllmAttentionMetadata-->>prepare_attn_metadata_for_draft_replay: restore target metadata after replay
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
PR_Github #60657 [ run ] completed with state
|
Signed-off-by: yizhang-nv <187001205+yizhang-nv@users.noreply.github.com> Signed-off-by: Yi Zhang <187001205+yizhang-nv@users.noreply.github.com>
Signed-off-by: Yi Zhang <187001205+yizhang-nv@users.noreply.github.com>
Signed-off-by: Eric Tsai <ertsai@nvidia.com>
ffcffbf to
67e3234
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
tests/unittest/_torch/speculative/test_eagle3.py (1)
344-373: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider asserting the draft buffer dtype and device.
The test verifies shapes and distinct storage. It does not verify that the draft buffers use the same dtype and device as the target buffers. A regression that allocates the draft buffers on CPU would still pass. Add dtype and device assertions to close that gap.
♻️ Proposed additional assertions
assert metadata.draft_block_ids_per_seq.shape == (num_seqs, 7) assert metadata.draft_kv_block_ids_per_seq.shape == (num_seqs, 7) + assert (metadata.draft_block_ids_per_seq.dtype == + metadata.block_ids_per_seq.dtype) + assert (metadata.draft_block_ids_per_seq.device == + metadata.block_ids_per_seq.device)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unittest/_torch/speculative/test_eagle3.py` around lines 344 - 373, Extend test_separate_draft_flash_mla_buffers_use_manager_geometry to assert that draft_block_ids_per_seq and draft_kv_block_ids_per_seq have the same dtype and device as the corresponding target buffers, while preserving the existing shape and distinct-storage checks.tensorrt_llm/_torch/models/modeling_deepseekv3.py (1)
1912-1915: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd precise type annotations to
get_model_defaults.Annotate
llm_argswithTorchLlmArgs. Replacedictwith a parameterized return type that describes the nested default structure. This method is a public model-default interface.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tensorrt_llm/_torch/models/modeling_deepseekv3.py` around lines 1912 - 1915, Update the classmethod get_model_defaults by annotating llm_args with TorchLlmArgs and replacing the unparameterized dict return annotation with a precise parameterized type describing the nested kv_cache_config and use_kv_cache_manager_v2 default structure.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/source/features/kvcache.md`:
- Around line 49-65: Add the repository-standard Markdown-compatible NVIDIA
copyright header at the beginning of docs/source/features/kvcache.md, using 2026
as the latest meaningful-modification year and preserving the existing document
content.
In `@tensorrt_llm/_torch/modules/mla.py`:
- Around line 3055-3059: The local layer index used by
transform_local_topk_and_prepare_pool_view must be recomputed for the currently
active KV-cache manager rather than reused across managers. Update the
trtllm_attention.get_local_layer_idx(attn_metadata) flow to invalidate or
refresh any cached value when speculative decoding switches between target and
draft managers, preserving the correct manager-specific offset.
In `@tests/unittest/_torch/executor/test_mamba_cache_manager.py`:
- Around line 688-712: Update
test_dsa_star_rejects_v2_and_keeps_explicit_v1_selection to exercise
get_kv_cache_manager_cls() with use_kv_cache_manager_v2=False, and assert that
it returns DSACacheManager. Keep the existing V2 STAR rejection assertion, but
do not pass KVCacheManager directly because that bypasses the DSA-specific
selector.
---
Nitpick comments:
In `@tensorrt_llm/_torch/models/modeling_deepseekv3.py`:
- Around line 1912-1915: Update the classmethod get_model_defaults by annotating
llm_args with TorchLlmArgs and replacing the unparameterized dict return
annotation with a precise parameterized type describing the nested
kv_cache_config and use_kv_cache_manager_v2 default structure.
In `@tests/unittest/_torch/speculative/test_eagle3.py`:
- Around line 344-373: Extend
test_separate_draft_flash_mla_buffers_use_manager_geometry to assert that
draft_block_ids_per_seq and draft_kv_block_ids_per_seq have the same dtype and
device as the corresponding target buffers, while preserving the existing shape
and distinct-storage checks.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 268467b1-518f-4303-8445-ce8cfa4719b1
📒 Files selected for processing (22)
cpp/tensorrt_llm/kernels/IndexerKCacheGather.hcpp/tensorrt_llm/kernels/IndexerKCacheScatter.hcpp/tensorrt_llm/kernels/indexerKCacheGather.cucpp/tensorrt_llm/kernels/indexerKCacheScatter.cudocs/source/features/kvcache.mdtensorrt_llm/_torch/attention_backend/sparse/dsa.pytensorrt_llm/_torch/attention_backend/sparse/utils.pytensorrt_llm/_torch/attention_backend/trtllm.pytensorrt_llm/_torch/models/modeling_deepseekv3.pytensorrt_llm/_torch/modules/mla.pytensorrt_llm/_torch/pyexecutor/_util.pytensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.pytensorrt_llm/_torch/pyexecutor/model_engine.pytensorrt_llm/_torch/speculative/interface.pytests/integration/defs/accuracy/test_llm_api_pytorch.pytests/unittest/_torch/attention/sparse/dsa/test_dsa_indexer.pytests/unittest/_torch/attention/sparse/test_cpp_custom_ops.pytests/unittest/_torch/executor/test_kv_cache_v2_extra_buffers.pytests/unittest/_torch/executor/test_mamba_cache_manager.pytests/unittest/_torch/speculative/test_eagle3.pytests/unittest/llmapi/test_config_database.pytests/unittest/llmapi/test_llm_args.py
🚧 Files skipped from review as they are similar to previous changes (8)
- cpp/tensorrt_llm/kernels/indexerKCacheGather.cu
- tests/unittest/_torch/attention/sparse/test_cpp_custom_ops.py
- tests/integration/defs/accuracy/test_llm_api_pytorch.py
- cpp/tensorrt_llm/kernels/IndexerKCacheGather.h
- cpp/tensorrt_llm/kernels/IndexerKCacheScatter.h
- tensorrt_llm/_torch/attention_backend/sparse/utils.py
- cpp/tensorrt_llm/kernels/indexerKCacheScatter.cu
- tensorrt_llm/_torch/speculative/interface.py
Signed-off-by: Yi Zhang <187001205+yizhang-nv@users.noreply.github.com>
67e3234 to
4f86a5e
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
/bot run --disable-fail-fast |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
tensorrt_llm/_torch/models/modeling_deepseekv3.py (1)
1912-1915: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winApply the required type annotations to both new functions.
Both changed functions omit required type information.
tensorrt_llm/_torch/models/modeling_deepseekv3.py#L1912-L1915: annotatellm_argsand replace baredictwith a precise return type.tests/unittest/llmapi/test_llm_args.py#L4000-L4001: annotate all parameters and add-> None.As per coding guidelines: annotate every function and use precise types.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tensorrt_llm/_torch/models/modeling_deepseekv3.py` around lines 1912 - 1915, Apply precise type annotations to both new functions: in tensorrt_llm/_torch/models/modeling_deepseekv3.py:1912-1915, annotate get_model_defaults’s llm_args parameter and replace the bare dict return type with the appropriate precise mapping type; in tests/unittest/llmapi/test_llm_args.py:4000-4001, annotate every parameter of the affected test function and add -> None.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tensorrt_llm/_torch/models/modeling_deepseekv3.py`:
- Around line 1-3: Remove the executable permission from the importable module
modeling_deepseekv3.py to resolve Ruff EXE002; do not add a shebang unless
direct execution is intentionally supported.
In `@tests/unittest/llmapi/test_llm_args.py`:
- Around line 3990-4024: Extend the parameterized cases in
test_deepseek_v3_family_kv_cache_manager_v2_default with a non-V3-family
architecture that resolves to a model class without the V2 default, using the
"auto" setting and expected value False. Keep the existing positive and
explicit-False cases unchanged.
---
Nitpick comments:
In `@tensorrt_llm/_torch/models/modeling_deepseekv3.py`:
- Around line 1912-1915: Apply precise type annotations to both new functions:
in tensorrt_llm/_torch/models/modeling_deepseekv3.py:1912-1915, annotate
get_model_defaults’s llm_args parameter and replace the bare dict return type
with the appropriate precise mapping type; in
tests/unittest/llmapi/test_llm_args.py:4000-4001, annotate every parameter of
the affected test function and add -> None.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 0e3f9a47-5a20-48b6-b561-17ab55c7b474
📒 Files selected for processing (21)
cpp/tensorrt_llm/kernels/IndexerKCacheGather.hcpp/tensorrt_llm/kernels/IndexerKCacheScatter.hcpp/tensorrt_llm/kernels/indexerKCacheGather.cucpp/tensorrt_llm/kernels/indexerKCacheScatter.cutensorrt_llm/_torch/attention_backend/sparse/dsa.pytensorrt_llm/_torch/attention_backend/sparse/utils.pytensorrt_llm/_torch/attention_backend/trtllm.pytensorrt_llm/_torch/models/modeling_deepseekv3.pytensorrt_llm/_torch/modules/mla.pytensorrt_llm/_torch/pyexecutor/_util.pytensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.pytensorrt_llm/_torch/pyexecutor/model_engine.pytensorrt_llm/_torch/speculative/interface.pytests/integration/defs/accuracy/test_llm_api_pytorch.pytests/unittest/_torch/attention/sparse/dsa/test_dsa_indexer.pytests/unittest/_torch/attention/sparse/test_cpp_custom_ops.pytests/unittest/_torch/executor/test_kv_cache_v2_extra_buffers.pytests/unittest/_torch/executor/test_mamba_cache_manager.pytests/unittest/_torch/speculative/test_eagle3.pytests/unittest/llmapi/test_config_database.pytests/unittest/llmapi/test_llm_args.py
🚧 Files skipped from review as they are similar to previous changes (18)
- tests/unittest/_torch/attention/sparse/test_cpp_custom_ops.py
- tensorrt_llm/_torch/pyexecutor/model_engine.py
- tests/unittest/_torch/executor/test_mamba_cache_manager.py
- tests/integration/defs/accuracy/test_llm_api_pytorch.py
- tensorrt_llm/_torch/modules/mla.py
- tensorrt_llm/_torch/attention_backend/sparse/utils.py
- tests/unittest/_torch/speculative/test_eagle3.py
- tests/unittest/llmapi/test_config_database.py
- cpp/tensorrt_llm/kernels/IndexerKCacheGather.h
- tensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.py
- tests/unittest/_torch/executor/test_kv_cache_v2_extra_buffers.py
- cpp/tensorrt_llm/kernels/indexerKCacheGather.cu
- cpp/tensorrt_llm/kernels/indexerKCacheScatter.cu
- cpp/tensorrt_llm/kernels/IndexerKCacheScatter.h
- tensorrt_llm/_torch/speculative/interface.py
- tensorrt_llm/_torch/attention_backend/trtllm.py
- tensorrt_llm/_torch/pyexecutor/_util.py
- tensorrt_llm/_torch/attention_backend/sparse/dsa.py
|
PR_Github #64538 [ run ] triggered by Bot. Commit: |
Signed-off-by: Yi Zhang <187001205+yizhang-nv@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/source/features/kvcache.md`:
- Around line 54-70: The KV Cache Manager Version section incorrectly describes
universal V2 selection and error behavior. Update the documentation to state
that use_kv_cache_manager_v2 only selects V1 versus V2 for DSA, while other
sparse algorithms ignore it; document NotImplementedError for connectors, beam
width greater than one, and DSA with STAR, and the base KVCacheManagerV2
AssertionError for STAR in other V2 managers.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 8735da93-714c-4e5f-8a00-36fc84d53cd6
📒 Files selected for processing (6)
docs/source/features/kvcache.mdtensorrt_llm/_torch/models/modeling_deepseekv3.pytensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.pytests/unittest/_torch/attention/sparse/dsa/test_dsa_indexer.pytests/unittest/_torch/executor/test_kv_cache_v2_extra_buffers.pytests/unittest/_torch/speculative/test_eagle3.py
💤 Files with no reviewable changes (2)
- tests/unittest/_torch/speculative/test_eagle3.py
- tests/unittest/_torch/attention/sparse/dsa/test_dsa_indexer.py
🚧 Files skipped from review as they are similar to previous changes (3)
- tensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.py
- tests/unittest/_torch/executor/test_kv_cache_v2_extra_buffers.py
- tensorrt_llm/_torch/models/modeling_deepseekv3.py
| ### KV Cache Manager Version | ||
|
|
||
| `KvCacheConfig.use_kv_cache_manager_v2` selects the V2 manager; `"auto"` uses | ||
| the model-specific default. When a sparse-attention model selects V2, | ||
| TensorRT LLM raises `NotImplementedError` for V2-incompatible features instead | ||
| of silently falling back to the V1 manager. | ||
|
|
||
| `DeepseekV3ForCausalLM`, `DeepseekV32ForCausalLM`, | ||
| `GlmMoeDsaForCausalLM`, and `MistralLarge3ForCausalLM` select V2 by default | ||
| when this option is `"auto"`. Set the option to `false` to select V1 | ||
| explicitly. | ||
|
|
||
| For DSA, KV cache manager V2 does not support STAR context parallelism. Use | ||
| another context-parallel mode, or set | ||
| `kv_cache_config.use_kv_cache_manager_v2: false` to use the DSA V1 cache | ||
| manager with STAR. | ||
|
|
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 8 \
'use_kv_cache_manager_v2|NotImplementedError|STAR|context_parallel' \
tensorrt_llm/_torch/attention_backend/sparse/utils.py \
tensorrt_llm/_torch/pyexecutor/_util.py \
tensorrt_llm/_torch/models/modeling_deepseekv3.py
rg -n -C 5 \
'get_model_defaults|use_kv_cache_manager_v2' \
tensorrt_llm/_torch/modelsRepository: NVIDIA/TensorRT-LLM
Length of output: 50375
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- documented section ---'
sed -n '1,95p' docs/source/features/kvcache.md
printf '%s\n' '--- V2 validation path ---'
sed -n '600,675p' tensorrt_llm/_torch/pyexecutor/_util.py
printf '%s\n' '--- sparse manager selection ---'
sed -n '1,55p' tensorrt_llm/_torch/attention_backend/sparse/utils.py
printf '%s\n' '--- listed model registrations and defaults ---'
rg -n -C 4 \
'DeepseekV3ForCausalLM|DeepseekV32ForCausalLM|GlmMoeDsaForCausalLM|MistralLarge3ForCausalLM|use_kv_cache_manager_v2' \
tensorrt_llm/_torch/models \
-g '*.py' | head -n 240
printf '%s\n' '--- relevant call sites and config semantics ---'
rg -n -C 5 \
'_kv_cache_manager_v2|use_kv_cache_manager_v2.*False|use_kv_cache_manager_v2.*True|_create_kv_cache_manager' \
tensorrt_llm/_torch/pyexecutor/_util.py \
tensorrt_llm/_torch \
-g '*.py' | head -n 300Repository: NVIDIA/TensorRT-LLM
Length of output: 50377
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
import ast
from pathlib import Path
files = [
Path("tensorrt_llm/_torch/models/modeling_deepseekv3.py"),
Path("tensorrt_llm/_torch/models/modeling_mistral_large3.py"),
Path("tensorrt_llm/_torch/pyexecutor/_util.py"),
Path("tensorrt_llm/_torch/attention_backend/sparse/utils.py"),
]
trees = {p: ast.parse(p.read_text()) for p in files}
print("--- registered model names and inherited defaults ---")
for path, tree in trees.items():
for node in ast.walk(tree):
if isinstance(node, ast.ClassDef):
registrations = []
for dec in node.decorator_list:
if (isinstance(dec, ast.Call) and isinstance(dec.func, ast.Name)
and dec.func.id == "register_auto_model"
and dec.args and isinstance(dec.args[0], ast.Constant)):
registrations.append(dec.args[0].value)
if registrations or node.name == "MistralLarge3ForCausalLM":
methods = {n.name for n in node.body if isinstance(n, ast.FunctionDef)}
print(path, node.name, "bases=", [
ast.unparse(base) for base in node.bases
], "registered=", registrations,
"defines_get_model_defaults=",
"get_model_defaults" in methods)
print("--- sparse manager branches ---")
sparse_tree = trees[Path("tensorrt_llm/_torch/attention_backend/sparse/utils.py")]
for node in ast.walk(sparse_tree):
if isinstance(node, ast.FunctionDef) and node.name == "get_sparse_attn_kv_cache_manager":
for child in ast.walk(node):
if isinstance(child, ast.Return):
print(ast.unparse(child.value))
print("--- V2 validation exception branches ---")
util_tree = trees[Path("tensorrt_llm/_torch/pyexecutor/_util.py")]
for node in ast.walk(util_tree):
if isinstance(node, ast.FunctionDef) and node.name == "_validate_or_fallback_kv_cache_manager_v2":
for child in ast.walk(node):
if isinstance(child, ast.Raise):
print(ast.unparse(child))
PY
printf '%s\n' '--- option declaration and auto-resolution references ---'
rg -n -C 6 \
'use_kv_cache_manager_v2\s*:|use_kv_cache_manager_v2.*auto|model defaults|model_defaults|get_model_defaults' \
tensorrt_llm/llmapi tensorrt_llm/_torch \
-g '*.py' | head -n 260Repository: NVIDIA/TensorRT-LLM
Length of output: 22923
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- DSA cache-manager STAR handling ---'
rg -n -C 8 \
'class DSACacheManager|class DSACacheManagerV2|CpType\.STAR|cp_type|context_parallel' \
tensorrt_llm/_torch/attention_backend/sparse \
tensorrt_llm/_torch/pyexecutor \
-g '*.py' | head -n 360
printf '%s\n' '--- DSA and STAR tests/configuration ---'
rg -n -C 5 \
'dsa|DSA|STAR|use_kv_cache_manager_v2' \
tests \
docs \
examples \
-g '*.py' -g '*.yaml' -g '*.yml' -g '*.md' | head -n 360Repository: NVIDIA/TensorRT-LLM
Length of output: 50375
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- MiniMax V2 construction and STAR path ---'
rg -n -C 18 \
'class MiniMaxM3KVCacheManagerV2|class DeepseekV4CacheManager|super\(\).__init__|CpType\.STAR|Star attention is not supported' \
tensorrt_llm/_torch/attention_backend/sparse/minimax_m3.py \
tensorrt_llm/_torch/attention_backend/sparse/deepseek_v4.py \
tensorrt_llm/_torch/pyexecutor/kv_cache_manager_v2.py \
-g '*.py'
printf '%s\n' '--- sparse algorithms and V2 manager classes ---'
python3 - <<'PY'
import ast
from pathlib import Path
path = Path("tensorrt_llm/_torch/attention_backend/sparse/utils.py")
tree = ast.parse(path.read_text())
for node in ast.walk(tree):
if isinstance(node, ast.FunctionDef) and node.name == "get_sparse_attn_kv_cache_manager":
for branch in node.body:
if isinstance(branch, ast.If):
print(ast.unparse(branch.test), "=>", ast.unparse(branch.body[-1]))
elif isinstance(branch, ast.Return):
print("return", ast.unparse(branch.value))
PY
printf '%s\n' '--- exact sparse V2 incompatibility gate ---'
sed -n '611,665p' tensorrt_llm/_torch/pyexecutor/_util.pyRepository: NVIDIA/TensorRT-LLM
Length of output: 4150
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- locate sparse manager implementations ---'
fd -t f -i 'minimax.*m3|deepseek.*v4|dsa' tensorrt_llm/_torch/attention_backend
fd -t f 'minimax_m3.py' 'deepseek_v4.py' tensorrt_llm/_torch
printf '%s\n' '--- locate V2 subclasses and constructors ---'
rg -l 'class MiniMaxM3KVCacheManagerV2|class DeepseekV4CacheManager' \
tensorrt_llm/_torch/attention_backend/sparse
rg -n -C 15 \
'class MiniMaxM3KVCacheManagerV2|class DeepseekV4CacheManager|super\(\).__init__' \
tensorrt_llm/_torch/attention_backend/sparse \
-g '*.py' | head -n 260Repository: NVIDIA/TensorRT-LLM
Length of output: 28827
Align the section with sparse-manager routing.
NotImplementedErrorcovers KV connectors, beam width greater than one, and DSA with STAR. Other V2 managers can reach a baseKVCacheManagerV2AssertionErrorfor STAR.use_kv_cache_manager_v2selects between V1 and V2 only for DSA. Other sparse algorithms ignore this option.- Update the documentation or expand validation to provide one consistent error contract.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/source/features/kvcache.md` around lines 54 - 70, The KV Cache Manager
Version section incorrectly describes universal V2 selection and error behavior.
Update the documentation to state that use_kv_cache_manager_v2 only selects V1
versus V2 for DSA, while other sparse algorithms ignore it; document
NotImplementedError for connectors, beam width greater than one, and DSA with
STAR, and the base KVCacheManagerV2 AssertionError for STAR in other V2
managers.
Signed-off-by: Yi Zhang <187001205+yizhang-nv@users.noreply.github.com>
|
/bot run --disable-fail-fast |
|
PR_Github #64549 [ run ] triggered by Bot. Commit: |
|
PR_Github #64538 [ run ] completed with state |
|
PR_Github #64549 [ run ] completed with state
|
Dev Engineer Review
Role.INDEX_KEYbuffer.QA Engineer Review
Test code changes are present.
Added or updated coverage includes:
TestGLM52.test_nvfp4.indexer_k_cache_scatter_op.No corresponding
tests/integration/test_lists/changes were reported for these tests. Test-list coverage cannot be confirmed from the available changes.Verdict: needs follow-up.
Description
Port the DSA KV cache manager V2 work from liji-nv@492422b onto the latest
main.This change:
DSACacheManagerV2selection throughuse_kv_cache_manager_v2while preserving the V1 path.Role.INDEX_KEYbuffer managed by V2.Role.ALL, runtime quota calculation, and static KV cache warm-up estimation.Test Coverage
git diff --checkpassed.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.