Skip to content

[https://nvbugs/6507080][fix] Override TokenizerBase.__repr__ to return f"{self.__class__.__name__}()" - #16839

Open
trtllm-agent wants to merge 3 commits into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6507080
Open

[https://nvbugs/6507080][fix] Override TokenizerBase.__repr__ to return f"{self.__class__.__name__}()"#16839
trtllm-agent wants to merge 3 commits into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6507080

Conversation

@trtllm-agent

@trtllm-agent trtllm-agent commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: TokenizerBase inherits transformers __repr__, which reads the abstract added_tokens_decoder property and raises NotImplementedError on user protocol subclasses
  • Fix: Override TokenizerBase.__repr__ to return f"{self.__class__.__name__}()" so pydantic/logging never touches transformers-internal state on custom tokenizers
  • Automated fix generated by repair-bot

Test plan

  • Verify fix on the same GPU type as the original failure
  • Check for regressions in related tests

Links

Dev Engineer Review

  • Added TokenizerBase.__repr__ in tensorrt_llm/tokenizer/tokenizer.py.
  • The method returns f"{self.__class__.__name__}()".
  • This prevents PreTrainedTokenizerBase.__repr__ from accessing unimplemented tokenizer state, such as added_tokens_decoder.
  • Removed the waiver for unittest/llmapi/test_llm.py::test_llm_with_customized_tokenizer.
  • The changes are focused and consistent with the reported NotImplementedError fix.

QA Engineer Review

  • Test-list change: tests/integration/test_lists/waives.txt
    • Removed the waiver for unittest/llmapi/test_llm.py::test_llm_with_customized_tokenizer.
    • Added no entries.
  • Verdict: needs follow-up because CBTS coverage data is unavailable.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3709479d-2b48-43e6-8384-c4ff100d6c08

📥 Commits

Reviewing files that changed from the base of the PR and between 8fa2a6f and 53e40a6.

📒 Files selected for processing (2)
  • tensorrt_llm/tokenizer/tokenizer.py
  • tests/integration/test_lists/waives.txt
💤 Files with no reviewable changes (1)
  • tests/integration/test_lists/waives.txt
🚧 Files skipped from review as they are similar to previous changes (1)
  • tensorrt_llm/tokenizer/tokenizer.py

Walkthrough

Adds a fallback TokenizerBase.__repr__ that returns ClassName() and removes the waiver for the customized tokenizer integration test.

Changes

Tokenizer representation and test enablement

Layer / File(s) Summary
TokenizerBase representation fallback and waiver removal
tensorrt_llm/tokenizer/tokenizer.py, tests/integration/test_lists/waives.txt
Adds a class-name-only __repr__ implementation and removes the customized tokenizer test from the waiver list.

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

Possibly related PRs

Suggested reviewers: qijune, crazydemo, schetlur-nv

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title identifies the NVBugs issue, uses the valid fix type, and clearly states the main tokenizer representation change.
Description check ✅ Passed The description explains the root cause, solution, test plan, and bug link, although it does not use all template headings.
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 PR with unit tests

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

@trtllm-agent
trtllm-agent force-pushed the repair-bot-bug6507080 branch from 30b981f to ced2a75 Compare July 29, 2026 02:52
@trtllm-agent
trtllm-agent requested a review from a team as a code owner July 29, 2026 02:52
@trtllm-agent
trtllm-agent requested a review from crazydemo July 29, 2026 02:52

@fredricz-20070104 fredricz-20070104 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.

Review summary - Approve

Reviewed the full diff; no blocking or major issues found.

Minor, non-blocking notes:

  • tensorrt_llm/tokenizer/tokenizer.py: repr loses detail for fully-implemented subclasses

Automated review by NVCortex Lite, run by @fredricz-20070104.

@mikeiovine

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63052 [ run ] triggered by Bot. Commit: ced2a75 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #63052 [ run ] completed with state FAILURE. Commit: ced2a75
/LLM/main/L0_MergeRequest_PR pipeline #51153 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

PreTrainedTokenizerBase.__repr__ reads properties (e.g.
added_tokens_decoder) that TokenizerBase subclasses are not required
to implement. When a user-supplied custom tokenizer becomes a field of
the pydantic llm_args model, logging f"LLM Args:\n{llm_args}" in
py_executor_creator triggers pydantic's __repr__, which recursively
calls repr() on the tokenizer and blows up with NotImplementedError.

Override __repr__ on TokenizerBase to return a class-name-only string
so pydantic reprs and startup logging never crash on custom tokenizers.

Signed-off-by: handongl <handongl@nvidia.com>
Signed-off-by: handongl <handongl@nvidia.com>
@trtllm-agent
trtllm-agent force-pushed the repair-bot-bug6507080 branch from ced2a75 to c8722e1 Compare August 5, 2026 06:43
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@mikeiovine

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64068 [ run ] triggered by Bot. Commit: c8722e1 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64068 [ run ] completed with state SUCCESS. Commit: c8722e1
/LLM/main/L0_MergeRequest_PR pipeline #51996 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

@brnguyen2 brnguyen2 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.

Approving — the comments below are optional touch-ups, not blockers.

Root cause looks right, and TransformersTokenizer already defines its own __repr__ (tokenizer.py:293) so the default path is unaffected.

Two asks before merge:

  1. The test is post-merge-only, so the standard pipeline won't re-run it after un-waiving — trigger the post-merge stage that covers unittest/llmapi/test_llm.py (/bot run --extra-stage "...") and link the result.
  2. Add a one-line assertion that repr() on a minimal TokenizerBase subclass doesn't raise. Without it, the only thing guarding this regression is a post-merge integration test.

Signed-off-by: Mike Iovine <miovine@nvidia.com>
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@mikeiovine

Copy link
Copy Markdown
Collaborator

/bot run

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64627 [ run ] triggered by Bot. Commit: 53e40a6 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #64627 [ run ] completed with state SUCCESS. Commit: 53e40a6
/LLM/main/L0_MergeRequest_PR pipeline #52487 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

CI Agent Failure Analysis

Link to invocation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants