[Bug]: PyTorch backend: LLM(batched_logits_processor=...) is accepted but the processor is never called

オープン
#22,905 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@lminer がすでに取り組んでいます。

2026年10月26日 から。

  • #21044 @lminer による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
22/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python, pytorch

調査の方向性

Start with the batched_logits_processor field on TorchLlmArgs and the point where the executor request is built, since the apply_batched_logits_processor flag is dropped there. Nothing under tensorrt_llm/_torch reads either name, so the processor has to be wired into the PyTorch sampling path. A linked open pull request (#21044) already targets this, so check it before starting. Done means the processor is called once per step and the example prints the forced Z token.

索引モデルが issue の本文から書いたものです。

説明

Pytorch
System Info
  • Tested on one NVIDIA L4 with nvcr.io/nvidia/tensorrt-llm/release:1.4.0rc4 (PyTorch backend), model Qwen/Qwen3-0.6B
  • main at a6d8944540 has the same code: nothing under tensorrt_llm/_torch reads batched_logits_processor or apply_batched_logits_processor
Who can help?

No response

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

LLM(batched_logits_processor=...) and SamplingParams(apply_batched_logits_processor=True) are both accepted, but the processor is never called. TorchLlmArgs keeps the batched_logits_processor field, and the request flag is dropped when the executor request is built.

import sys
from transformers import AutoTokenizer
from tensorrt_llm import LLM, SamplingParams
from tensorrt_llm.sampling_params import BatchedLogitsProcessor

class ForceAll(BatchedLogitsProcessor):
    def __init__(self, token_id): self.token_id = token_id
    def __call__(self, req_ids, logits, token_ids, stream_ptr, client_ids):
        print("batched processor called", req_ids, file=sys.stderr, flush=True)
        for rows in logits:
            rows[:] = float("-inf")
            rows[..., self.token_id] = 0

z = AutoTokenizer.from_pretrained("Qwen/Qwen3-0.6B").encode("Z", add_special_tokens=False)[-1]
llm = LLM("Qwen/Qwen3-0.6B", batched_logits_processor=ForceAll(z))
g = dict(max_tokens=4, temperature=0.0)
print(repr(llm.generate("A B C", SamplingParams(**g)).outputs[0].text))
print(repr(llm.generate("A B C", SamplingParams(**g, apply_batched_logits_processor=True)).outputs[0].text))
Expected behavior

The second request is forced to the token for Z on every step, and batched processor called is printed once per step. Or, if the PyTorch backend does not support the batched processor, the LLM or the request is refused with an error.

actual behavior

Both requests return ' D E F G'. batched processor called is never printed and nothing reports that the processor was ignored.

additional notes

The batched processor was a feature of the removed TensorRT backend. The release notes still list it ("Added batched logits processor support"), and trtllm-serve names batched_logits_processor among the fields to set through the Python LLM API.

#21044 makes the PyTorch backend call it.

主要言語
Python
スター
15.2k
フォーク
3k
平均マージ
2日 21時間
マージ済み PR(30日)
477

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

NVIDIA/TensorRT-LLM のほかの issue

NVIDIA/TensorRT-LLM の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。