Repository navigation
[TRTLLM-13582][feat] Reduce context-phase host overhead in input prep - #15584
Wanli-Jiang wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughAdds a ChangesScheduling and Model Engine Performance Optimizations
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
728bafc to
5e8eaf3
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #55476 [ run ] triggered by Bot. Commit: |
|
PR_Github #55476 [ run ] completed with state
|
5e8eaf3 to
e0e197e
Compare
52a3dee to
d10295f
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #55714 [ run ] triggered by Bot. Commit: |
|
PR_Github #55714 [ run ] completed with state
|
|
@Wanli-Jiang it looks similar to some of the changes in feat/deepseek_v4 branch: #15584 I wonder how we should reconcile. |
|
/bot run --disable-fail-fast |
|
PR_Github #55991 [ run ] triggered by Bot. Commit: |
|
PR_Github #55991 [ run ] completed with state
|
|
/bot run --disable-fail-fast |
|
PR_Github #56051 [ run ] triggered by Bot. Commit: |
|
PR_Github #56051 [ run ] completed with state
|
d10295f to
e602e51
Compare
|
/bot run --disable-fail-fast |
|
PR_Github #56214 [ run ] triggered by Bot. Commit: |
|
PR_Github #56214 [ run ] completed with state
|
Reduce host-side input preparation cost in the pure-context (prefill) path of _prepare_tp_inputs: - Build pure-context position_ids directly on-device with torch.arange, skipping the Python list build and its host->device copy. Guarded to the case with no generation request, no MRoPE, and zero position offset; all other cases fall back to the list path unchanged. - Stage input_ids/position_ids copies via array.array + torch.frombuffer instead of torch.tensor(<list>), faster for long sequences. The staging helper is a no-op on an empty list. Verified value-preserving (bit-identical generated tokens) across decode, in-flight batching, chunked prefill, and prefix-cache / block-reuse. Note: the original PR NVIDIA#15584 also reduced ADP request-routing overhead, but that optimization was independently landed on main via NVIDIA#15625 (_num_input_tokens uses the cheap num_input_tokens accessor), so the adp_router.py / executor_request_queue.py changes are dropped on rebase. Signed-off-by: Wanli Jiang <[email protected]>
e602e51 to
08467f3
Compare
Improvement measurement
Breakdown in the code path
GPU-idle ms per host stage, rank-1 worker, Super-120B 50k CTX bs=1.
"Baseline (main)" already includes #15625's route fix; "Optimized (PR)" adds C1+C2.
Sub-stages are the NVTX ranges actually present in the trace;
route+gather+bcastis_fetch_new_requests − merge_requests(route_requests / gather_all_rank_states have nodedicated NVTX marker in this build — the original report added those via separate
fetchinstrinstrumented runs).Before/after measurement
_prepare_inputs6.49→2.06 (−68 %)_prepare_inputs6.59→2.26 (−66 %);_fetch~flat_prepare_inputs1.71→0.97 (−43 %)Summary by CodeRabbit
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.