Skip to content

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

Merged
shihaobai merged 2 commits into
mainfrom
fix/deepseek-v32-tokenizer-cpu-import
Oct 29, 2026
Merged

shihaobai merged 2 commits 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 supports chat prompts in regular and thinking modes, including prompts with tools.
    • Prompts can be returned as text or encoded tokens, with generation prompts supported.
    • Chat requests can provide messages using either the conversation or messages format.
  • Bug Fixes
    • Tool definitions are formatted and attached to prompts for inclusion 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: c28f01bf-f61a-4da6-9daf-ce734686d841
Commits

Reviewing files that changed from the base of the PR and between 4c1002c and 4c35bbf.

Files selected for processing: 3
  • lightllm/models/deepseek3_2/model.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; 6 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 module is not loaded.

Priority: Normal

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

Change: Bug fix

Possibly related PRs

  • ModelTC/LightLLM#1593: Adds a tokenizer-only path and import-isolation tests for DeepSeek-V4; this PR applies similar import-isolation testing to DeepSeek-V3.2.

Suggested reviewers: sufubao

Merge Risk: Minimal · up to 4c35b

No concrete merge-blocking risk was identified in the tokenizer relocation.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: preventing GPU model imports when initializing the DeepSeek-V3.2 tokenizer.
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
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
📝 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.

Resolve the tokenizer import-isolation test conflict while preserving
DeepSeek-V3.2 and DeepSeek-V4 coverage.

Validation: 29 tokenizer tests passed; Black and Flake8 passed.
@shihaobai
shihaobai merged commit 3760853 into main Oct 29, 2026
2 checks passed
@shihaobai
shihaobai deleted the fix/deepseek-v32-tokenizer-cpu-import branch October 29, 2026 06:12
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.

2 participants