AttributeError: Qwen2Tokenizer has no attribute batch_encode_plus. Did you mean: '_encode_plus'?#870
AttributeError: Qwen2Tokenizer has no attribute batch_encode_plus. Did you mean: '_encode_plus'?#870jiyzhang wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
1. issues encountered
```
File "/app/TensorRT-Model-Optimizer/examples/llm_ptq/hf_ptq.py", line 146, in make_calib_dataloader
calib_dataloader = get_dataset_dataloader(
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/modelopt/torch/utils/dataset_utils.py", line 217, in get_dataset_dataloader
batch_encoded = tokenizer.batch_encode_plus(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/transformers/tokenization_utils_base.py", line 1291, in __getattr__
raise AttributeError(f"{self.__class__.__name__} has no attribute {key}")
AttributeError: Qwen2Tokenizer has no attribute batch_encode_plus. Did you mean: '_encode_plus'?
```
2. `batch_encode_plus` was deprecated, it's recommended to to `tokenizer(...)`
Signed-off-by: jiyzhang <jiyongzhang@gmail.com>
📝 WalkthroughWalkthroughThe change replaces Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
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 |
|
Do you know why Qwen3-Code-Next uses Qwen2 tokenizer? |
|
What does this PR do?
Type of change: ?
Bug fix
Overview: ?
The error below occurred when trying to quantize Qwen3 models (Qwen/Qwen3-Code-Next)
batch_encode_pluswas deprecated, it's recommended to totokenizer(...)File changed:
modelopt/torch/utils/dataset_utils.pyfrom
to
Usage
There is no change to the usage.
Testing
After the code modification, quantizing Qwen3 models works well.
Before your PR is "Ready for review"
Additional Information
Summary by CodeRabbit