Skip to content

[https://nvbugs/6891162][fix] Stop test_generate_with_stop_words on the token Qwen3 generates for N - #20673

Merged
chenfeiz0326 merged 2 commits into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-v2/nvbug-6891162-r7
Oct 23, 2026
Merged

chenfeiz0326 merged 2 commits into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-v2/nvbug-6891162-r7

Conversation

@trtllm-agent

@trtllm-agent trtllm-agent commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Description

unittest/llmapi/test_llm.py::test_generate_with_stop_words has failed since the default model of test_llm.py changed from TinyLlama-1.1B-Chat to Qwen3-0.6B (#19178).

Root cause. The test derives its stop token with tokenizer.encode("N", add_special_tokens=False)[-1]. TinyLlama's SentencePiece tokenizer gives the same token the model generates after "... L M". Qwen3's BPE tokenizer encodes a bare "N" as id 45, but continuing the prompt "A B C" the model generates the space-prefixed " N", id 451. So end_id / stop_token_ids never match, and generation runs to its length limit:

similar(' D E F G H I J K L M N O P Q R S T U V W X Y Z\n\nThe alphabet is 26 letters long', 'D E F G H I J K L M')  -> False

Fix. Derive the stop id from " N", the token the model actually generates. The test's expectations, criteria and other cases are unchanged. This test's waiver is removed.

test_generate_with_bad_words (same bug) is not changed here and stays waived. Its first reference was captured with TinyLlama, and its bad="I J" / bad=["F E", "I J"] strings do not match the space-prefixed tokens Qwen3 generates. Updating them is left to the test owner.

Test Coverage

On an A100 80GB with the CI image, unittest/llmapi/test_llm.py::test_generate_with_stop_words:

  • before: fails with the assertion above;
  • after: passes.

The neighbouring test_generate_with_detokenization_stop_words and test_generate_with_detokenization_stop_words_streaming also pass.

Fixes https://nvbugs/6891162 (partially: test_generate_with_stop_words)

PR Checklist

  • PR description clearly explains what and why.
  • Test cases are provided for new code paths (no new code paths; test-only change).
  • No unrelated changes.

🤖 Generated with Claude Code

Dev Engineer Review

test_generate_with_stop_words now derives the stop-token ID from " N", matching the space-prefixed token generated by the model. The change removes only this test’s waiver. test_generate_with_bad_words remains waived and unchanged.

QA Engineer Review

Modified tests/unittest/llmapi/test_llm.py and tests/integration/test_lists/waives.txt. The test now checks stopping on the space-prefixed token. The waiver entry for this test was removed. No matching entry was found in the searched CI or manual-QA lists. The PR description reports that this test and two detokenization stop-word tests passed on an A100 80GB. Coverage verdict: sufficient for this targeted change.

Per-File QA Perspective

  • tests/unittest/llmapi/test_llm.py: Covers stop-word handling when the generated token is " N". No matching CI or manual-QA list entry was found in the searched lists.
  • tests/integration/test_lists/waives.txt: Removes the waiver for unittest/llmapi/test_llm.py::test_generate_with_stop_words, allowing the test to run rather than be skipped.

…he token Qwen3 generates for N

test_generate_with_stop_words derived its stop id with
tokenizer.encode("N")[-1]. With TinyLlama's SentencePiece tokenizer that
is the same token the model generates after "M". With the Qwen3-0.6B
default model, BPE encodes a bare "N" as id 45. The model generates the
space-prefixed " N" (id 451), so end_id/stop_token_ids never matched
and generation ran to the full length. Derive the id from " N". Every
existing expectation in the test then holds, and its waiver is removed.

test_generate_with_bad_words stays waived: its first reference string
was captured with TinyLlama and needs a test-owner decision.

Signed-off-by: trtllm-agent <296075020+trtllm-agent@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 26e6e82 and 3d8b8e3.

📒 Files selected for processing: 2
  • tests/integration/test_lists/waives.txt
  • tests/unittest/llmapi/test_llm.py
💤 Files with no reviewable changes: 1
  • tests/integration/test_lists/waives.txt

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

Walkthrough

The stop-word test now derives stop_id from " N" instead of "N". Its skip entry was removed.

Changes

Stop-word test

Layer / File(s) Summary
Update and enable stop-word test
tests/unittest/llmapi/test_llm.py, tests/integration/test_lists/waives.txt
The test derives stop_id from " N". Comments describe the generated spacing and possible BPE token differences. The test's skip entry was removed.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Suggested reviewers: tongyuantongyu

Merge Risk: ⚪ Minimal · up to 3d8b8

The stop-token derivation and waiver removal are consistent with the stated fix, with no identified merge blocker.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title identifies the NVBugs issue, the fix type, and the specific stop-token test change. It is clear and directly related to the primary change.
Description check Passed The description explains the failure, root cause, fix, test coverage, waiver removal, and remaining scope. It includes the required Description, Test Coverage, and PR Checklist sections.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@mikeiovine mikeiovine left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stamp on behalf of runtime devs

@github-actions

Copy link
Copy Markdown

Automatically added "ci: full pre-merge approved" because this PR has satisfied the required GitHub review approvals. Unresolved review conversations and other required checks remain independent merge requirements.

@BowenFu

BowenFu commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Bug engineer ownership

@mikeiovine, as the engineer assigned to the linked bug, you are responsible for driving this bot PR to resolution. Please coordinate review, address feedback and required code changes, get CI passing, and verify the original failure before driving it to merge. If the PR is obsolete or superseded, close it with a reason. Keep this PR updated with blockers and the next step.

Resolve the waives.txt conflict with NVIDIA#20758, which removed the adjacent
test_generate_with_bad_words waiver line. No change to this PR's fix.

Signed-off-by: chenfeiz0326 <203214996+chenfeiz0326@users.noreply.github.com>
@chenfeiz0326

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast --extra-stage "A100X-PyTorch-Post-Merge-1"

@chenfeiz0326

Copy link
Copy Markdown
Collaborator

Merged main into this branch (3d8b8e3) to resolve the waives.txt conflict with #20758, which removed the adjacent test_generate_with_bad_words waiver line and has now merged. The fix itself is unchanged: the diff against main is still the " N" stop-id change in test_generate_with_stop_words plus the removal of its waiver.

CI is started with A100X-PyTorch-Post-Merge-1 added, because that is the only stage that runs unittest/llmapi/test_llm.py. On #20758 that stage ran test_generate_with_bad_words and it passed.

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #80129 [ run ] triggered by Bot. Commit: 3d8b8e3 Link to invocation

@chenfeiz0326

Copy link
Copy Markdown
Collaborator

/bot run --disable-fail-fast

@chenfeiz0326

Copy link
Copy Markdown
Collaborator

In the previous run, A100X-PyTorch-Post-Merge-1 ran test_generate_with_stop_words (the test this PR fixes) and it passed, as did test_generate_with_bad_words and both test_generate_with_detokenization_stop_words variants. The only failure in that stage was test_startup_metrics_by_server_info: the server info now has a render_fingerprint key. That key was added on main by #19964, and this post-merge-only test was not updated there. It is unrelated to this PR, so CI is re-run without the extra stage.

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #80188 [ run ] triggered by Bot. Commit: 3d8b8e3 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #80129 [ run ] completed with state ABORTED. Commit: 3d8b8e3

Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #80188 [ run ] completed with state SUCCESS. Commit: 3d8b8e3
/LLM/main/L0_MergeRequest_PR pipeline #65996 completed with status: 'SUCCESS'

CI Report

Link to invocation

@chenfeiz0326
chenfeiz0326 merged commit 1526744 into NVIDIA:main Oct 23, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants