[BugFix] Fix Qwen3 Omni talker mtp torch.compile startup error (#1104)

Signed-off-by: ram16g <anlianfengjie@163.com>
Signed-off-by: ZeldaHuang <hzm414167@alibaba-inc.com>
Co-authored-by: ram16g <anlianfengjie@163.com>
Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
This commit is contained in:
authored and GitHub committed 2026-01-30 23:25:49 +08:00
1 parent 4eeea68cff
commit f6cfc0d1e3
4 files changed
+25 -19

No files matched your search

@@ -458,10 +458,6 @@ class Qwen3OmniMoeTalkerCodePredictor(nn.Module):
TopPLogitsWarper(top_p=0.8),
]
)
max_batch_size = vllm_config.scheduler_config.max_num_seqs
self.position_ids_buffer = []
for layer_idx in range(self.num_code_groups - 1):
self.position_ids_buffer.append(torch.arange(layer_idx + 2, dtype=torch.int64).repeat(max_batch_size))
compilation_config = get_current_vllm_config().compilation_config
if prefix in compilation_config.static_forward_context:
@@ -508,13 +504,11 @@ class Qwen3OmniMoeTalkerCodePredictor(nn.Module):
batch_size = current_input.shape[0]
# Predict all residual layers (layers 1 to num_code_groups-1) autoregressively
begin_pos = 0
for layer_idx in range(self.num_code_groups - 1):
# Input for this layer: [last_talker_hidden, prev_layer_embed]
seq_len = layer_idx + 2
# Compute position_ids dynamically to avoid torch.compile specializing batch_size
position_ids = torch.arange(seq_len, device=current_input.device, dtype=torch.int64).repeat(batch_size)
# Forward through code_predictor model
position_ids = self.position_ids_buffer[layer_idx][: (layer_idx + 2) * batch_size] # [1, seq_len]
begin_pos += layer_idx + 2
outputs = self.model(
inputs_embeds=current_input,
attention_mask=None,
@@ -135,8 +135,11 @@ class Qwen3OmniMoeTalkerForConditionalGeneration(
self.code_predictor = Qwen3OmniMoeTalkerCodePredictor(
vllm_config=vllm_config, prefix=maybe_prefix(prefix, "code_predictor")
)
max_batch_size = max(
vllm_config.scheduler_config.max_num_seqs, vllm_config.compilation_config.max_cudagraph_capture_size
)
self.layer0_embed_buffer = torch.zeros(
(vllm_config.scheduler_config.max_num_seqs, 1, self.config.text_config.hidden_size),
(max_batch_size, 1, self.config.text_config.hidden_size),
dtype=vllm_config.model_config.dtype,
)