Skip to content

[None][feat] adp_router: salt-aware probe_prefix_match_length on v1/v2 KV cache backends - #14435

Merged
lancelly merged 1 commit into
NVIDIA:feat/deepseek_v4from
lancelly:cp-a5ee47b092-feat-deepseek-v4
May 22, 2026
Merged

[None][feat] adp_router: salt-aware probe_prefix_match_length on v1/v2 KV cache backends#14435
lancelly merged 1 commit into
NVIDIA:feat/deepseek_v4from
lancelly:cp-a5ee47b092-feat-deepseek-v4

Conversation

@lancelly

@lancelly lancelly commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

Make KVCacheAwareADPRouter work on KVCacheManagerV2 (currently AttributeErrors) and become salt-aware on KVCacheManager v1 (currently probes the wrong namespace for salted requests).

Before this change:

  • v2 KVCacheManagerV2 has no probe_prefix_match_length, so any v2 backend (DSV4 in particular) crashes with AttributeError in adp_router.gather_prefix_matches as soon as attention_dp_config.enable_kv_cache_aware_routing=true.
  • v1 KVCacheManager has a probe but never forwarded cache_salt_id onto the dummy LlmRequest, so salted requests were probed against the salt=None namespace while _create_kv_cache wrote to the salted one. Router saw match_len=0 for everything that was actually warm.

After this change, both backends probe the same namespace their _create_kv_cache paths write to: (lora_task_id, cache_salt_id).

What's in this PR

  • tensorrt_llm/_torch/pyexecutor/resource_manager.py:
    • Add KVCacheManagerV2.probe_prefix_match_length(probe_tokens, lora_task_id, *, cache_salt_id=None) that delegates to KVCacheManager.probe_reuse(ReuseScope(lora_task_id, cache_salt_id)) (the probe API added in [None][feat] KV reuse probe #14395).
    • Extend the v1 probe_prefix_match_length to accept cache_salt_id and pass it through to the C++ LlmRequest so buildBlockKeys() resolves the correct namespace.
  • tensorrt_llm/_torch/pyexecutor/scheduler/adp_router.py:
    • In gather_prefix_matches, read req.cache_salt_id (defaulting to None) and forward it to the probe call.

… KV cache backends

Make KVCacheAwareADPRouter work on KVCacheManagerV2 and become salt-aware on
KVCacheManager (v1). Before this change:

- v2 KVCacheManagerV2 had no probe_prefix_match_length, so any v2 backend
  (including DSV4) would AttributeError on adp_router.gather_prefix_matches
  with enable_kv_cache_aware_routing=true.
- v1 had a probe but never forwarded cache_salt_id onto the dummy LlmRequest,
  so salted requests were probed against the salt=None namespace while
  _create_kv_cache wrote to the salted one -- router saw the wrong match
  length.

Add a v2 KVCacheManagerV2.probe_prefix_match_length that calls the new
KVCacheManager.probe_reuse (added in PR NVIDIA#14395) with
ReuseScope(lora_id, salt). Extend the v1 probe to take cache_salt_id and
pass it through to CppLlmRequest so the C++ buildBlockKeys() pulls the right
namespace. Update adp_router.gather_prefix_matches to read req.cache_salt_id
and forward it.

Both backends now probe the same namespace their _create_kv_cache paths
write to: (lora_task_id, cache_salt_id).

Signed-off-by: Lance Liao <108499334+lancelly@users.noreply.github.com>
(cherry picked from commit a5ee47b)
Signed-off-by: Lance Liao <108499334+lancelly@users.noreply.github.com>
@lancelly
lancelly requested review from a team as code owners May 22, 2026 02:48
@lancelly
lancelly requested review from HuiGao-NV and removed request for a team May 22, 2026 02:48
@lancelly lancelly changed the title [None][fix] adp_router: salt-aware probe_prefix_match_length on v1/v2 KV cache backends [None][feat] adp_router: salt-aware probe_prefix_match_length on v1/v2 KV cache backends May 22, 2026
@lancelly

Copy link
Copy Markdown
Collaborator Author

/bot run --disable-fail-fast

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #49829 [ run ] triggered by Bot. Commit: b37ae69 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #49829 [ run ] completed with state SUCCESS. Commit: b37ae69
/LLM/main/L0_MergeRequest_PR pipeline #39414 completed with status: 'SUCCESS'

CI Report

Link to invocation

@lancelly
lancelly merged commit 823494c into NVIDIA:feat/deepseek_v4 May 22, 2026
10 of 11 checks passed
lfr-0531 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 10, 2026
…2 KV cache backends (NVIDIA#14435)

Signed-off-by: Lance Liao <108499334+lancelly@users.noreply.github.com>
lfr-0531 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 11, 2026
…2 KV cache backends (NVIDIA#14435)

Signed-off-by: Lance Liao <108499334+lancelly@users.noreply.github.com>
lfr-0531 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 12, 2026
…2 KV cache backends (NVIDIA#14435)

Signed-off-by: Lance Liao <108499334+lancelly@users.noreply.github.com>
lfr-0531 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 26, 2026
…2 KV cache backends (NVIDIA#14435)

Signed-off-by: Lance Liao <108499334+lancelly@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
Shixiaowei02 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 29, 2026
…2 KV cache backends (NVIDIA#14435)

Signed-off-by: Lance Liao <108499334+lancelly@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
lancelly added a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 29, 2026
…2 KV cache backends (NVIDIA#14435)

Signed-off-by: Lance Liao <108499334+lancelly@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
Signed-off-by: Liao Lanyu <108499334+lancelly@users.noreply.github.com>
Shixiaowei02 pushed a commit to lfr-0531/TensorRT-LLM that referenced this pull request Jun 30, 2026
…2 KV cache backends (NVIDIA#14435)

Signed-off-by: Lance Liao <108499334+lancelly@users.noreply.github.com>
Signed-off-by: Fanrong Li <lfr-0531@users.noreply.github.com>
Signed-off-by: Liao Lanyu <108499334+lancelly@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants