fix(spec-decode): load draft token embedding from checkpoint under PP - #50
Open
Karl0007 wants to merge 1 commit into
Open
fix(spec-decode): load draft token embedding from checkpoint under PP#50Karl0007 wants to merge 1 commit into
Karl0007 wants to merge 1 commit into
Conversation
Under pipeline parallelism the drafter runs on the LAST rank while the target's embed_tokens lives on the FIRST, so there is nothing local to alias. MTP's load_weights() filters out every non-spec-layer key, so the draft's own embed_tokens stayed uninitialised memory and the draft emitted constant garbage tokens (acceptance ~= 1). Previously sharing was skipped wholesale whenever PP world size != 1. Now: share when the target embedding is materialised on this rank (_has_real_weight guards against aliasing a PPMissingLayer, which would silently produce a no-op layer), otherwise populate the draft's own embedding by reading the one tensor off the checkpoint via model.safetensors.index.json - no cross-rank collective needed. Verified on 4x sm80 64GB (GLM-5.3-Flash AWQ W4A16, PP4 14,12,12,7 + MTP num_speculative_tokens=5): draft acceptance went from ~1 to 46-56% (mean acceptance length 3.3-3.8), correctness battery 9/9. Signed-off-by: kk <kk@cmp170hx>
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.
Problem
Under pipeline parallelism the spec-decode drafter runs on the last PP rank while the target's
embed_tokenslives on the first rank — so there is nothing local to alias into the draft. Compounding this, MTP'sload_weights()filters out every non-spec-layer key (including the top-levelembed_tokens), so the draft's own embedding stays uninitialised GPU memory. The draft then emits near-constant garbage tokens: acceptance ≈ 1, and MTP+PP silently degrades to pure target decode (or worse).Current code skips embedding sharing wholesale whenever
pp world_size != 1, so this configuration has no correct path.Fix
_has_real_weightguard prevents aliasing aPPMissingLayer(which has no.weightand would silently become a no-op layer).model.safetensors.index.json(candidate keys cover GLM5-Next's language-model prefix). No cross-rank collective needed; one-time load cost.Verified on 4× sm_80 64 GB (PCIe, no P2P), GLM-5.3-Flash AWQ W4A16,
PP4 14,12,12,7+--speculative-config {"method":"mtp","num_speculative_tokens":5}:Same shape also validated with DSpark (PP4 + DSpark5: acceptance length 3.11, 42.3%), so the fix generalises beyond EAGLE-style MTP.