Commit 21e8dcf
[BugFix][SpecDecode] Fix low MTP acceptance rate for SFA+DSA_CP (MTP>1) (vllm-project#10825)
### What this PR does / why we need it?
Fixes a degraded multi-token-prediction (MTP) / speculative-decoding
acceptance rate on Ascend when num_speculative_tokens > 1 when enable
dsa_cp for sfa models.
Root cause: Root cause: In the SFA v1 attention-metadata builder
(vllm_ascend/attention/sfa_v1.py), the actual_seq_lengths_query /
actual_seq_lengths_key buffers handed to lightning indexer shared the
same memory buffer across all draft steps. With MTP > 1, the
attention-metadata is overwritten and only the last step is kept, which
leads to wrong inputs. Meanwhile, rotary cos/sin were also fetched from
an out-dated cache while drafting.
Changes:
- vllm_ascend/attention/sfa_v1.py: pre-allocate per-draft-step buffers
spec_actual_seq_lengths_query/key (one tensor per step, sized
max_num_reqs * (num_speculative_tokens + 1) + 1) so each step owns
independent, with no step overwrites another's metadata. Split the
builder into build() (non-draft/verify path),
build_for_drafting(draft_step, ...), and a shared _build(...,
draft_step) that selects the correct per-step buffer; pass
use_cache=False to get_cos_and_sin_mla while drafting so the rotary
tables are recomputed for each step.
- vllm_ascend/spec_decode/llm_base_proposer.py: when a builder exposes
build_for_drafting, route each draft step's attention-metadata build
through it instead of calling build(0, ...) for every step, so the
per-step buffers are actually used and cross-step aliasing is avoided.
Effect: correct per-step attention metadata and rotary embeddings →
restored MTP/spec-decode acceptance rate for num_speculative_tokens > 1.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
- vLLM version: v0.22.1
- vLLM main:
vllm-project/vllm@967c5c3
Co-authored-by: wu-yushan <wuyushan1@huawei.com>
Co-authored-by: YzTongNiar <1667927948@qq.com>
Co-authored-by: Orla-see <lidan276@huawei.com>
Co-authored-by: LookAround0301 <lixushi@huawei.com>1 parent 620555f commit 21e8dcf
2 files changed
Lines changed: 48 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
203 | 208 | | |
204 | 209 | | |
205 | 210 | | |
| |||
208 | 213 | | |
209 | 214 | | |
210 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
211 | 225 | | |
212 | 226 | | |
213 | 227 | | |
214 | 228 | | |
215 | 229 | | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | 230 | | |
221 | 231 | | |
222 | 232 | | |
| |||
240 | 250 | | |
241 | 251 | | |
242 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
243 | 269 | | |
244 | 270 | | |
245 | 271 | | |
| |||
265 | 291 | | |
266 | 292 | | |
267 | 293 | | |
268 | | - | |
| 294 | + | |
269 | 295 | | |
270 | 296 | | |
271 | 297 | | |
| |||
307 | 333 | | |
308 | 334 | | |
309 | 335 | | |
310 | | - | |
311 | | - | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
312 | 346 | | |
313 | 347 | | |
314 | 348 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1652 | 1652 | | |
1653 | 1653 | | |
1654 | 1654 | | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
1655 | 1662 | | |
1656 | 1663 | | |
1657 | 1664 | | |
| |||
0 commit comments