Skip to content

[https://nvbugs/6162328][fix] Add a tiny compat shim in load_hf_tokenizer that, when bytes_to_unicode is m#14090

Merged
xinhe-nv merged 4 commits into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6162328
May 26, 2026
Merged

[https://nvbugs/6162328][fix] Add a tiny compat shim in load_hf_tokenizer that, when bytes_to_unicode is m#14090
xinhe-nv merged 4 commits into
NVIDIA:mainfrom
tensorrt-cicd:repair-bot-bug6162328

Conversation

@tensorrt-cicd

@tensorrt-cicd tensorrt-cicd commented May 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

Test plan

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

Links

Summary by CodeRabbit

  • Bug Fixes
    • Fixed compatibility issue with legacy GPT-2 tokenizers that rely on older import paths, ensuring these tokenizers can be loaded successfully without errors.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR adds a compatibility shim to restore the missing bytes_to_unicode function in Transformers' legacy GPT-2 tokenization module location. The helper is invoked early in load_hf_tokenizer() to enable legacy trust_remote_code tokenizers to import successfully despite API reorganization in newer Transformers versions.

Changes

GPT-2 bytes_to_unicode Compatibility

Layer / File(s) Summary
GPT-2 bytes_to_unicode compatibility helper
tensorrt_llm/tokenizer/tokenizer.py
_ensure_gpt2_bytes_to_unicode_compat() patches transformers.models.gpt2.tokenization_gpt2.bytes_to_unicode by importing from the newer transformers.convert_slow_tokenizer location, with early return if already present and silent no-op on import failures. The helper is called in load_hf_tokenizer() before tokenizer instantiation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title is truncated and incomplete, cutting off mid-word ('bytes_to_unicode is m'). While it references the correct bug ID and describes the general intent, the truncation makes it unclear and fails to communicate the complete change. Provide the complete, untruncated title. The title should clearly state the full purpose, e.g., '[https://nvbugs/6162328][fix] Add compatibility shim for bytes_to_unicode in load_hf_tokenizer'.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
Description check ✅ Passed The PR description clearly explains the root cause (transformers 5.3.0 removed bytes_to_unicode re-export), the fix (compatibility shim), test verification, and includes relevant bug tracking links.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tensorrt_llm/tokenizer/tokenizer.py (1)

1-1: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add/update the required NVIDIA copyright header on this modified source file.

This file was modified, but the required header/year update is missing in the provided content.

As per coding guidelines, "All TensorRT-LLM source files must contain an NVIDIA copyright header with year of latest modification, using the Apache 2.0 license text".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tensorrt_llm/tokenizer/tokenizer.py` at line 1, Add the required NVIDIA
copyright header (with the year of latest modification) and Apache 2.0 license
block to the top of tokenizer.py (above the existing importlib statement);
ensure the header text matches the project's standard NVIDIA copyright +
Apache-2.0 boilerplate and the year reflects the most recent change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@tensorrt_llm/tokenizer/tokenizer.py`:
- Line 1: Add the required NVIDIA copyright header (with the year of latest
modification) and Apache 2.0 license block to the top of tokenizer.py (above the
existing importlib statement); ensure the header text matches the project's
standard NVIDIA copyright + Apache-2.0 boilerplate and the year reflects the
most recent change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d4fa2bf4-75f7-4aef-b610-3adc4df316d0

📥 Commits

Reviewing files that changed from the base of the PR and between be4f57e and a724e49.

📒 Files selected for processing (1)
  • tensorrt_llm/tokenizer/tokenizer.py

@tensorrt-cicd
tensorrt-cicd force-pushed the repair-bot-bug6162328 branch 2 times, most recently from a9e9bf7 to 8600751 Compare May 21, 2026 05:55
…tokenizers on transformers 5.x

Signed-off-by: tensorrt-cicd <90828364+tensorrt-cicd@users.noreply.github.com>
Signed-off-by: tensorrt-cicd <90828364+tensorrt-cicd@users.noreply.github.com>
@tensorrt-cicd
tensorrt-cicd force-pushed the repair-bot-bug6162328 branch from 8600751 to 6f44f6e Compare May 25, 2026 07:43
@xinhe-nv
xinhe-nv requested review from Superjomn and xinhe-nv May 25, 2026 08:50

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

LGTM

@xinhe-nv
xinhe-nv enabled auto-merge (squash) May 25, 2026 08:59
@xinhe-nv

Copy link
Copy Markdown
Collaborator

/bot run --skip-test

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator Author

PR_Github #50191 [ run ] triggered by Bot. Commit: f6cba14 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator Author

PR_Github #50191 [ run ] completed with state SUCCESS. Commit: f6cba14
/LLM/main/L0_MergeRequest_PR pipeline #39732 (Partly Tested) completed with status: 'SUCCESS'
Pipeline passed with automatic retried tests. Check the rerun report for details.

CI Report

Link to invocation

@xinhe-nv

Copy link
Copy Markdown
Collaborator

/bot reuse-pipeline

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator Author

PR_Github #50242 [ reuse-pipeline ] triggered by Bot. Commit: 6afc168 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator Author

PR_Github #50242 [ reuse-pipeline ] completed with state SUCCESS. Commit: 6afc168
Reusing PR_Github #50191 (Partly Tested) for commit 6afc168

Link to invocation

@xinhe-nv
xinhe-nv merged commit 31826c1 into NVIDIA:main May 26, 2026
10 checks passed
@xinhe-nv
xinhe-nv deleted the repair-bot-bug6162328 branch May 26, 2026 01:39
bmarimuthu-nv pushed a commit to nv-auto-deploy/TensorRT-LLM that referenced this pull request May 28, 2026
…nizer` that, when `bytes_to_unicode` is m (NVIDIA#14090)

Signed-off-by: tensorrt-cicd <90828364+tensorrt-cicd@users.noreply.github.com>
Co-authored-by: xinhe-nv <200704525+xinhe-nv@users.noreply.github.com>
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.

3 participants