[Bugfix][Qwen3-Omni] Handle missing packed modules mapping (#6748)

Signed-off-by: psv666 <2693925048@qq.com>
Co-authored-by: Gao Han <hgaoaf@connect.ust.hk>
This commit is contained in:
psv666andGao Han authored and GitHub committed 2026-08-29 15:24:49 +08:00
1 parent 08cdee8dc4
commit 5c47fd0bc8
2 files changed
+65 -3

No files matched your search

@@ -0,0 +1,62 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
"""Regression tests for nested Qwen3-Omni quantization config mapping."""
from dataclasses import dataclass
import pytest
from vllm_omni.model_executor.models.qwen3_omni.quantization import (
_OUTER_MAPPING_APPLIED,
apply_nested_quant_config_mapping,
)
pytestmark = [pytest.mark.core_model, pytest.mark.cpu]
@dataclass
class _QuantConfig:
packed_modules_mapping: dict[str, list[str]]
@dataclass
class _NestedModel:
quant_config: _QuantConfig | None
@dataclass
class _NestedModelWithPackedModules(_NestedModel):
packed_modules_mapping: dict[str, list[str]]
def _mapped_quant_config(**packed_modules_mapping):
quant_config = _QuantConfig(packed_modules_mapping=packed_modules_mapping)
setattr(quant_config, _OUTER_MAPPING_APPLIED, True)
return quant_config
def test_nested_mapping_ignores_missing_quant_config():
apply_nested_quant_config_mapping(_NestedModel(quant_config=None))
def test_nested_mapping_allows_model_without_packed_modules_mapping():
quant_config = _mapped_quant_config(existing=["module"])
apply_nested_quant_config_mapping(_NestedModel(quant_config=quant_config))
assert quant_config.packed_modules_mapping == {"existing": ["module"]}
def test_nested_mapping_merges_packed_modules_mapping():
quant_config = _mapped_quant_config(existing=["module"])
model = _NestedModelWithPackedModules(
quant_config=quant_config,
packed_modules_mapping={"qkv_proj": ["q_proj", "k_proj", "v_proj"]},
)
apply_nested_quant_config_mapping(model)
assert quant_config.packed_modules_mapping == {
"existing": ["module"],
"qkv_proj": ["q_proj", "k_proj", "v_proj"],
}
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
"""Quantization mapping helpers for nested Qwen3-Omni stages."""
from vllm.model_executor.models.interfaces import SupportsQuant
@@ -25,8 +25,8 @@ def apply_nested_quant_config_mapping(model: SupportsQuant) -> None:
# The outer model maps names, while the nested model still contributes
# fused-module metadata needed by quantization scheme matching.
if model.packed_modules_mapping is not None:
quant_config.packed_modules_mapping.update(model.packed_modules_mapping)
if packed_modules_mapping := getattr(model, "packed_modules_mapping", None):
quant_config.packed_modules_mapping.update(packed_modules_mapping)
class Qwen3OmniNestedSupportsQuant(SupportsQuant):