You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(tokenizer): avoid GPU model imports for DeepSeek-V3.2 - #1658
Initializing a DeepSeek-V3.2 tokenizer currently imports deepseek3_2.model, which also loads model weights, inference layers, and GPU kernel dependencies. This unnecessarily exposes CPU-only PD masters and other tokenizer-only processes to GPU import failures.
Move the existing DeepSeekV32Tokenizer class unchanged into deepseek3_2/tokenizer.py and update the tokenizer factory. Replace the fake model-module stub in the import-isolation regression with the real wrapper, covering text encoding, thinking, and tool prompt construction while rejecting GPU model implementation imports.
Validation:
The strengthened regression fails on the original main import path and passes with this change.
Executed the regression subprocesses directly for both Llama and DeepSeek-V3.2 with CUDA_VISIBLE_DEVICES='' and HF_HUB_OFFLINE=1; pytest is unavailable in the validation environment.
Confirmed the moved tokenizer class is AST-identical to the original.
Repository Black and Flake8 hooks passed.
Summary by CodeRabbit
New Features
DeepSeek V3.2 now supports chat prompts in regular and thinking modes, including prompts with tools.
Chat prompts can be returned as text or encoded tokens, with generation prompts supported.
Bug Fixes
Tool definitions are formatted and attached to prompts so they can be included in chat requests.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: dcbdde2f-4d9f-4e11-b386-7f11dd6713bb
📥 Commits
Reviewing files that changed from the base of the PR and between b799a58 and 4c1002c.
📒 Files selected for processing: 4
lightllm/models/deepseek3_2/model.py
lightllm/models/deepseek3_2/tokenizer.py
lightllm/server/tokenizer.py
unit_tests/server/test_tokenizer.py
💤 Files with no reviewable changes: 1
lightllm/models/deepseek3_2/model.py
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
📝 Walkthrough
The DeepSeek V3.2 tokenizer wrapper moves from model.py to tokenizer.py. The server import and tokenizer tests are updated to use and verify the new module location.
Changes: DeepSeek V3.2 tokenizer
Layer / File(s)
Summary
Move the tokenizer wrapper lightllm/models/deepseek3_2/model.py, lightllm/models/deepseek3_2/tokenizer.py
The wrapper and its chat-template handling move from the model module to the tokenizer module.
Wire and verify tokenizer selection lightllm/server/tokenizer.py, unit_tests/server/test_tokenizer.py
The server imports the wrapper from the tokenizer module. Tests check regular, thinking, and tool template output, and verify that the model wrapper module is not loaded.
The tokenizer relocation has no identified broken repository callers and is ready for normal merge checks.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files.
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly and concisely describes the main change: preventing GPU model imports when initializing the DeepSeek-V3.2 tokenizer.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
Commit to this branch
Create a new PR
🧪 Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 @coderabbitai help to get the list of available commands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Initializing a DeepSeek-V3.2 tokenizer currently imports
deepseek3_2.model, which also loads model weights, inference layers, and GPU kernel dependencies. This unnecessarily exposes CPU-only PD masters and other tokenizer-only processes to GPU import failures.Move the existing
DeepSeekV32Tokenizerclass unchanged intodeepseek3_2/tokenizer.pyand update the tokenizer factory. Replace the fake model-module stub in the import-isolation regression with the real wrapper, covering text encoding, thinking, and tool prompt construction while rejecting GPU model implementation imports.Validation:
CUDA_VISIBLE_DEVICES=''andHF_HUB_OFFLINE=1; pytest is unavailable in the validation environment.Summary by CodeRabbit