[None][perf] use native C++ BlockKeyHasher in disagg router to improve TTFT#14767
Open
zheyuf wants to merge 1 commit into
Open
[None][perf] use native C++ BlockKeyHasher in disagg router to improve TTFT#14767zheyuf wants to merge 1 commit into
zheyuf wants to merge 1 commit into
Conversation
92e1e6e to
51f6b20
Compare
…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>
51f6b20 to
0625b9a
Compare
Collaborator
Author
|
/bot run --disable-fail-fast |
Collaborator
|
PR_Github #51169 [ run ] triggered by Bot. Commit: |
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.
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-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.