mirror of
https://github.com/vllm-project/vllm.git
synced 2026-10-28 09:45:26 +08:00
[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:
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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user