fix: Add get_hf_tokenizer_kwargs to NemotronHBridge#2664
fix: Add get_hf_tokenizer_kwargs to NemotronHBridge#2664shanecmoran wants to merge 1 commit intoNVIDIA-NeMo:mainfrom
Conversation
📝 WalkthroughWalkthroughAdds the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/unit_tests/models/nemotronh/test_nemotron_h_bridge.py (1)
358-370: Add a test category marker on the new tokenizer kwargs suite.Please add a
pytest.markclassification (for example,unit) to this new test class to match the test categorization convention.Suggested change
+@pytest.mark.unit class TestNemotronHBridgeTokenizerKwargs: """Test get_hf_tokenizer_kwargs method."""As per coding guidelines, "Use 'pytest.mark' to categorize tests (unit, integration, system)."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/unit_tests/models/nemotronh/test_nemotron_h_bridge.py` around lines 358 - 370, The test class TestNemotronHBridgeTokenizerKwargs lacks a pytest.mark category; add a marker (e.g., `@pytest.mark.unit`) above the class definition to classify these tests as unit tests and keep suite conventions consistent—apply the decorator to the TestNemotronHBridgeTokenizerKwargs class that contains calls to NemotronHBridge.get_hf_tokenizer_kwargs().
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/unit_tests/models/nemotronh/test_nemotron_h_bridge.py`:
- Around line 358-370: The test class TestNemotronHBridgeTokenizerKwargs lacks a
pytest.mark category; add a marker (e.g., `@pytest.mark.unit`) above the class
definition to classify these tests as unit tests and keep suite conventions
consistent—apply the decorator to the TestNemotronHBridgeTokenizerKwargs class
that contains calls to NemotronHBridge.get_hf_tokenizer_kwargs().
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9eafc85f-c796-4c56-b48a-7345116880a4
📒 Files selected for processing (2)
src/megatron/bridge/models/nemotronh/nemotron_h_bridge.pytests/unit_tests/models/nemotronh/test_nemotron_h_bridge.py
|
/ok to test 7d29884 |
Nemotron Nano v2 models only provide a fast tokenizer
(tokenizer.json, no tokenizer.model). The container's megatron-core
defaults use_fast=False, causing AutoTokenizer.from_pretrained to
silently return False instead of a tokenizer object, which then
crashes on self.tokenizer.chat_template during checkpoint conversion.
Add get_hf_tokenizer_kwargs returning {"use_fast": True}, following
the existing GLM45VBridge pattern. The call site in auto_bridge.py
already uses hasattr to check for this method.
Fixes: NVIDIA-NeMo#2663
Signed-off-by: Shane Moran <shane.moran@shopify.com>
7d29884 to
a5588a7
Compare
Summary
Nemotron Nano v2 models only provide a fast tokenizer (
tokenizer.json, notokenizer.model). The container's megatron-core defaultsuse_fast=False, causingAutoTokenizer.from_pretrainedto silently returnFalseinstead of a tokenizer object, which crashes during checkpoint conversion.Changes
get_hf_tokenizer_kwargs()classmethod toNemotronHBridgereturning{"use_fast": True}Follows the existing
GLM45VBridgepattern. The call site inauto_bridge.py:768already useshasattrto check for this method — no other changes needed.Fixes #2663
Summary by CodeRabbit
New Features
Tests