Commit 8f8c56f
[BugFix][SpecDecode] Fix low MTP acceptance rate for SFA+DSA_CP (MTP>1) (vllm-project#10878)
### 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.
Align Ascend attention builders' build_for_drafting with vllm's base
convention (common_attn_metadata, draft_index) so all spec-decode draft
paths go through one consistent entry point.
- sfa_v1.py: split build() into build()/build_for_drafting()/_build();
pre-allocate per-draft-step spec_actual_seq_lengths_query/key buffers so
each draft step owns independent metadata (no cross-step aliasing);
recompute rotary (use_cache=False) while drafting.
- llm_base_proposer.py: drop the else->build(0,...,model) branch; route
all draft steps through build_for_drafting(common_attn_metadata,
draft_index, **extra). Standard-attention drafters (eagle/eagle3/mtp on
Qwen/Llama) now hit the base build_for_drafting -> build(0, m,
fast_build=True), fixing the 'int' object has no attribute 'num_reqs'
crash from the swapped-positional elif. Rename draft_step ->
draft_index.
- dsa_v1.py / dsa_cp.py: swap build_for_drafting arg order to
(common_attn_metadata, draft_index, ...) and rename draft_step ->
draft_index for consistency.
- vLLM version: v0.23.0
- 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>1 parent c093794 commit 8f8c56f
4 files changed
Lines changed: 94 additions & 65 deletions
File tree
- vllm_ascend
- attention
- context_parallel
- spec_decode
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
355 | | - | |
356 | 355 | | |
| 356 | + | |
357 | 357 | | |
358 | 358 | | |
359 | 359 | | |
| |||
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
384 | | - | |
| 384 | + | |
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
390 | | - | |
| 390 | + | |
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
| |||
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
416 | | - | |
| 416 | + | |
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
| |||
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
445 | | - | |
446 | | - | |
| 445 | + | |
| 446 | + | |
447 | 447 | | |
448 | 448 | | |
449 | 449 | | |
| |||
463 | 463 | | |
464 | 464 | | |
465 | 465 | | |
466 | | - | |
| 466 | + | |
467 | 467 | | |
468 | 468 | | |
469 | 469 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1133 | 1133 | | |
1134 | 1134 | | |
1135 | 1135 | | |
1136 | | - | |
1137 | 1136 | | |
| 1137 | + | |
1138 | 1138 | | |
1139 | 1139 | | |
1140 | 1140 | | |
| |||
1147 | 1147 | | |
1148 | 1148 | | |
1149 | 1149 | | |
1150 | | - | |
| 1150 | + | |
1151 | 1151 | | |
1152 | 1152 | | |
1153 | 1153 | | |
1154 | 1154 | | |
1155 | | - | |
| 1155 | + | |
1156 | 1156 | | |
1157 | 1157 | | |
1158 | 1158 | | |
1159 | 1159 | | |
1160 | 1160 | | |
1161 | 1161 | | |
1162 | | - | |
| 1162 | + | |
1163 | 1163 | | |
1164 | 1164 | | |
1165 | 1165 | | |
| |||
1169 | 1169 | | |
1170 | 1170 | | |
1171 | 1171 | | |
1172 | | - | |
| 1172 | + | |
1173 | 1173 | | |
1174 | 1174 | | |
1175 | 1175 | | |
| |||
1198 | 1198 | | |
1199 | 1199 | | |
1200 | 1200 | | |
1201 | | - | |
| 1201 | + | |
1202 | 1202 | | |
1203 | 1203 | | |
1204 | 1204 | | |
| |||
1218 | 1218 | | |
1219 | 1219 | | |
1220 | 1220 | | |
1221 | | - | |
| 1221 | + | |
1222 | 1222 | | |
1223 | 1223 | | |
1224 | 1224 | | |
| |||
1270 | 1270 | | |
1271 | 1271 | | |
1272 | 1272 | | |
1273 | | - | |
| 1273 | + | |
1274 | 1274 | | |
1275 | 1275 | | |
1276 | 1276 | | |
| |||
1295 | 1295 | | |
1296 | 1296 | | |
1297 | 1297 | | |
1298 | | - | |
| 1298 | + | |
1299 | 1299 | | |
1300 | 1300 | | |
1301 | 1301 | | |
1302 | | - | |
| 1302 | + | |
1303 | 1303 | | |
1304 | 1304 | | |
1305 | 1305 | | |
| |||
| 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 | | |
| |||
0 commit comments