[Performance] NGram drafting copies the full token history on each generation step
Maintainers usually reply within 1 day
Assessment
This issue has not been assessed yet.
Description
Proposal to improve performance
With NGram speculative decoding, the PyTorch executor asks the drafter to propose continuations for each generation request. NGramDrafter.prepare_draft_tokens calls list(request.get_tokens(0)). The C++ binding converts the complete beam history to a Python list, then list(...) copies it again. After the first step the pool already knows where indexing should resume and needs only the tail to update its index and look up the next pattern.
On an NVIDIA H20 with TensorRT-LLM 1.4.0rc4 and real C++-backed requests, the median time for one steady-state call to prepare_draft_tokens on eight requests was 257 µs at 2,048 prefix tokens, 872 µs at 8,192, and 3,485 µs at 32,768. Each request appended one token per step with a four-token draft and a maximum matching n-gram size of two. These timings cover the drafter's CPU work.
The first step needs the full prompt to seed the pool. Later steps should fetch the range needed to update the index and match the current suffix. On the same request histories they should produce the same ordered proposals with shared and private pools, including after rewinds and draft-length changes.
Report of performance regression
No response
Misc discussion on performance
No response
Your current environment (if you think it is necessary)
NVIDIA H20, TensorRT-LLM 1.4.0rc4, PyTorch 2.14.1+cu130, Qwen3-0.6B.
Before submitting a new issue...
- Make sure you already searched for relevant issues, and checked the documentation and examples for answers to frequently asked questions.
- Dominant language
- Python
- Stars
- 15.2k
- Forks
- 3k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 477
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NVIDIA/TensorRT-LLM
-
Bug: AttributeError: 'GptOssConfig' object has no attribute 'rope_scaling_factor' with transformers >= 5.xPossibly taken @NimaVaziri claimed this today. OpenPytorch
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NVIDIA/TensorRT-LLM#23406 ·
Maintainers usually reply within 1 day
-
Inference runtime Windows
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
NVIDIA/TensorRT-LLM#23394 ·
Maintainers usually reply within 1 day
-
[Bug]: MMLU subsampling changes when evaluators are interleavedPossibly taken @LeNeLeNeWo claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NVIDIA/TensorRT-LLM#23273 ·
Maintainers usually reply within 1 day
-
Trace-replay Pareto window includes the drain when sessions finish out of admission orderPossibly taken @sbeierle claimed this 3 days ago. OpenTesting
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
NVIDIA/TensorRT-LLM#23077 ·
Maintainers usually reply within 1 day
-
LongBench V2 blog command breaks on inline comments after continuationsPossibly taken @ddlw claimed this 25 days ago. OpenDoc
Difficulty 1/5 Under an hour Newbie friendliness 91/100
NVIDIA/TensorRT-LLM#21879 ·
Maintainers usually reply within 1 day
All issues in NVIDIA/TensorRT-LLM
Similar issues
-
[Resource]: SpaicelyOpenresource-submission validation-passed
Difficulty 1/5 Under an hour Newbie friendliness 68/100
hesreallyhim/awesome-claude-code#3875 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
bvis/aegis-hass#725 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
datasektionen/cashflow#468 ·
-
dont call alembic upgrade until we check whether or not the cache DB has an alembic version stampOpen
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
#1643 unrecoverable split: 1 digest with a 403 — two earlier captures of the same URL are real 200sOpen
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Robin-IA/Congressional-Letters-Dev#1684 ·
Maintainers usually reply within 1 day