[MyPy][3/N] Fix MyPy errors in test groups (part 3) (#55939)
Signed-off-by: Taimys <ffy2281693949@gmail.com> Signed-off-by: Luyi Xiao <81631911+luyixiao95@users.noreply.github.com> Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Codex <noreply@openai.com> Co-authored-by: Luyi Xiao <81631911+luyixiao95@users.noreply.github.com> Co-authored-by: Taimys <ffy2281693949@gmail.com> Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Codex
Luyi Xiao
Taimys
Harry Mellor
Claude Opus 5.5
parent
c4fa6f36a7
commit
5225f1bacb
@@ -16,6 +16,7 @@ from tests.quantization.utils import (
|
||||
_test_online_quant_peak_mem_impl,
|
||||
is_quant_method_supported,
|
||||
load_model_without_vllm_runner,
|
||||
quant_config_args,
|
||||
)
|
||||
from vllm import _custom_ops as ops
|
||||
from vllm._aiter_ops import rocm_aiter_ops
|
||||
@@ -180,7 +181,7 @@ def test_qianfan_online_fp8_keeps_vision_layers_unquantized(
|
||||
config = OnlineQuantizationConfig(args)
|
||||
other_config = OnlineQuantizationConfig(args)
|
||||
model = QianfanOCRForConditionalGeneration.__new__(
|
||||
QianfanOCRForConditionalGeneration
|
||||
QianfanOCRForConditionalGeneration # type: ignore[type-abstract]
|
||||
)
|
||||
model._patch_quant_config(
|
||||
SimpleNamespace(vision_config=SimpleNamespace(num_hidden_layers=2)),
|
||||
@@ -209,9 +210,9 @@ def test_online_nvfp4_reuses_kernel_when_weights_are_reprocessed(
|
||||
monkeypatch,
|
||||
) -> None:
|
||||
method = object.__new__(Nvfp4OnlineMoEMethod)
|
||||
method.moe = SimpleNamespace(is_act_and_mul=True)
|
||||
method.nvfp4_backend = object()
|
||||
method.experts_cls = object
|
||||
method.moe = SimpleNamespace(is_act_and_mul=True) # type: ignore[assignment]
|
||||
method.nvfp4_backend = object() # type: ignore[assignment] # Opaque mocked-backend sentinel.
|
||||
method.experts_cls = object # type: ignore[assignment] # Opaque mocked-expert sentinel.
|
||||
method.moe_quant_config = None
|
||||
method.moe_kernel = None
|
||||
|
||||
@@ -239,7 +240,7 @@ def test_online_nvfp4_reuses_kernel_when_weights_are_reprocessed(
|
||||
)
|
||||
make_kernel = Mock(return_value=kernel)
|
||||
get_quant_config = Mock(return_value=quant_config)
|
||||
method.get_fused_moe_quant_config = get_quant_config
|
||||
monkeypatch.setattr(method, "get_fused_moe_quant_config", get_quant_config)
|
||||
|
||||
monkeypatch.setattr(
|
||||
"vllm.model_executor.layers.quantization.online.nvfp4."
|
||||
@@ -355,7 +356,7 @@ def test_online_prequantized_compatibility(
|
||||
checkpoint_config = checkpoint_config_factory()
|
||||
|
||||
checkpoint_config.online_quantization_config = OnlineQuantizationConfig(
|
||||
QuantizationConfigArgs(linear="mxfp8")
|
||||
quant_config_args(linear="mxfp8")
|
||||
)
|
||||
config = checkpoint_config
|
||||
|
||||
@@ -408,7 +409,7 @@ def test_online_ignore_keeps_checkpoint_quantization_linear(
|
||||
quant_config = _fully_quantized_quark_config()
|
||||
prefix = "model.layers.0.self_attn.o_proj"
|
||||
quant_config.online_quantization_config = OnlineQuantizationConfig(
|
||||
QuantizationConfigArgs(linear="mxfp8", ignore=[prefix])
|
||||
quant_config_args(linear="mxfp8", ignore=[prefix])
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
quant_config.online_quantization_config,
|
||||
@@ -437,7 +438,7 @@ def test_online_quantization_rejects_prequantized_moe(
|
||||
prefix = "model.layers.0.mlp.experts"
|
||||
quant_config = _fully_quantized_quark_config()
|
||||
quant_config.online_quantization_config = OnlineQuantizationConfig(
|
||||
QuantizationConfigArgs(linear="mxfp4", moe="mxfp4")
|
||||
quant_config_args(linear="mxfp4", moe="mxfp4")
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match="pre-quantized layer"):
|
||||
@@ -460,7 +461,7 @@ def test_activation_only_override_applies_to_checkpoint_method(
|
||||
model_config = ModelConfig(
|
||||
model=str(tmp_path),
|
||||
quantization="compressed-tensors",
|
||||
quantization_config=QuantizationConfigArgs(moe={"activation": "mxfp8"}),
|
||||
quantization_config=quant_config_args(moe={"activation": "mxfp8"}),
|
||||
hf_overrides={
|
||||
"quantization_config": {
|
||||
"quant_method": "compressed-tensors",
|
||||
@@ -514,7 +515,7 @@ def test_online_overlay_loads_checkpoint_config_file(tmp_path) -> None:
|
||||
model_config = ModelConfig(
|
||||
model=str(tmp_path),
|
||||
quantization="awq",
|
||||
quantization_config=QuantizationConfigArgs(linear="mxfp8"),
|
||||
quantization_config=quant_config_args(linear="mxfp8"),
|
||||
)
|
||||
|
||||
result = weight_utils.get_quant_config(model_config, LoadConfig())
|
||||
@@ -574,7 +575,7 @@ def test_online_shorthand_selects_checkpoint_or_online_config(
|
||||
|
||||
def test_log_online_quantization_for_composable_config(monkeypatch) -> None:
|
||||
"""Composable configs log their nested online quantization results."""
|
||||
online_config = OnlineQuantizationConfig(QuantizationConfigArgs(linear="mxfp8"))
|
||||
online_config = OnlineQuantizationConfig(quant_config_args(linear="mxfp8"))
|
||||
online_config.quantized_layers = {
|
||||
"model.layers.0.self_attn.o_proj": ("linear", "mxfp8", None),
|
||||
"model.layers.1.self_attn.o_proj": ("linear", "mxfp8", None),
|
||||
@@ -1164,7 +1165,7 @@ def test_online_quantization_records_global_config(
|
||||
default_vllm_config, dist_init
|
||||
) -> None:
|
||||
default_vllm_config.model_config = ModelConfig()
|
||||
config = OnlineQuantizationConfig(QuantizationConfigArgs(linear="fp8_per_block"))
|
||||
config = OnlineQuantizationConfig(quant_config_args(linear="fp8_per_block"))
|
||||
prefix = "model.layers.0.self_attn.o_proj"
|
||||
layer = ColumnParallelLinear(
|
||||
input_size=1,
|
||||
@@ -1218,7 +1219,7 @@ def test_online_quantization_targets_reject_unsupported_layer() -> None:
|
||||
|
||||
|
||||
def test_log_online_quantization(default_vllm_config, monkeypatch) -> None:
|
||||
config = OnlineQuantizationConfig(QuantizationConfigArgs(linear="fp8_per_tensor"))
|
||||
config = OnlineQuantizationConfig(quant_config_args(linear="fp8_per_tensor"))
|
||||
config.quantized_layers = {
|
||||
"model.layers.0.mlp.down_proj": ("linear", "fp8_per_tensor", None),
|
||||
"model.layers.1.mlp.down_proj": ("linear", "fp8_per_tensor", None),
|
||||
@@ -1431,7 +1432,7 @@ def test_online_int8_moe_w2_scale_matches_unsharded(monkeypatch) -> None:
|
||||
layer.w2_weight = torch.nn.Parameter(w2_in, requires_grad=False)
|
||||
layer.num_experts = layer.local_num_experts = w13.shape[0]
|
||||
method = SimpleNamespace(moe=SimpleNamespace(tp_size=moe_tp_size))
|
||||
Int8OnlineMoEMethod._quantize_weights(method, layer)
|
||||
Int8OnlineMoEMethod._quantize_weights(method, layer) # type: ignore[arg-type]
|
||||
return layer.w2_weight, layer.w2_scale
|
||||
|
||||
full_weight, full_scale = quantize(w2, 1)
|
||||
|
||||
Reference in New Issue
Block a user