fix: per-sequence last-token embedding in EAGLE3/MTP draft for batched multimodal spec decoding (#27846)

This commit is contained in:
Jackey Hua
2026-06-11 13:33:16 -07:00
committed by GitHub
parent 10219bd9d6
commit 24c5d76f74
2 changed files with 9 additions and 8 deletions
+4 -3
View File
@@ -198,9 +198,10 @@ class LlamaModel(nn.Module):
and not forward_batch.forward_mode.is_draft_extend(include_v2=True)
):
assert embeds is not None
embeds = torch.cat(
[embeds[:-1], self.embed_tokens(input_ids[-1].unsqueeze(0))]
)
last_indices = (
forward_batch.extend_start_loc + forward_batch.extend_seq_lens - 1
).long()
embeds[last_indices] = self.embed_tokens(input_ids[last_indices])
if embeds is None:
embeds = self.embed_tokens(input_ids)
else:
+5 -5
View File
@@ -163,11 +163,11 @@ class Qwen3_5ForCausalLMMTP(nn.Module):
and not forward_batch.forward_mode.is_draft_extend(include_v2=True)
):
assert input_embeds is not None
input_embeds = torch.cat(
[
input_embeds[:-1],
self.model.embed_tokens(input_ids[-1].unsqueeze(0)),
]
last_indices = (
forward_batch.extend_start_loc + forward_batch.extend_seq_lens - 1
).long()
input_embeds[last_indices] = self.model.embed_tokens(
input_ids[last_indices]
)
if input_embeds is None: