[BugFix] Disable TP for Qwen3-Omni audio encoder when heads % TP != 0 (#50858)
Signed-off-by: CalvinXKY <xky@users.noreply.github.com> Co-authored-by: CalvinXKY <xky@users.noreply.github.com>
This commit is contained in:
@@ -196,8 +196,13 @@ class Qwen3OmniMoeAudioAttention(nn.Module):
|
||||
self.embed_dim = config.d_model
|
||||
self.num_heads = config.encoder_attention_heads
|
||||
self.head_dim = self.embed_dim // self.num_heads
|
||||
# Audio encoder uses 20 heads. Shard across TP when divisible
|
||||
# (e.g. TP=2/4); otherwise keep unreplicated (e.g. TP=8).
|
||||
tp_size = get_tensor_model_parallel_world_size()
|
||||
self.num_local_heads = self.num_heads // tp_size
|
||||
self.disable_tp = self.num_heads % tp_size != 0
|
||||
self.num_local_heads = (
|
||||
self.num_heads if self.disable_tp else self.num_heads // tp_size
|
||||
)
|
||||
|
||||
if (self.head_dim * self.num_heads) != self.embed_dim:
|
||||
raise ValueError(
|
||||
@@ -214,6 +219,7 @@ class Qwen3OmniMoeAudioAttention(nn.Module):
|
||||
total_num_kv_heads=self.num_heads,
|
||||
bias=True,
|
||||
prefix=f"{prefix}.qkv_proj",
|
||||
disable_tp=self.disable_tp,
|
||||
)
|
||||
|
||||
self.out_proj = RowParallelLinear(
|
||||
@@ -221,6 +227,7 @@ class Qwen3OmniMoeAudioAttention(nn.Module):
|
||||
output_size=self.embed_dim,
|
||||
bias=True,
|
||||
prefix=f"{prefix}.out_proj",
|
||||
disable_tp=self.disable_tp,
|
||||
)
|
||||
|
||||
self.attn = MMEncoderAttention(
|
||||
|
||||
Reference in New Issue
Block a user