Add pydocstyle to the ruff rules (#52136)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Signed-off-by: Harry Mellor <hej.mellor@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
804e5377aa
commit
8c1557a79c
@@ -808,7 +808,6 @@ def test_models_fse_init(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
) -> None:
|
||||
"""Model construction resolves FSE consistently with Quark quantization."""
|
||||
|
||||
quantization_config: dict[str, Any] = (
|
||||
get_deepseek_v4_quark_config(["layers.0.ffn.shared_experts"] if exclude else [])
|
||||
if model_type == "deepseek_v4"
|
||||
@@ -1320,7 +1319,8 @@ def test_fp8_shared_expert_fse_allows_symmetric_ignored_layers() -> None:
|
||||
|
||||
def test_fp8_shared_expert_fse_expands_packed_projections() -> None:
|
||||
"""Both shards of a fused projection ignored is symmetric within that
|
||||
projection, so the mismatch reported is against the routed experts."""
|
||||
projection, so the mismatch reported is against the routed experts.
|
||||
"""
|
||||
quant_config = _fp8_config(
|
||||
ignored_layers=[
|
||||
"model.layers.0.mlp.shared_experts.gate_proj",
|
||||
@@ -1344,7 +1344,8 @@ def test_fp8_shared_expert_fse_expands_packed_projections() -> None:
|
||||
|
||||
def test_fp8_shared_expert_fse_propagates_partial_shard_exclusion() -> None:
|
||||
"""Half a fused projection excluded is rejected by `is_layer_skipped`
|
||||
itself, exactly as it is in `Fp8Config.get_quant_method`."""
|
||||
itself, exactly as it is in `Fp8Config.get_quant_method`.
|
||||
"""
|
||||
quant_config = _fp8_config(
|
||||
ignored_layers=["model.layers.0.mlp.shared_experts.gate_proj"]
|
||||
)
|
||||
|
||||
@@ -346,7 +346,8 @@ def test_deepseek_v32_dispatches_selected_mha(
|
||||
def test_select_candidate_blocks_tolerates_empty_rows():
|
||||
"""Full-cudagraph decode pads the batch with seq_len-0 rows. The newest
|
||||
block pin must not index -1 for them (device-side assert); they select
|
||||
no candidate blocks and real rows still pin their newest block."""
|
||||
no candidate blocks and real rows still pin their newest block.
|
||||
"""
|
||||
block_size, topk_blocks = 8, 3
|
||||
logits = torch.zeros(3, 64, device="cuda")
|
||||
logits[0, 3] = 5.0 # block 0 scores highest for row 0
|
||||
@@ -457,7 +458,8 @@ def test_candidate_kernels_preserve_packed_bounds_and_padding(
|
||||
|
||||
def _make_candidates(lens: torch.Tensor, num_candidates: int, cbk: int):
|
||||
"""Production-faithful candidates: top min(avail, K) blocks per row —
|
||||
full coverage for lens <= K*cbk, a fixed-size subset beyond that."""
|
||||
full coverage for lens <= K*cbk, a fixed-size subset beyond that.
|
||||
"""
|
||||
avail = ((lens.cpu() + cbk - 1) // cbk).tolist()
|
||||
rows = []
|
||||
for a in avail:
|
||||
@@ -493,7 +495,8 @@ def _candidate_token_mask(
|
||||
|
||||
def _reference_topk(masked: torch.Tensor, topk: int) -> torch.Tensor:
|
||||
"""Plain ``torch.topk`` over -inf-masked logits; slots past a row's valid
|
||||
count are -1 (the indexer's "no token" sentinel)."""
|
||||
count are -1 (the indexer's "no token" sentinel).
|
||||
"""
|
||||
values, indices = masked.topk(topk, dim=1)
|
||||
return torch.where(values > float("-inf"), indices.int(), -1)
|
||||
|
||||
@@ -506,7 +509,8 @@ def _assert_same_selection(
|
||||
) -> None:
|
||||
"""Both top-k index sets must pick the same multiset of logit values per
|
||||
row (-1 padding must match too). Indices themselves may differ: the
|
||||
top-k kernels break ties among equal values in nondeterministic order."""
|
||||
top-k kernels break ties among equal values in nondeterministic order.
|
||||
"""
|
||||
for r in range(logits.shape[0]):
|
||||
base = int(row_starts[r]) if row_starts is not None else 0
|
||||
g, e = got[r][got[r] >= 0], expected[r][expected[r] >= 0]
|
||||
@@ -518,7 +522,8 @@ def _assert_same_selection(
|
||||
|
||||
def _sparse_scratch(rows: int, num_sparse: int, topk: int) -> dict:
|
||||
"""Caller-owned buffers the sparse path writes into (the metadata builder
|
||||
owns these in production)."""
|
||||
owns these in production).
|
||||
"""
|
||||
i32 = dict(dtype=torch.int32, device="cuda")
|
||||
return dict(
|
||||
sparse_indices=torch.zeros(rows, num_sparse, **i32),
|
||||
@@ -533,7 +538,8 @@ def _expand_candidates_reference(
|
||||
"""PyTorch reference for `candidate_blocks_to_sparse_indices`: expand
|
||||
each candidate block into ``cbk // sbk`` sparse blocks, keep those inside
|
||||
``[0, ke - ks)``, sort ascending, anchor at ``ks // sbk``, pad by
|
||||
repeating the last valid block, and count the valid sparse columns."""
|
||||
repeating the last valid block, and count the valid sparse columns.
|
||||
"""
|
||||
ratio = cbk // sbk
|
||||
rows, num_candidates = candidates.shape
|
||||
num_sparse = num_candidates * ratio
|
||||
@@ -559,7 +565,8 @@ def _expand_candidates_reference(
|
||||
@pytest.mark.skipif(not torch.cuda.is_available(), reason="Triton kernel")
|
||||
def test_candidate_blocks_to_sparse_indices_math():
|
||||
"""Candidate->sparse-block expansion: ks anchoring, range filtering,
|
||||
repeat-last padding, and the per-row valid column count (``end``)."""
|
||||
repeat-last padding, and the per-row valid column count (``end``).
|
||||
"""
|
||||
from vllm.model_executor.kernels.attention.dsa.sparse_mqa_logits import (
|
||||
candidate_blocks_to_sparse_indices,
|
||||
)
|
||||
@@ -611,7 +618,8 @@ def test_candidate_blocks_to_sparse_indices_math():
|
||||
def test_candidate_blocks_to_sparse_indices_matches_reference(cbk: int, sbk: int):
|
||||
"""The Triton expansion equals the PyTorch reference on production-shaped
|
||||
random inputs, including strided (column-sliced) candidate rows and
|
||||
strided output buffers."""
|
||||
strided output buffers.
|
||||
"""
|
||||
from vllm.model_executor.kernels.attention.dsa.sparse_mqa_logits import (
|
||||
candidate_blocks_to_sparse_indices,
|
||||
)
|
||||
@@ -681,7 +689,8 @@ def test_sparse_mqa_logits_prefill_matches_dense_masked(capture: bool):
|
||||
``torch.topk`` over dense bf16 logits masked to the candidates (the two
|
||||
DeepGEMM kernels agree bitwise on candidate columns), incl. under CUDA
|
||||
graph capture, and a later layer reusing the step's expansion/schedule
|
||||
selects the same values."""
|
||||
selects the same values.
|
||||
"""
|
||||
deep_gemm = _skip_unless_sm100_sparse_kernels()
|
||||
from vllm.model_executor.kernels.attention.dsa.sparse_mqa_logits import (
|
||||
sparse_mqa_logits_prefill_chunk,
|
||||
@@ -771,7 +780,8 @@ def test_sparse_mqa_logits_prefill_matches_dense_masked(capture: bool):
|
||||
|
||||
def _build_fp4_paged_cache(req_lens: torch.Tensor, page_kv: int, head_dim: int):
|
||||
"""MXFP4 paged cache in DeepGEMM's fused layout: per page, all tokens'
|
||||
fp4 data first, then their packed UE8M0 scales."""
|
||||
fp4 data first, then their packed UE8M0 scales.
|
||||
"""
|
||||
device = req_lens.device
|
||||
pages_per = (req_lens + page_kv - 1) // page_kv
|
||||
num_pages, max_pages = int(pages_per.sum()), int(pages_per.max())
|
||||
@@ -807,7 +817,8 @@ def test_sparse_mqa_logits_paged_matches_dense_masked(next_n: int, capture: bool
|
||||
"""Paged sparse-MQA decode selects exactly the values ``torch.topk`` picks
|
||||
from the dense bf16 masked logits, incl. MTP rows (next_n > 1 flattened to
|
||||
one query row each), CUDA graph capture/replay and schedule reuse by a
|
||||
later layer."""
|
||||
later layer.
|
||||
"""
|
||||
deep_gemm = _skip_unless_sm100_sparse_kernels()
|
||||
from vllm.model_executor.kernels.attention.dsa.sparse_mqa_logits import (
|
||||
sparse_mqa_logits_paged_decode,
|
||||
@@ -916,7 +927,8 @@ def test_sparse_mqa_logits_paged_matches_dense_masked(next_n: int, capture: bool
|
||||
|
||||
def test_sparse_mqa_logits_accuracy_vs_torch():
|
||||
"""Sparse-kernel numerics vs a PyTorch fp32 reference on the dequantized
|
||||
MXFP4 inputs."""
|
||||
MXFP4 inputs.
|
||||
"""
|
||||
_skip_unless_sm100_sparse_kernels()
|
||||
from deep_gemm.utils import cast_back_from_fp4
|
||||
|
||||
|
||||
@@ -232,7 +232,8 @@ class TestShouldSkipWeight:
|
||||
|
||||
class TestSafetensorsWeightsIteratorWithEpFilter:
|
||||
"""Verify that EP filtering produces a strict subset of unfiltered loading
|
||||
and that all expected dense + local expert weights are present."""
|
||||
and that all expected dense + local expert weights are present.
|
||||
"""
|
||||
|
||||
@pytest.fixture(scope="class")
|
||||
def gpt2_files(self):
|
||||
@@ -262,7 +263,8 @@ class TestSafetensorsWeightsIteratorWithEpFilter:
|
||||
|
||||
def test_empty_filter_skips_experts_only(self, gpt2_files):
|
||||
"""GPT-2 has no expert weights, so even an empty local_expert_ids
|
||||
set should return all weights (all are dense)."""
|
||||
set should return all weights (all are dense).
|
||||
"""
|
||||
all_weights = dict(safetensors_weights_iterator(gpt2_files, False))
|
||||
filtered_weights = dict(
|
||||
safetensors_weights_iterator(gpt2_files, False, local_expert_ids=set())
|
||||
@@ -273,7 +275,8 @@ class TestSafetensorsWeightsIteratorWithEpFilter:
|
||||
|
||||
class TestEpFilterOnSyntheticMoeWeights:
|
||||
"""Create synthetic safetensors files with expert-like naming and verify
|
||||
that the filter correctly skips non-local experts."""
|
||||
that the filter correctly skips non-local experts.
|
||||
"""
|
||||
|
||||
@pytest.fixture
|
||||
def synthetic_moe_files(self, tmp_path):
|
||||
|
||||
@@ -350,7 +350,8 @@ def test_marlin_post_load_preserves_runtime_tensor_addresses(monkeypatch, dist_i
|
||||
@pytest.mark.parametrize("variant", ["fp8", "mxfp8", "nvfp4"])
|
||||
def test_marlin_prepare_layer_preserves_workspace_address(monkeypatch, variant):
|
||||
"""The Marlin fallback prepare_* functions rerun on weight reload and must
|
||||
reuse the workspace storage whose address captured CUDA graphs hold."""
|
||||
reuse the workspace storage whose address captured CUDA graphs hold.
|
||||
"""
|
||||
from vllm import _custom_ops as ops
|
||||
from vllm.model_executor.layers.quantization.utils import (
|
||||
marlin_utils,
|
||||
@@ -428,7 +429,8 @@ def test_marlin_prepare_layer_preserves_workspace_address(monkeypatch, variant):
|
||||
|
||||
def test_marlin_make_workspace_new_rejects_incompatible_existing(monkeypatch):
|
||||
"""An incompatible existing workspace means the address captured by CUDA
|
||||
graphs is already unusable; allocating a replacement would hide that."""
|
||||
graphs is already unusable; allocating a replacement would hide that.
|
||||
"""
|
||||
from vllm.model_executor.layers.quantization.utils import marlin_utils
|
||||
|
||||
monkeypatch.setattr(marlin_utils, "num_compute_units", lambda _: 4)
|
||||
@@ -609,7 +611,8 @@ class _RecordingQuantMethod(QuantizeMethodBase):
|
||||
class _LateBiasLayer(torch.nn.Module):
|
||||
"""Mimics an online-quantized linear: `weight` is created on meta by
|
||||
`create_weights()`, which wraps the loaders, and the linear base registers
|
||||
`bias` afterwards."""
|
||||
`bias` afterwards.
|
||||
"""
|
||||
|
||||
def __init__(self, quant_method):
|
||||
super().__init__()
|
||||
|
||||
@@ -42,7 +42,8 @@ def _run_warmup(monkeypatch, layers) -> list[dict]:
|
||||
@pytest.mark.parametrize("scale_name", ["weight_scale", "weight_scale_inv"])
|
||||
def test_registered_deep_gemm_layer_is_warmed_up(monkeypatch, scale_name) -> None:
|
||||
"""Any layer stamped by the DeepGEMM kernel is warmed, regardless of the
|
||||
quantization method that owns it or the name of its scale parameter."""
|
||||
quantization method that owns it or the name of its scale parameter.
|
||||
"""
|
||||
layer = _block_fp8_layer(256, 128, scale_name)
|
||||
|
||||
calls = _run_warmup(monkeypatch, [layer])
|
||||
@@ -54,7 +55,8 @@ def test_registered_deep_gemm_layer_is_warmed_up(monkeypatch, scale_name) -> Non
|
||||
|
||||
def test_n_multiple_of_64_matches_kernel_selection(monkeypatch) -> None:
|
||||
"""DeepGEMM accepts N % 64 == 0 (e.g. DeepSeek kv_a_proj_with_mqa, N=576),
|
||||
so warmup must not require N % 128 == 0."""
|
||||
so warmup must not require N % 128 == 0.
|
||||
"""
|
||||
assert len(_run_warmup(monkeypatch, [_block_fp8_layer(576, 256)])) == 1
|
||||
|
||||
|
||||
@@ -71,7 +73,7 @@ def test_unstamped_and_mismatched_block_layers_are_skipped(monkeypatch) -> None:
|
||||
|
||||
@pytest.mark.parametrize("is_bmm", [False, True])
|
||||
def test_kernel_registers_itself_as_warmup_provider(is_bmm) -> None:
|
||||
"""bmm layers bypass the kernel at runtime, so they must not be warmed."""
|
||||
"""Bmm layers bypass the kernel at runtime, so they must not be warmed."""
|
||||
kernel = object.__new__(DeepGemmFp8BlockScaledMMKernel)
|
||||
kernel.is_deep_gemm_supported = False
|
||||
layer = torch.nn.Module()
|
||||
|
||||
@@ -23,9 +23,7 @@ REVISION_ROBERTA = os.environ.get("REVISION", "main")
|
||||
current_platform.is_rocm(), reason="Xformers backend is not supported on ROCm."
|
||||
)
|
||||
def test_model_loading_with_params(vllm_runner, monkeypatch):
|
||||
"""
|
||||
Test parameter weight loading with tp>1.
|
||||
"""
|
||||
"""Test parameter weight loading with tp>1."""
|
||||
# to use apply_model
|
||||
monkeypatch.setenv("VLLM_ALLOW_INSECURE_SERIALIZATION", "1")
|
||||
with vllm_runner(
|
||||
@@ -68,9 +66,7 @@ def test_model_loading_with_params(vllm_runner, monkeypatch):
|
||||
current_platform.is_rocm(), reason="Xformers backend is not supported on ROCm."
|
||||
)
|
||||
def test_roberta_model_loading_with_params(vllm_runner, monkeypatch):
|
||||
"""
|
||||
Test parameter weight loading with tp>1.
|
||||
"""
|
||||
"""Test parameter weight loading with tp>1."""
|
||||
# to use apply_model
|
||||
monkeypatch.setenv("VLLM_ALLOW_INSECURE_SERIALIZATION", "1")
|
||||
with vllm_runner(
|
||||
@@ -113,9 +109,7 @@ def test_roberta_model_loading_with_params(vllm_runner, monkeypatch):
|
||||
current_platform.is_rocm(), reason="Xformers backend is not supported on ROCm."
|
||||
)
|
||||
def test_facebook_roberta_model_loading_with_params(vllm_runner, monkeypatch):
|
||||
"""
|
||||
Test loading roberta-base model with no lm_head.
|
||||
"""
|
||||
"""Test loading roberta-base model with no lm_head."""
|
||||
# to use apply_model
|
||||
monkeypatch.setenv("VLLM_ALLOW_INSECURE_SERIALIZATION", "1")
|
||||
model_name = "FacebookAI/roberta-base"
|
||||
|
||||
@@ -62,7 +62,6 @@ def test_oink_availability_checks(
|
||||
expected_fused: bool,
|
||||
):
|
||||
"""Test OINK support detection with clean import state for each parameter set."""
|
||||
|
||||
# Use spawn to run function in fresh process with clean imports
|
||||
# TODO migrate to spawn utility:
|
||||
# https://github.com/vllm-project/vllm/issues/41415
|
||||
|
||||
@@ -16,8 +16,7 @@ from vllm.multimodal.processing import InputProcessingContext
|
||||
|
||||
# Helper function to print input IDs with coalesced audio/video tokens.
|
||||
def print_input_ids(input_ids):
|
||||
"""
|
||||
Print input IDs, compressing consecutive special tokens.
|
||||
"""Print input IDs, compressing consecutive special tokens.
|
||||
- 151675: <|audio_pad|>
|
||||
- 151656: <|video_pad|>
|
||||
"""
|
||||
@@ -137,7 +136,6 @@ def test_qwen3_omni_get_updates_use_audio_in_video(
|
||||
mock_image_processor,
|
||||
):
|
||||
"""Test the get_updates_use_audio_in_video method directly."""
|
||||
|
||||
from vllm.model_executor.models.qwen3_omni_moe_thinker import (
|
||||
Qwen3OmniMoeThinkerMultiModalProcessor,
|
||||
Qwen3OmniMoeThinkerProcessingInfo,
|
||||
|
||||
@@ -51,8 +51,7 @@ class DummyConfig:
|
||||
def make_video_embedding(
|
||||
t, h, w, interleave_text_tokens: tuple[int, int], video_pruning_rate: float = 0.0
|
||||
):
|
||||
"""
|
||||
Helper function to make a video embedding for a given video size and pruning rate.
|
||||
"""Make a video embedding for a given video size and pruning rate.
|
||||
|
||||
Args:
|
||||
t: Number of frames.
|
||||
@@ -64,6 +63,7 @@ def make_video_embedding(
|
||||
|
||||
Returns:
|
||||
Tuple of (unpruned_tokens_sequence, pruned_tokens_sequence, retention_mask)
|
||||
|
||||
"""
|
||||
unpruned_tokens_sequence = []
|
||||
population = list(range(1, 100))
|
||||
|
||||
@@ -278,7 +278,7 @@ def test_routed_experts_capturer_single_dp_no_metadata():
|
||||
|
||||
|
||||
def test_routed_experts_capturer_dp_naive_concatenated_all_ranks():
|
||||
"""n == sum(num_tokens_dp): slice this rank's segment from concatenated topk."""
|
||||
"""N == sum(num_tokens_dp): slice this rank's segment from concatenated topk."""
|
||||
capturer = _capturer_with_buffer(dp_rank=1)
|
||||
num_tokens_dp = torch.tensor([2, 3], dtype=torch.int32)
|
||||
ctx = SimpleNamespace(
|
||||
@@ -295,7 +295,7 @@ def test_routed_experts_capturer_dp_naive_concatenated_all_ranks():
|
||||
|
||||
|
||||
def test_routed_experts_capturer_dp_modular_local_tokens():
|
||||
"""n == token_num_per_dp: topk is already local to this DP rank."""
|
||||
"""N == token_num_per_dp: topk is already local to this DP rank."""
|
||||
capturer = _capturer_with_buffer(dp_rank=1)
|
||||
num_tokens_dp = torch.tensor([2, 3], dtype=torch.int32)
|
||||
ctx = SimpleNamespace(
|
||||
@@ -326,7 +326,8 @@ def test_routed_experts_capturer_dp_unexpected_batch_raises():
|
||||
|
||||
def test_routed_experts_attention_group_is_shared_and_fail_closed():
|
||||
"""Both sides key routing data by this gid, so it must skip non-full-attention
|
||||
groups rather than defaulting to 0, and fail closed when none exists."""
|
||||
groups rather than defaulting to 0, and fail closed when none exists.
|
||||
"""
|
||||
common = dict(num_kv_heads=1, head_size=1, dtype=torch.float32)
|
||||
config = SimpleNamespace(
|
||||
kv_cache_groups=[
|
||||
|
||||
@@ -57,7 +57,8 @@ class TestMaybeRemapKvScaleName:
|
||||
|
||||
def test_qkv_proj_k_scale(self):
|
||||
"""Qwen3-MoE / llm-compressor format: qkv_proj.k_scale -> attn.k_scale
|
||||
Regression test for https://github.com/vllm-project/vllm/issues/25047"""
|
||||
Regression test for https://github.com/vllm-project/vllm/issues/25047
|
||||
"""
|
||||
result = maybe_remap_kv_scale_name(
|
||||
"model.layers.0.self_attn.qkv_proj.k_scale", self.PARAMS_DICT
|
||||
)
|
||||
@@ -65,35 +66,36 @@ class TestMaybeRemapKvScaleName:
|
||||
|
||||
def test_qkv_proj_v_scale(self):
|
||||
"""Qwen3-MoE / llm-compressor format: qkv_proj.v_scale -> attn.v_scale
|
||||
Regression test for https://github.com/vllm-project/vllm/issues/25047"""
|
||||
Regression test for https://github.com/vllm-project/vllm/issues/25047
|
||||
"""
|
||||
result = maybe_remap_kv_scale_name(
|
||||
"model.layers.0.self_attn.qkv_proj.v_scale", self.PARAMS_DICT
|
||||
)
|
||||
assert result == "model.layers.0.self_attn.attn.v_scale"
|
||||
|
||||
def test_modelopt_k_proj_k_scale(self):
|
||||
"""ModelOpt format: k_proj.k_scale -> attn.k_scale"""
|
||||
"""ModelOpt format: k_proj.k_scale -> attn.k_scale."""
|
||||
result = maybe_remap_kv_scale_name(
|
||||
"model.layers.0.self_attn.k_proj.k_scale", self.PARAMS_DICT
|
||||
)
|
||||
assert result == "model.layers.0.self_attn.attn.k_scale"
|
||||
|
||||
def test_modelopt_v_proj_v_scale(self):
|
||||
"""ModelOpt format: v_proj.v_scale -> attn.v_scale"""
|
||||
"""ModelOpt format: v_proj.v_scale -> attn.v_scale."""
|
||||
result = maybe_remap_kv_scale_name(
|
||||
"model.layers.0.self_attn.v_proj.v_scale", self.PARAMS_DICT
|
||||
)
|
||||
assert result == "model.layers.0.self_attn.attn.v_scale"
|
||||
|
||||
def test_deprecated_kv_scale(self):
|
||||
"""Old format: kv_scale -> attn.k_scale (deprecated)"""
|
||||
"""Old format: kv_scale -> attn.k_scale (deprecated)."""
|
||||
result = maybe_remap_kv_scale_name(
|
||||
"model.layers.0.self_attn.kv_scale", self.PARAMS_DICT
|
||||
)
|
||||
assert result == "model.layers.0.self_attn.attn.k_scale"
|
||||
|
||||
def test_default_bare_k_scale(self):
|
||||
"""Default format: .k_scale -> .attn.k_scale"""
|
||||
"""Default format: .k_scale -> .attn.k_scale."""
|
||||
result = maybe_remap_kv_scale_name(
|
||||
"model.layers.0.self_attn.k_scale", self.PARAMS_DICT
|
||||
)
|
||||
@@ -108,7 +110,8 @@ class TestMaybeRemapKvScaleName:
|
||||
def test_nvfp4_modelopt_k_proj_k_scale(self):
|
||||
"""ModelOpt NVFP4 format (e.g. nvidia/Qwen3-30B-A3B-NVFP4):
|
||||
k_proj.k_scale -> attn.k_scale.
|
||||
Validates that NVFP4 checkpoints are not broken by this change."""
|
||||
Validates that NVFP4 checkpoints are not broken by this change.
|
||||
"""
|
||||
result = maybe_remap_kv_scale_name(
|
||||
"model.layers.0.self_attn.k_proj.k_scale", self.PARAMS_DICT
|
||||
)
|
||||
@@ -117,7 +120,8 @@ class TestMaybeRemapKvScaleName:
|
||||
def test_nvfp4_modelopt_v_proj_v_scale(self):
|
||||
"""ModelOpt NVFP4 format (e.g. nvidia/Qwen3-30B-A3B-NVFP4):
|
||||
v_proj.v_scale -> attn.v_scale.
|
||||
Validates that NVFP4 checkpoints are not broken by this change."""
|
||||
Validates that NVFP4 checkpoints are not broken by this change.
|
||||
"""
|
||||
result = maybe_remap_kv_scale_name(
|
||||
"model.layers.0.self_attn.v_proj.v_scale", self.PARAMS_DICT
|
||||
)
|
||||
@@ -125,7 +129,8 @@ class TestMaybeRemapKvScaleName:
|
||||
|
||||
def test_qwen3_vl_moe_qkv_proj_k_scale(self):
|
||||
"""Qwen3-VL-MoE uses the same fused qkv_proj naming as Qwen3-MoE.
|
||||
Regression test for qwen3_vl_moe.py fix (same bug as #25047)."""
|
||||
Regression test for qwen3_vl_moe.py fix (same bug as #25047).
|
||||
"""
|
||||
result = maybe_remap_kv_scale_name(
|
||||
"model.layers.0.self_attn.qkv_proj.k_scale", self.PARAMS_DICT
|
||||
)
|
||||
@@ -133,7 +138,8 @@ class TestMaybeRemapKvScaleName:
|
||||
|
||||
def test_qwen3_vl_moe_qkv_proj_v_scale(self):
|
||||
"""Qwen3-VL-MoE uses the same fused qkv_proj naming as Qwen3-MoE.
|
||||
Regression test for qwen3_vl_moe.py fix (same bug as #25047)."""
|
||||
Regression test for qwen3_vl_moe.py fix (same bug as #25047).
|
||||
"""
|
||||
result = maybe_remap_kv_scale_name(
|
||||
"model.layers.0.self_attn.qkv_proj.v_scale", self.PARAMS_DICT
|
||||
)
|
||||
@@ -175,7 +181,8 @@ class TestKvCacheScaleMapper:
|
||||
"""The `WeightsMapper` returned by `get_cache_scale_mapper` replaces the
|
||||
per-model `maybe_remap_kv_scale_name` calls. It must remap the same set of
|
||||
checkpoint formats (the non-`params_dict`-dependent ones) and be idempotent
|
||||
so it composes safely with a model's own qkv/gate_up `hf_to_vllm_mapper`."""
|
||||
so it composes safely with a model's own qkv/gate_up `hf_to_vllm_mapper`.
|
||||
"""
|
||||
|
||||
def _mapper(self):
|
||||
# `get_cache_scale_mapper` does not use `self`; call it on the base
|
||||
@@ -265,7 +272,8 @@ class TestKvCacheScaleMapper:
|
||||
def test_composes_with_qkv_mapper(self):
|
||||
"""Applied together with a model's qkv/gate_up mapper, the regex scale
|
||||
rules run before the substr rename, so scales are normalized to `.attn.`
|
||||
and regular projections are still fused correctly."""
|
||||
and regular projections are still fused correctly.
|
||||
"""
|
||||
from vllm.model_executor.models.utils import WeightsMapper
|
||||
|
||||
model_mapper = WeightsMapper(
|
||||
|
||||
Reference in New Issue
Block a user