bugfix: redirect draft-extend placeholder KV write to padding block.#1944
Open
weizhehuang0827 wants to merge 1 commit into
Open
bugfix: redirect draft-extend placeholder KV write to padding block.#1944weizhehuang0827 wants to merge 1 commit into
weizhehuang0827 wants to merge 1 commit into
Conversation
When dp_enabled=true or use_chunked_prefill=true, draft extend always adds a prev_token row. If prev_token_id < 0 (first decode after prefill or all-draft-rejected), the placeholder row overwrites a valid KV cache entry at position-1, permanently degrading speculative acceptance rate. Fix: detect placeholder rows and redirect their new_cache_slots to block 0 (reserved padding block), preserving the correct KV cache content while maintaining DP token-count alignment. Verified on DeepSeek-V3.2-w8a8 (DP=2, num_speculative_tokens=3): - seed1 1req: 41.97% vs 39.86% (nofix), +2.11% - seed3 1req: 16.67% vs 16.67% (identical, short request) - seed4 1req: 57.02% vs 54.70% (nofix), +2.32% - 4req seed1: 48.47% vs 48.33% (nofix), drafted count identical (687)
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.
Description
Summary
dp_enabled=trueorenable_atb_spec_kernel=true, draft extend always adds a prev_token row for DP token-count alignmentprev_token_id < 0(first decode after prefill or all-draft-rejected), the placeholder row overwrites a valid KV cache entry at position-1, permanently degrading speculative acceptance ratenew_cache_slotsto block 0 (reserved padding block), preserving correct KV cache contentTest Results
Verified on DeepSeek-V3.2-w8a8 full model (DP=2, num_speculative_tokens=3, enable_atb_spec_kernel=false):
Related Issues
Change Type
Pull Request Checklist
Thank you for contributing to xLLM. Before requesting review, please make sure the following items are complete.
PR Title and Commit Messages
<type>: <subject>.Pre-commit Checks
pre-commitby runningpip install pre-commitor an equivalent command.pre-commit install.pre-commit run --all-filesand fixed any reported issues.Self Review
.agents/skills/code-review/references/custom-code-style.md, especially code written or assisted by AI.mainbranch.Build and Test Coverage
python setup.py build testhas passed on a CUDA machine.python setup.py build testhas passed on an NPU machine.python setup.py build testhas passed on an MLU machine.Reviewer Notes