[Mini-VLLM] Cut dead subsystems across serving, connectors, parsers
- Remove P/D transfer connectors: nixl, nixl_chat, mooncake x2, hf3fs, moriio, hisparse, example and hidden-states connectors - Reduce weight_transfer to the base API used by model loading - Remove kv_offload tiering, simple_kv_offload, ec cpu/example, snapshot command, engine snapshot server - Remove transformers model fallback, dsv4 tokenizers, dead platforms cpu/tpu/xpu, flashmla third_party, dsa, megamoe/flydsl, dead attn ops, dead layers (short_conv, fused_embed_norm, indexer_topk, relu2 gemma_ar, lightning_attn, minimax_rms_norm), gemm_rs_ar - Keep MoE LoRA op (imported eagerly by punica_gpu); drop fp8 variant - Rebuild parser hubs around Qwen3 adapters only (36 dead adapters) - Remove dead tests with the code they covered Co-authored-by: Hinata <hinata@idihore.id> Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
@@ -1,65 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
import pytest
|
||||
import transformers.image_utils
|
||||
from PIL import Image
|
||||
|
||||
from vllm.transformers_utils.processors.pixtral import MistralCommonImageProcessor
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def image_processor() -> MistralCommonImageProcessor:
|
||||
return MistralCommonImageProcessor(mm_encoder=None)
|
||||
|
||||
|
||||
def test_fetch_images_passes_through_decoded_image(
|
||||
image_processor: MistralCommonImageProcessor,
|
||||
):
|
||||
image = Image.new("RGB", (4, 4))
|
||||
result = image_processor.fetch_images(image)
|
||||
assert result is image
|
||||
|
||||
|
||||
def test_fetch_images_recurses_over_list(
|
||||
image_processor: MistralCommonImageProcessor,
|
||||
):
|
||||
a = Image.new("RGB", (4, 4))
|
||||
b = Image.new("RGB", (8, 8))
|
||||
result = image_processor.fetch_images([a, b])
|
||||
assert isinstance(result, list)
|
||||
assert len(result) == 2
|
||||
assert result[0] is a
|
||||
assert result[1] is b
|
||||
|
||||
|
||||
def test_fetch_images_recurses_over_nested_list(
|
||||
image_processor: MistralCommonImageProcessor,
|
||||
):
|
||||
a = Image.new("RGB", (4, 4))
|
||||
b = Image.new("RGB", (8, 8))
|
||||
result = image_processor.fetch_images([[a], [b]])
|
||||
assert result == [[a], [b]]
|
||||
|
||||
|
||||
def test_fetch_images_str_delegates_to_load_image(
|
||||
monkeypatch, image_processor: MistralCommonImageProcessor
|
||||
):
|
||||
sentinel = Image.new("RGB", (2, 2))
|
||||
received: dict[str, object] = {}
|
||||
|
||||
def fake_load_image(path):
|
||||
received["path"] = path
|
||||
return sentinel
|
||||
|
||||
monkeypatch.setattr(transformers.image_utils, "load_image", fake_load_image)
|
||||
|
||||
result = image_processor.fetch_images("/tmp/fake.png")
|
||||
assert result is sentinel
|
||||
assert received["path"] == "/tmp/fake.png"
|
||||
|
||||
|
||||
def test_fetch_images_rejects_unsupported_type(
|
||||
image_processor: MistralCommonImageProcessor,
|
||||
):
|
||||
with pytest.raises(TypeError, match="only a single or a list"):
|
||||
image_processor.fetch_images(42)
|
||||
@@ -1,127 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
"""Unit tests for ``MistralCommonFeatureExtractor.fetch_audio``.
|
||||
|
||||
``transformers>=5.10`` adds a ``ProcessorMixin.prepare_inputs_layout`` helper
|
||||
that calls ``self.feature_extractor.fetch_audio(...)`` unconditionally. The
|
||||
duck-typed :class:`MistralCommonFeatureExtractor` previously did not implement
|
||||
that method, so loading any voxtral model under transformers 5.10.x raised
|
||||
``AttributeError: 'MistralCommonFeatureExtractor' object has no attribute
|
||||
'fetch_audio'``. These tests pin the new ``fetch_audio`` method to the same
|
||||
contract as ``transformers.SequenceFeatureExtractor.fetch_audio``.
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
import torch
|
||||
|
||||
from vllm.tokenizers.mistral import MistralTokenizer
|
||||
from vllm.transformers_utils.processors.voxtral import (
|
||||
MistralCommonFeatureExtractor,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def feature_extractor() -> MistralCommonFeatureExtractor:
|
||||
tokenizer = MistralTokenizer.from_pretrained("mistralai/Voxtral-Mini-3B-2507")
|
||||
return MistralCommonFeatureExtractor(tokenizer.instruct.audio_encoder)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"audio",
|
||||
[
|
||||
np.zeros(1024, dtype=np.float32),
|
||||
torch.zeros(1024),
|
||||
[0.0, 1.0, 2.0],
|
||||
],
|
||||
ids=["numpy_array", "torch_tensor", "list_of_floats"],
|
||||
)
|
||||
def test_fetch_audio_passes_through(
|
||||
feature_extractor: MistralCommonFeatureExtractor, audio
|
||||
):
|
||||
result = feature_extractor.fetch_audio(audio)
|
||||
assert result is audio
|
||||
|
||||
|
||||
def test_fetch_audio_recurses_over_list_of_arrays(
|
||||
feature_extractor: MistralCommonFeatureExtractor,
|
||||
):
|
||||
a = np.zeros(8, dtype=np.float32)
|
||||
b = np.ones(8, dtype=np.float32)
|
||||
result = feature_extractor.fetch_audio([a, b])
|
||||
assert isinstance(result, list)
|
||||
assert len(result) == 2
|
||||
assert result[0] is a
|
||||
assert result[1] is b
|
||||
|
||||
|
||||
def test_fetch_audio_uses_self_sampling_rate_when_none(
|
||||
monkeypatch, feature_extractor: MistralCommonFeatureExtractor
|
||||
):
|
||||
"""If ``sampling_rate`` is None, ``self.sampling_rate`` must be used.
|
||||
|
||||
Verified indirectly via the recursion path: when we pass a list of arrays
|
||||
without sampling_rate, recursive calls receive the resolved rate.
|
||||
"""
|
||||
captured: list[int | None] = []
|
||||
original = feature_extractor.fetch_audio
|
||||
|
||||
def spy(audio, sampling_rate=None):
|
||||
captured.append(sampling_rate)
|
||||
return original(audio, sampling_rate=sampling_rate)
|
||||
|
||||
monkeypatch.setattr(feature_extractor, "fetch_audio", spy)
|
||||
feature_extractor.fetch_audio([np.zeros(4, dtype=np.float32)])
|
||||
# Top-level call has sampling_rate=None; inner recursive call sees the
|
||||
# resolved rate from self.sampling_rate.
|
||||
assert captured[0] is None
|
||||
assert captured[1] == 16000
|
||||
|
||||
|
||||
def test_fetch_audio_explicit_sampling_rate_propagates(
|
||||
monkeypatch, feature_extractor: MistralCommonFeatureExtractor
|
||||
):
|
||||
captured: list[int | None] = []
|
||||
original = feature_extractor.fetch_audio
|
||||
|
||||
def spy(audio, sampling_rate=None):
|
||||
captured.append(sampling_rate)
|
||||
return original(audio, sampling_rate=sampling_rate)
|
||||
|
||||
monkeypatch.setattr(feature_extractor, "fetch_audio", spy)
|
||||
feature_extractor.fetch_audio([np.zeros(4, dtype=np.float32)], sampling_rate=8000)
|
||||
assert captured[0] == 8000
|
||||
assert captured[1] == 8000
|
||||
|
||||
|
||||
def test_fetch_audio_rejects_unsupported_type(
|
||||
feature_extractor: MistralCommonFeatureExtractor,
|
||||
):
|
||||
with pytest.raises(TypeError, match="only a numpy array"):
|
||||
feature_extractor.fetch_audio(42)
|
||||
|
||||
|
||||
def test_fetch_audio_str_delegates_to_load_audio(
|
||||
monkeypatch, feature_extractor: MistralCommonFeatureExtractor
|
||||
):
|
||||
"""A str input must round-trip through ``transformers.audio_utils.load_audio``.
|
||||
|
||||
We monkey-patch ``load_audio`` so the test stays offline (no real URL/path
|
||||
fetched) and still asserts the delegation contract.
|
||||
"""
|
||||
sentinel = np.array([0.5, -0.5], dtype=np.float32)
|
||||
received: dict[str, object] = {}
|
||||
|
||||
def fake_load_audio(path, sampling_rate=None):
|
||||
received["path"] = path
|
||||
received["sampling_rate"] = sampling_rate
|
||||
return sentinel
|
||||
|
||||
import transformers.audio_utils
|
||||
|
||||
monkeypatch.setattr(transformers.audio_utils, "load_audio", fake_load_audio)
|
||||
|
||||
result = feature_extractor.fetch_audio("/tmp/fake.wav")
|
||||
assert result is sentinel
|
||||
assert received["path"] == "/tmp/fake.wav"
|
||||
assert received["sampling_rate"] == 16000
|
||||
@@ -1,159 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
import copy
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from transformers import AutoConfig
|
||||
|
||||
from vllm.transformers_utils.config import get_config, uses_mrope
|
||||
from vllm.transformers_utils.configs.bailing_moe_v3_vl import (
|
||||
BailingMoeV3TextConfig,
|
||||
BailingMoeV3VisionConfig,
|
||||
BailingMoeV3VLConfig,
|
||||
)
|
||||
|
||||
|
||||
def _bailing_v3_vl_config() -> dict[str, Any]:
|
||||
return {
|
||||
"architectures": ["BailingMoeV3VLForConditionalGeneration"],
|
||||
"auto_map": {
|
||||
"AutoConfig": ("configuration_bailing_moe_v3_vl.BailingMoeV3VLConfig")
|
||||
},
|
||||
"model_type": "bailing_moe_v3_vl",
|
||||
"mrope_section": [8, 12, 12],
|
||||
"text_config": {
|
||||
"num_hidden_layers": 42,
|
||||
"layer_group_size": 6,
|
||||
"rope_theta": 6_000_000,
|
||||
},
|
||||
"vision_config": {"disable_merger_proj": True},
|
||||
}
|
||||
|
||||
|
||||
def _write_config(path: Path, config: dict[str, Any]) -> None:
|
||||
path.mkdir()
|
||||
(path / "config.json").write_text(json.dumps(config), encoding="utf-8")
|
||||
|
||||
|
||||
def test_bailing_v3_vl_config_loads_without_remote_code(tmp_path: Path):
|
||||
model_path = tmp_path / "model"
|
||||
_write_config(model_path, _bailing_v3_vl_config())
|
||||
|
||||
config = get_config(model_path, trust_remote_code=False)
|
||||
|
||||
assert isinstance(config, BailingMoeV3VLConfig)
|
||||
assert isinstance(config.text_config, BailingMoeV3TextConfig)
|
||||
assert isinstance(config.vision_config, BailingMoeV3VisionConfig)
|
||||
assert isinstance(
|
||||
AutoConfig.from_pretrained(model_path, trust_remote_code=False),
|
||||
BailingMoeV3VLConfig,
|
||||
)
|
||||
assert config.mrope_section == [8, 12, 12]
|
||||
assert uses_mrope(config)
|
||||
|
||||
text_config = config.text_config
|
||||
assert text_config.model_type == "bailing_hybrid"
|
||||
assert text_config.architectures == ["BailingMoeV3ForCausalLM"]
|
||||
assert text_config.rope_parameters["mrope_section"] == [8, 12, 12]
|
||||
assert text_config.rope_parameters["rope_theta"] == 6_000_000
|
||||
assert text_config.layer_types.count("linear_attention") == 35
|
||||
assert [
|
||||
layer_idx
|
||||
for layer_idx, layer_type in enumerate(text_config.layer_types)
|
||||
if layer_type == "full_attention"
|
||||
] == [5, 11, 17, 23, 29, 35, 41]
|
||||
assert config.vision_config.disable_merger_proj is True
|
||||
|
||||
normalized = config.to_dict()
|
||||
restored = BailingMoeV3VLConfig.from_dict(normalized)
|
||||
assert isinstance(restored.text_config, BailingMoeV3TextConfig)
|
||||
assert isinstance(restored.vision_config, BailingMoeV3VisionConfig)
|
||||
assert restored.to_dict() == normalized
|
||||
|
||||
|
||||
def test_bailing_v3_vl_config_preserves_explicit_nested_values():
|
||||
config_dict = _bailing_v3_vl_config()
|
||||
config_dict["architectures"] = ["CustomBailingVLForConditionalGeneration"]
|
||||
text_config = config_dict["text_config"]
|
||||
text_config["architectures"] = ["CustomBailingForCausalLM"]
|
||||
text_config["layer_types"] = (["linear_attention"] * 5 + ["full_attention"]) * 7
|
||||
text_config["rope_theta"] = 1_000_000
|
||||
text_config["rope_parameters"] = {
|
||||
"rope_type": "default",
|
||||
"rope_theta": 1_000_000,
|
||||
"mrope_section": [8, 12, 12],
|
||||
}
|
||||
original = copy.deepcopy(config_dict)
|
||||
|
||||
config = BailingMoeV3VLConfig(**config_dict)
|
||||
|
||||
assert config_dict == original
|
||||
assert config.architectures == ["CustomBailingVLForConditionalGeneration"]
|
||||
assert config.text_config.architectures == ["CustomBailingForCausalLM"]
|
||||
assert config.text_config.layer_types == text_config["layer_types"]
|
||||
assert config.text_config.rope_parameters["rope_theta"] == 1_000_000
|
||||
assert config.text_config.rope_parameters["mrope_section"] == [8, 12, 12]
|
||||
|
||||
|
||||
def test_bailing_v3_vl_config_normalizes_config_instance():
|
||||
text_config = BailingMoeV3TextConfig()
|
||||
|
||||
config = BailingMoeV3VLConfig(
|
||||
text_config=text_config,
|
||||
mrope_section=[8, 12, 12],
|
||||
)
|
||||
|
||||
assert config.text_config is text_config
|
||||
assert text_config.rope_parameters["mrope_section"] == [8, 12, 12]
|
||||
|
||||
|
||||
def test_bailing_v3_text_config_trailing_and_legacy_layers():
|
||||
expected = ["linear_attention", "linear_attention", "full_attention"] * 2 + [
|
||||
"full_attention"
|
||||
] * 2
|
||||
text_config = BailingMoeV3TextConfig(
|
||||
num_hidden_layers=8,
|
||||
layer_group_size=3,
|
||||
)
|
||||
assert text_config.layer_types == expected
|
||||
|
||||
text_config = BailingMoeV3TextConfig(
|
||||
num_hidden_layers=8,
|
||||
layer_group_size=3,
|
||||
layers_block_type=["mamba", "mamba", "attention"] * 2 + ["attention"] * 2,
|
||||
)
|
||||
assert text_config.layer_types == expected
|
||||
|
||||
|
||||
def test_bailing_v3_text_config_accepts_legacy_rope_type():
|
||||
text_config = BailingMoeV3TextConfig(rope_scaling={"type": "linear", "factor": 2.0})
|
||||
|
||||
assert text_config.rope_parameters["type"] == "linear"
|
||||
assert text_config.rope_parameters["rope_type"] == "linear"
|
||||
|
||||
|
||||
def test_bailing_v3_vl_config_rejects_invalid_values():
|
||||
with pytest.raises(ValueError, match="layer_group_size must be positive"):
|
||||
BailingMoeV3TextConfig(layer_group_size=0)
|
||||
|
||||
with pytest.raises(ValueError, match="must match the layer_group_size schedule"):
|
||||
BailingMoeV3TextConfig(
|
||||
num_hidden_layers=8,
|
||||
layer_group_size=3,
|
||||
layer_types=["full_attention"] * 8,
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match="conflicting M-RoPE sections"):
|
||||
BailingMoeV3VLConfig(
|
||||
text_config={
|
||||
"rope_parameters": {
|
||||
"rope_type": "default",
|
||||
"mrope_section": [4, 14, 14],
|
||||
}
|
||||
},
|
||||
mrope_section=[8, 12, 12],
|
||||
)
|
||||
@@ -1,153 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
import json
|
||||
|
||||
import pytest
|
||||
|
||||
from vllm.config import ModelConfig, ParallelConfig, SpeculativeConfig
|
||||
from vllm.transformers_utils.config import get_config
|
||||
from vllm.transformers_utils.configs.k3_dspark import K3DSparkConfig
|
||||
|
||||
|
||||
def _write_dspark_config(path, **overrides):
|
||||
path.mkdir()
|
||||
config = {
|
||||
"architectures": ["K3DSparkModel"],
|
||||
"model_type": "k3_dspark",
|
||||
"hidden_size": 7168,
|
||||
"intermediate_size": 14336,
|
||||
"num_hidden_layers": 5,
|
||||
"num_attention_heads": 96,
|
||||
"num_key_value_heads": 96,
|
||||
"q_lora_rank": 1536,
|
||||
"kv_lora_rank": 512,
|
||||
"qk_nope_head_dim": 128,
|
||||
"qk_rope_head_dim": 64,
|
||||
"v_head_dim": 128,
|
||||
"vocab_size": 163840,
|
||||
"rms_norm_eps": 1e-5,
|
||||
"max_position_embeddings": 32768,
|
||||
"rope_theta": 50000.0,
|
||||
"num_target_layers": 5,
|
||||
"target_hidden_size": 7168,
|
||||
"target_num_hidden_layers": 93,
|
||||
"target_layer_ids": [2, 23, 47, 71, 89],
|
||||
"markov_rank": 256,
|
||||
"draft_vocab_size": 163840,
|
||||
"torch_dtype": "bfloat16",
|
||||
}
|
||||
config.update(overrides)
|
||||
(path / "config.json").write_text(json.dumps(config))
|
||||
|
||||
|
||||
def _write_target_config(path):
|
||||
path.mkdir()
|
||||
config = {
|
||||
"architectures": ["LlamaForCausalLM"],
|
||||
"model_type": "llama",
|
||||
"hidden_size": 7168,
|
||||
"intermediate_size": 14336,
|
||||
"num_hidden_layers": 93,
|
||||
"num_attention_heads": 56,
|
||||
"num_key_value_heads": 8,
|
||||
"vocab_size": 163840,
|
||||
"max_position_embeddings": 32768,
|
||||
"torch_dtype": "bfloat16",
|
||||
}
|
||||
(path / "config.json").write_text(json.dumps(config))
|
||||
|
||||
|
||||
def test_dspark_mla_config_loads_from_local_json(tmp_path):
|
||||
draft_path = tmp_path / "draft"
|
||||
_write_dspark_config(draft_path)
|
||||
|
||||
config = get_config(draft_path, trust_remote_code=False)
|
||||
|
||||
assert isinstance(config, K3DSparkConfig)
|
||||
assert config.model_type == "k3_dspark"
|
||||
assert config.architectures == ["K3DSparkModel"]
|
||||
assert config.hidden_act == "silu"
|
||||
assert config.rope_parameters == {
|
||||
"rope_type": "default",
|
||||
"rope_theta": 50000.0,
|
||||
}
|
||||
assert config.n_routed_experts == 0
|
||||
assert config.draft_vocab_size == config.vocab_size
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"overrides",
|
||||
[
|
||||
{"mla_use_nope": True},
|
||||
{"mla_use_output_gate": True},
|
||||
{"mla_use_qk_norm": True},
|
||||
{"dspark_bonus_anchor": True},
|
||||
{"q_lora_rank": None},
|
||||
{"draft_vocab_size": 8192},
|
||||
{"target_layer_ids": []},
|
||||
{"num_target_layers": 4},
|
||||
],
|
||||
)
|
||||
def test_dspark_mla_rejects_unsupported_checkpoint_options(tmp_path, overrides):
|
||||
draft_path = tmp_path / "draft"
|
||||
_write_dspark_config(draft_path, **overrides)
|
||||
|
||||
with pytest.raises(ValueError, match="MLA DSpark"):
|
||||
get_config(draft_path, trust_remote_code=False)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("num_attention_heads", "expected_local_heads"),
|
||||
[(64, 8), (96, 12)],
|
||||
ids=["released-64-head", "block5-96-head"],
|
||||
)
|
||||
def test_dspark_mla_uses_latent_kv_geometry(
|
||||
tmp_path, num_attention_heads, expected_local_heads
|
||||
):
|
||||
draft_path = tmp_path / "draft"
|
||||
_write_dspark_config(
|
||||
draft_path,
|
||||
num_attention_heads=num_attention_heads,
|
||||
num_key_value_heads=num_attention_heads,
|
||||
)
|
||||
model_config = ModelConfig(
|
||||
model=str(draft_path),
|
||||
tokenizer_mode="skip",
|
||||
runner="draft",
|
||||
max_model_len=32768,
|
||||
)
|
||||
|
||||
assert model_config.is_deepseek_mla
|
||||
assert model_config.use_mla
|
||||
assert model_config.get_head_size() == 576
|
||||
# external_launcher skips ParallelConfig's local-GPU-count check so the
|
||||
# config logic can be exercised at TP8 on a single-GPU test node.
|
||||
parallel_config = ParallelConfig(
|
||||
tensor_parallel_size=8, distributed_executor_backend="external_launcher"
|
||||
)
|
||||
assert model_config.get_num_kv_heads(parallel_config) == 1
|
||||
assert model_config.get_num_attention_heads(parallel_config) == expected_local_heads
|
||||
assert model_config.get_num_experts() == 0
|
||||
|
||||
|
||||
def test_dspark_mla_speculative_config_preserves_architecture(tmp_path):
|
||||
target_path = tmp_path / "target"
|
||||
draft_path = tmp_path / "draft"
|
||||
_write_target_config(target_path)
|
||||
_write_dspark_config(draft_path)
|
||||
target_config = ModelConfig(
|
||||
model=str(target_path), tokenizer_mode="skip", max_model_len=32768
|
||||
)
|
||||
speculative_config = SpeculativeConfig(
|
||||
model=str(draft_path),
|
||||
method="dspark",
|
||||
num_speculative_tokens=8,
|
||||
target_model_config=target_config,
|
||||
target_parallel_config=ParallelConfig(),
|
||||
)
|
||||
|
||||
assert speculative_config.parallel_drafting
|
||||
assert speculative_config.draft_model_config.architectures == ["K3DSparkModel"]
|
||||
assert speculative_config.draft_model_config.hf_config.model_type == "k3_dspark"
|
||||
assert speculative_config.draft_model_config.use_mla
|
||||
Reference in New Issue
Block a user