Skip to content

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

Open
trtllm-agent wants to merge 2 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 2 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

  • Updated TokenizerBase in tensorrt_llm/tokenizer/tokenizer.py to override __repr__, returning f"{self.__class__.__name__}()".
  • This avoids PreTrainedTokenizerBase.__repr__ accessing tokenizer internals (e.g., added_tokens_decoder) that custom TokenizerBase subclasses may not implement, preventing NotImplementedError when pydantic/logging triggers repr().

QA Engineer Review

  • Test-list changes: tests/integration/test_lists/waives.txt
    • Removed the waivers entry for unittest/llmapi/test_llm.py::test_llm_with_customized_tokenizer (no entries added).
    • Verdict: needs follow-up

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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: 7bfc20ab-bd31-43b4-8ebe-41affd4e72b1

📥 Commits

Reviewing files that changed from the base of the PR and between 30b981f and ced2a75.

📒 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__ returning 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, schetlur-nv, crazydemo, yiqingy0, dpitman-nvda

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title follows the required ticket/type format and clearly summarizes the fix to TokenizerBase.repr.
Description check ✅ Passed The description covers the root cause, fix, test plan, and bug link, so it is mostly complete despite not matching the template headings exactly.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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 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

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.

7 participants