Warn on and normalize partial_rotary_factor declarations the DSpark modeling does not implement - #72
Open
arthurgao2003 wants to merge 1 commit into
Conversation
…not implement DSpark's Qwen3 draft modeling applies RoPE across the full head dim, but build_draft_config deepcopies the target config, so a target (or DFlash warm-start checkpoint) declaring partial_rotary_factor != 1.0 leaks the field into saved draft checkpoints verbatim. Serving engines that honor it (e.g. vLLM's dflash/dspark path) then rotate fewer dims than training did, silently collapsing acceptance length (observed 2.53 offline -> ~1.4 in vLLM; recovers to 2.59 once the config declares 1.0). - build_draft_config now normalizes the declaration to 1.0 with a warning - Qwen3DSparkModel init warns when loading a config that still declares partial RoPE (covers pre-existing checkpoints) Fixes deepseek-ai#71 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #71.
Problem
The DSpark Qwen3 draft modeling applies RoPE across the full head dim (custom
apply_rotary_pos_embhas no rotary/pass-through split, andQwen3RotaryEmbeddingyields full-dim cos/sin for this config), butbuild_draft_configstarts fromcopy.deepcopy(target_config). A target — or a DFlash warm-start checkpoint — that declarespartial_rotary_factor != 1.0(Qwen3.5-family targets do) leaks the field into the saved draft checkpoint verbatim. The checkpoint is then self-inconsistent: weights trained with full-dim rotation, config declaring partial rotation.Serving engines that honor the field, e.g. vLLM's dflash/dspark path, rotate
head_dim * factordims — a silent train/serve geometry mismatch. Measured on a Qwen3.5-27B-class target with a 5-layer draft warm-started from z-lab DFlash: offline AL 2.53 → vLLM serving AL ~1.4; recovers to 2.59 (matching offline) once the config declares 1.0. Full analysis in #71.Change
common.py:declared_partial_rotary_factor(config)(readsrope_parameters/rope_scaling/ top-level) andcheck_partial_rotary_factor(config, normalize=False).qwen3/config.py:build_draft_confignormalizes the declaration to 1.0 (with a warning) right after the deepcopy, so newly produced checkpoints describe the trained geometry.qwen3/modeling.py:Qwen3DSparkModel.__init__warns when loading a config that still declares partial RoPE — covers pre-existing checkpoints and externally generated configs.No numerics change: training already rotated the full head dim; this only makes the saved declaration truthful and surfaces the mismatch for old checkpoints.
Testing
rope_parameters/rope_scaling/ top-level; normalize rewrites all present locations; clean configs stay silent and untouched.Qwen3Configwithpartial_rotary_factor=0.25throughbuild_draft_config→ one normalize warning, all declarations = 1.0;Qwen3DSparkModelinit on the normalized config is silent, init on a dirty config fires exactly one warning; tiny model instantiates fine on CPU.