[Performance] NGram drafting copies the full token history on each generation step

Đang mở
#23,075 0 bình luận 0 reaction 2 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@kaiyux đang làm issue này rồi.

Từ ngày 30/11/2026.

  • #23076 của @HaoyangPing0324 — đang mở

Đánh giá

Issue này chưa được đánh giá.

Mô tả

Investigating Performance Speculative Decoding triaged
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.
Ngôn ngữ chính
Python
Star
15.2k
Fork
3k
Merge trung bình
2 ngày 21 giờ
Pull request đã merge (30 ngày)
477

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NVIDIA/TensorRT-LLM

Tất cả issue của NVIDIA/TensorRT-LLM

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.