[Bugfix] Fix MOSS-Audio meta initialization (#63629)

Signed-off-by: Tony Lin <tony.lin@intel.com>
Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
This commit is contained in:
Tony LinandCyrus Leung authored and GitHub committed 2026-10-26 04:07:30 +00:00
1 parent 5a224c1ef3
commit d7595a7678
2 files changed
+28 -3

No files matched your search

@@ -594,6 +594,29 @@ def test_moss_qwen3_deepstack_keys_for_pp(monkeypatch):
assert set(forward_tensors.tensors) == set(tensors.tensors)
@pytest.mark.parametrize("device", ["cpu", "meta"])
@pytest.mark.parametrize(("num_mel_bins", "conv_freq"), [(128, 16), (129, 17)])
def test_moss_audio_encoder_initialization(
dist_init: None, device: str, num_mel_bins: int, conv_freq: int
) -> None:
"""Encoder construction preserves projection shapes, including on meta."""
config = MossAudioEncoderConfig(
d_model=8,
output_dim=8,
num_mel_bins=num_mel_bins,
encoder_layers=1,
encoder_attention_heads=2,
encoder_ffn_dim=16,
downsample_hidden_size=2,
deepstack_encoder_layer_indexes=[],
)
with torch.device(device):
encoder = MossAudioEncoder(config)
assert encoder.stem_proj.weight.shape == (8, 2 * conv_freq)
assert all(param.device.type == device for param in encoder.parameters())
def test_moss_audio_encoder_loads_realistic_attention_weight_names(monkeypatch):
from vllm.config import VllmConfig, set_current_vllm_config
from vllm.config.device import DeviceConfig
+5 -3
View File
@@ -504,9 +504,11 @@ class MossAudioEncoder(nn.Module):
padding=(1, 1),
)
conv_freq = self._compute_downsampled_length(
torch.tensor(config.num_mel_bins)
).item()
# Use integer arithmetic because meta tensors do not support .item().
# Three convolutions with kernel=3, stride=2, padding=1 each yield
# ceil(n / 2); together they yield ceil(n / 8) = (n + 7) // 8.
conv_freq = (config.num_mel_bins + 7) // 8
self.stem_proj = ReplicatedLinear(
config.downsample_hidden_size * int(conv_freq),
config.d_model,