NVIDIA / NVIDIA/TensorRT-LLM

[bug] Lookahead spec-dec verifies w guesses instead of g

Open
#4,003 1 comment 0 reactions 1 assignee View on GitHub

@lfr-0531 is already working on this.

Since May 16, 2025.

bug Investigating Speculative Decoding Testing triaged
Dominant language
Python
Stars
14.7k
Forks
2.8k
Avg merge
2d 23h
Merged PRs (30d)
489

Description

System Info

All systems

Who can help?

@kaiyux

Information
  • The official example scripts
  • My own modified scripts
Tasks
  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)
Reproduction

.

Expected behavior

The pool manager makes g guesses

actual behavior

The pool manager is making w guesses

additional notes

The bug is in this line: https://github.com/NVIDIA/TensorRT-LLM/blob/b40f351b7a3f8c15a3e97b7d4e1f9459dafd8922/cpp/tensorrt_llm/layers/lookaheadAlgorithm.cpp#L183
It passes the parameter w, when it should be passing the parameter g. As a result, the algorithm verifies fewer n-grams than what is expected from the configuration.

Why did this not cause any errors so far?
The LookaheadPoolManager already clips the number of guess to g here:
https://github.com/NVIDIA/TensorRT-LLM/blob/b40f351b7a3f8c15a3e97b7d4e1f9459dafd8922/cpp/tensorrt_llm/layers/lookaheadPoolManager.cpp#L53
As a result, the number of n-gram guesses (with the bug) is min(w, g), so there are no more than g guesses.

We (at Baseten) tried to write our own custom LookaheadPoolManager and ran into an assertion failure at this line:
https://github.com/NVIDIA/TensorRT-LLM/blob/b40f351b7a3f8c15a3e97b7d4e1f9459dafd8922/cpp/tensorrt_llm/layers/lookaheadAlgorithm.cpp#L188

This bug doesn't cause any crashes, but fixing it may improve the performance for users who set g values higher than w.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.