[Bug]: gemma4 reasoning parser returns reasoning as content on requests without tools; reasoning_content keeps the thought label
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Start with Gemma4ReasoningParser and compare its raw-token handling with MuseSparkReasoningParser and KimiK3ReasoningParser. The issue names tests/unittest/llmapi/test_reasoning_parser.py for regression tests; check the linked pull request for work already underway. Done means reasoning is separated from content without the thought label, including when streaming.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
System Info
TensorRT-LLM main (3f692ac). This is serving-layer logic only, so it reproduces on CPU with the google/gemma-4-E4B-it tokenizer.
Who can help?
No response
Information
- The official example scripts
- My own modified scripts
Reproduction
trtllm-serve with a Gemma 4 model and --reasoning_parser gemma4 (or auto, which maps gemma4 to it). Send a chat request with chat_template_kwargs: {"enable_thinking": true} and no tools.
<|channel> and <channel|> are special tokens in the Gemma 4 tokenizer. The request keeps the default skip_special_tokens=True, and Gemma4ReasoningParser does not set needs_raw_special_tokens. So _configure_parser_special_token_decoding leaves the default in place and the detokenizer removes both markers:
from transformers import AutoTokenizer
from tensorrt_llm.llmapi.reasoning_parser import ReasoningParserFactory
tok = AutoTokenizer.from_pretrained("google/gemma-4-E4B-it")
ids = tok.encode("<|channel>thought\nThe user wants 2+2.<channel|>4", add_special_tokens=False)
text = tok.decode(ids, skip_special_tokens=True) # what the server decodes
print(repr(text)) # 'thought\nThe user wants 2+2.4'
r = ReasoningParserFactory.create_reasoning_parser("gemma4").parse(text)
print(repr(r.content), repr(r.reasoning_content)) # 'thought\nThe user wants 2+2.4' ''
print(ReasoningParserFactory.needs_raw_special_tokens("gemma4")) # False
Expected behavior
content == "4". reasoning_content holds the reasoning.
actual behavior
- Without tools: the whole reasoning block, plus its
thoughtlabel, is returned ascontent, glued to the answer, andreasoning_contentis empty. With tools it works only because the Gemma 4 tool parser setsneeds_raw_special_tokens. - With tools (raw tokens kept):
reasoning_contentstarts with the channel label ("thought\nThe user wants..."). In a tool-call loop the Gemma 4 chat template replays that turn's reasoning as'<|channel>thought\n' + reasoning_content + '\n<channel|>'. The next prompt therefore contains<|channel>thought\nthought\n..., which the model never produced: an off-distribution prompt and a prefix-cache miss at every tool step. vLLM's Gemma 4 parser strips this label (_strip_thought_label).
additional notes
Fix:
- Set
needs_raw_special_tokens = TrueonGemma4ReasoningParser.MuseSparkReasoningParserandKimiK3ReasoningParseralready do this for the same reason. - Drop a leading
thought\nfrom each channel body inparseandparse_delta. While streaming, a partial label split across deltas is held back.
A PR with regression tests in tests/unittest/llmapi/test_reasoning_parser.py follows.
A related gap that the PR does not change: after a tool response with enable_thinking=True, the template's generation prompt ends with <|channel>thought\n. The completion then starts inside the channel, but Gemma4ReasoningParser always starts outside reasoning. That reasoning is still returned as content up to <channel|>. Fixing it needs the prompt-tail resolution (resolves_thinking_from_prompt) that other parsers use, so I left it for a separate change.
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
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.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của NVIDIA/TensorRT-LLM
-
Bug: AttributeError: 'GptOssConfig' object has no attribute 'rope_scaling_factor' with transformers >= 5.xCó thể đã có người làm @NimaVaziri đã nhận hôm nay. Đang mởPytorch
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NVIDIA/TensorRT-LLM#23406 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Inference runtime Windows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
NVIDIA/TensorRT-LLM#23394 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: MMLU subsampling changes when evaluators are interleavedCó thể đã có người làm @LeNeLeNeWo đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
NVIDIA/TensorRT-LLM#23273 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Trace-replay Pareto window includes the drain when sessions finish out of admission orderCó thể đã có người làm @sbeierle đã nhận 3 ngày trước. Đang mởTesting
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
NVIDIA/TensorRT-LLM#23077 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
LongBench V2 blog command breaks on inline comments after continuationsCó thể đã có người làm @ddlw đã nhận 25 ngày trước. Đang mởDoc
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
NVIDIA/TensorRT-LLM#21879 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của NVIDIA/TensorRT-LLM
Issue tương tự
-
[Resource]: SpaicelyĐang mởresource-submission validation-passed
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
hesreallyhim/awesome-claude-code#3875 · 1 bình luận ·
-
[Bug]: Ajax Pro login issueĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
bvis/aegis-hass#725 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
datasektionen/cashflow#468 ·
-
dont call alembic upgrade until we check whether or not the cache DB has an alembic version stampĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
#1643 unrecoverable split: 1 digest with a 403 — two earlier captures of the same URL are real 200sĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Robin-IA/Congressional-Letters-Dev#1684 ·
Maintainer thường phản hồi trong vòng 1 ngày