[Feature] Support Prefill-Decode disaggregation via vLLM KV transfer (#2220)

Signed-off-by: LiuBingyu <liubingyu62@gmail.com>
This commit is contained in:
Bingyu (Spencer) Liu authored and GitHub committed 2026-04-17 18:43:17 +08:00
1 parent b88d3ce75e
commit a5a4998ece
11 files changed
+1672 -48

No files matched your search

@@ -891,10 +891,11 @@ class Qwen3OmniMoeForConditionalGeneration(
Returns:
(input_ids, input_embeds) for talker
"""
target_len = thinker_result_ids.shape[-1]
im_start_indexes = torch.cat(
(
torch.nonzero(input_ids[0] == self.config.im_start_token_id).squeeze(),
torch.tensor([thinker_result_ids.shape[-1]], device=input_ids.device, dtype=input_ids.dtype),
torch.tensor([target_len], device=input_ids.device, dtype=input_ids.dtype),
),
dim=-1,
) # Shape [n_starts + 1]; Take batch 0 since batched inference is not supported here.
@@ -1029,8 +1030,35 @@ class Qwen3OmniMoeForConditionalGeneration(
return last_talker_hidden, text_step, update_dict
def _get_talker_user_parts(self, im_start_index, segment_end_index, multimodal_mask, thinker_hidden, thinker_embed):
clamped = min(
segment_end_index,
multimodal_mask.shape[0],
thinker_hidden.shape[0],
thinker_embed.shape[0],
)
if clamped < segment_end_index:
logger.warning(
"_get_talker_user_parts: segment_end_index %d clamped to %d "
"(embed=%d, hidden=%d, mask=%d). "
"This usually means _merge_pd_embeddings failed to merge "
"prefill embeddings – check PD prefill_mm keys.",
segment_end_index,
clamped,
thinker_embed.shape[0],
thinker_hidden.shape[0],
multimodal_mask.shape[0],
)
segment_end_index = clamped
seg_len = segment_end_index - im_start_index
if seg_len <= 0:
return torch.empty(
(0, self.config.talker_config.text_config.hidden_size),
device=thinker_hidden.device,
dtype=torch.bfloat16,
)
user_talker_part = torch.empty(
(segment_end_index - im_start_index, self.config.talker_config.text_config.hidden_size),
(seg_len, self.config.talker_config.text_config.hidden_size),
device=thinker_hidden.device,
dtype=torch.bfloat16,
)