[Fix] Fixes speculative decode indexing and unpad condition for attention metadata (#5626)

### What this PR does / why we need it?
This addresses the issue brought up by #5356 and #4963, and we believe
the unnecessary conditions are the root cause.

Change the unpad trigger to be driven by actual size mismatches
(num_reqs vs base_num_reqs or scheduled vs input token counts) rather
than specific speculative-method flags. Then remove brittle workarounds
that forced request counts and sliced query start locations.

This prevents incorrect indexing and length mismatches during
speculative decoding and makes metadata unpadding more robust across
scheduling modes.

### Does this PR introduce _any_ user-facing change?
None.

### How was this patch tested?
Tested by existing cases.

- vLLM version: v0.13.0
- vLLM main:
8be6432bda

---------

Signed-off-by: Yizhou Liu <liu_yizhou@outlook.com>
This commit is contained in:
Yizhou
2026-01-08 19:41:08 +08:00
committed by GitHub
parent 503822c56c
commit f4605c2b3c
3 changed files with 9 additions and 15 deletions

View File

@@ -1013,9 +1013,7 @@ class NPUModelRunner(GPUModelRunner):
if self.speculative_config and \
self.spec_decode_common_attn_metadata is None:
self.spec_decode_common_attn_metadata = common_attn_metadata
if self.speculative_config.method in ("eagle", "eagle3") and \
(self.vllm_config.speculative_config.enforce_eager \
or self.use_async_scheduling):
if num_reqs != base_num_reqs or total_num_scheduled_tokens != num_input_tokens:
self.spec_decode_common_attn_metadata = \
self.spec_decode_common_attn_metadata.unpadded(
total_num_scheduled_tokens, base_num_reqs)