Skip to content

[None][perf] use native C++ BlockKeyHasher in disagg router to improve TTFT#14767

Open
zheyuf wants to merge 1 commit into
NVIDIA:feat/deepseek_v4from
zheyuf:perf/disagg-router-native-blockkey-hasher
Open

[None][perf] use native C++ BlockKeyHasher in disagg router to improve TTFT#14767
zheyuf wants to merge 1 commit into
NVIDIA:feat/deepseek_v4from
zheyuf:perf/disagg-router-native-blockkey-hasher

Conversation

@zheyuf
Copy link
Copy Markdown
Collaborator

@zheyuf zheyuf commented May 29, 2026

The bottleneck is CPU-side queueing in the orchestrator. It routes each request by hashing the prompt into KV-cache block keys; that hashing (hash_v1_block_key) is a pure-Python per-token loop. For ~39k-token agentic prompts it costs ~tens of ms, running on the orchestrator's single asyncio event loop, so it monopolizes one CPU core and serializes all concurrent requests → TTFT explodes with concurrency.

Fix: move block hashing to the native C++ hasher → the event loop de-saturates.

Impact (DSv4-Pro 1P1D DEP8, GB300, AgentPerf-V2), c128: TTFT p95 10.71s → 3.13s (−71%), throughput +50%, req/s +63% at the same concurrency. SLO60 ceiling (p95 ≤ 5s & SSE p25 ≥ 60 tok/s) rises ~c80 → c160 (~5 → 10 users/GPU). Post-fix the bottleneck moves to prefill queueing (ctx_queue), not the orchestrator.

@coderabbitai summary

Description

Test Coverage

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-compatible or api-breaking. For api-breaking, include BREAKING in 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.

@zheyuf zheyuf changed the title [None][perf] use native C++ BlockKeyHasher in disagg router to boost TTFT [None][perf] use native C++ BlockKeyHasher in disagg router to improve TTFT May 30, 2026
@zheyuf zheyuf force-pushed the perf/disagg-router-native-blockkey-hasher branch from 92e1e6e to 51f6b20 Compare May 30, 2026 01:54
…k hashing

The disaggregated orchestrator computes KV-cache block hashes per request for prefix-/conversation-aware routing. hash_v1_block_key is a pure-Python per-token loop; for long prompts (~39k tokens) it dominates the single asyncio event loop's CPU (py-spy: ~89% of one saturated core) and, being GIL-bound, serializes concurrent requests, so TTFT degrades super-linearly with concurrency.

Route block_key_hasher's common path (cache_salt_id is None) to the existing nanobind-exposed C++ BlockKeyHasher, which implements the identical algorithm, removing the per-token Python loop from the orchestrator hot path. Bit-exact with hash_v1_block_key (verified 550/550 incl. the chained per-block pattern), no new dependency. Falls back to the Python implementation only when a cache_salt_id is set (the C++ hash() binding takes no salt) -- which does not occur on the unsalted agent/chat completion path.

Only the serve router's routing-time hashing is changed; the worker-side KV-cache event hashing that Dynamo consumes (kept V1-compatible by NVIDIA#13624) is untouched, so the V1 hash contract is preserved.

Impact (DSv4-Pro 1P1D disagg, DEP8, GB300, AgentPerf-V2): c128 TTFT p95 10.71s -> 3.13s (-71%), throughput +50%, req/s +63% at fixed concurrency; SLO60 ceiling (p95<=5s and SSE p25>=60 tok/s) ~c80 -> c160 (~5 -> 10 users/GPU). Post-fix the bottleneck shifts to prefill queueing (ctx_queue), not the orchestrator.

Signed-off-by: Zheyu Fu <zheyuf@nvidia.com>
@zheyuf zheyuf force-pushed the perf/disagg-router-native-blockkey-hasher branch from 51f6b20 to 0625b9a Compare May 30, 2026 06:19
@zheyuf zheyuf marked this pull request as ready for review May 30, 2026 06:20
@zheyuf zheyuf requested a review from a team as a code owner May 30, 2026 06:20
@zheyuf zheyuf requested review from zhenhuaw-me and removed request for a team and zhenhuaw-me May 30, 2026 06:20
@zheyuf
Copy link
Copy Markdown
Collaborator Author

zheyuf commented May 30, 2026

/bot run --disable-fail-fast

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #51169 [ run ] triggered by Bot. Commit: 0625b9a Link to invocation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants