Skip to content

fix(tokenizer): avoid GPU model imports for DeepSeek-V3.2 - #1658

Open
WANDY666 wants to merge 1 commit into
mainfrom
fix/deepseek-v32-tokenizer-cpu-import
Open

WANDY666 wants to merge 1 commit into
mainfrom
fix/deepseek-v32-tokenizer-cpu-import

Conversation

@WANDY666

@WANDY666 WANDY666 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

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.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: sufubao

Merge Risk: ⚪ Minimal · up to 4c100

The tokenizer relocation has no identified broken repository callers and is ready for normal merge checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning 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 Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: preventing GPU model imports when initializing the DeepSeek-V3.2 tokenizer.
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: 💡 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.

❤️ Share

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

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.

1 participant