[Mini-vLLM] Cut dead subsystems: models, entrypoints, backends, utils, tests
- Drop dead model modules, keeping files live imports require - Remove anthropic, cohere, codegen entrypoints and batch STT modes - Delete unused attention backends, MoE experts, and NPU/XPU util leaves - Strip dead third_party trees and ROCm leaves with no CUDA path - Remove mooncake EC connectors: dependency missing since branch base - Re-audit verified by full import sweep and Qwen3.5 smoke test Co-authored-by: Hinata <hinata@idihore.id> Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
@@ -1,156 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.evals.gsm8k.gsm8k_eval import evaluate_gsm8k_offline
|
||||
from vllm.config import CompilationConfig
|
||||
from vllm.platforms import current_platform
|
||||
|
||||
from ...utils import compute_acceptance_len, compute_acceptance_rate
|
||||
|
||||
REGRESSION_TOLERANCE = 0.95
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class DSparkCorrectnessConfig:
|
||||
model: str
|
||||
draft_model: str
|
||||
reference_accuracy: float
|
||||
reference_acceptance_rate: float
|
||||
reference_acceptance_len: float
|
||||
num_speculative_tokens: int = 7
|
||||
max_model_len: int = 4096
|
||||
max_num_seqs: int | None = None
|
||||
num_questions: int = 1319
|
||||
max_tokens: int = 256
|
||||
use_chat_completions: bool = False
|
||||
chat_template_kwargs: dict[str, object] | None = None
|
||||
attention_backend: str | None = None
|
||||
gpu_memory_utilization: float = 0.92
|
||||
enforce_eager: bool = False
|
||||
disable_flashinfer_sampler: bool = False
|
||||
language_model_only: bool = False
|
||||
|
||||
|
||||
# References from 12 full GSM8K runs at temperature 1.0: accuracy 0.782-0.814,
|
||||
# acceptance rate 0.418-0.434, acceptance length 3.928-4.037.
|
||||
QWEN3_DSPARK_DEEPSPEC = DSparkCorrectnessConfig(
|
||||
model="Qwen/Qwen3-4B-FP8",
|
||||
draft_model="deepseek-ai/dspark_qwen3_4b_block7",
|
||||
reference_accuracy=0.801,
|
||||
reference_acceptance_rate=0.428,
|
||||
reference_acceptance_len=3.994,
|
||||
attention_backend="FLASH_ATTN",
|
||||
)
|
||||
|
||||
# References from five 200-question runs at temperature 1.0: accuracy
|
||||
# 0.900-0.955, acceptance rate 0.578-0.595, acceptance length 5.044-5.167.
|
||||
GEMMA4_DSPARK_DEEPSPEC = DSparkCorrectnessConfig(
|
||||
model="RedHatAI/gemma-4-12B-it-NVFP4",
|
||||
draft_model="deepseek-ai/dspark_gemma4_12b_block7",
|
||||
reference_accuracy=0.92,
|
||||
reference_acceptance_rate=0.58,
|
||||
reference_acceptance_len=5.0,
|
||||
max_num_seqs=32,
|
||||
num_questions=200,
|
||||
use_chat_completions=True,
|
||||
gpu_memory_utilization=0.85,
|
||||
enforce_eager=True,
|
||||
disable_flashinfer_sampler=True,
|
||||
language_model_only=True,
|
||||
)
|
||||
|
||||
# Reference from 200 GSM8K questions at temperature 1.0.
|
||||
QWEN3_6_DSPARK_SPECULATORS = DSparkCorrectnessConfig(
|
||||
model="RedHatAI/Qwen3.6-35B-A3B-NVFP4",
|
||||
draft_model="RedHatAI/Qwen3.6-35B-A3B-speculator.dspark",
|
||||
reference_accuracy=0.85,
|
||||
reference_acceptance_rate=0.41,
|
||||
reference_acceptance_len=4.25,
|
||||
num_speculative_tokens=8,
|
||||
max_num_seqs=32,
|
||||
num_questions=200,
|
||||
use_chat_completions=True,
|
||||
chat_template_kwargs={"enable_thinking": False},
|
||||
gpu_memory_utilization=0.85,
|
||||
language_model_only=True,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"config",
|
||||
[
|
||||
pytest.param(QWEN3_DSPARK_DEEPSPEC, id="qwen3-deepspec"),
|
||||
pytest.param(GEMMA4_DSPARK_DEEPSPEC, id="gemma4-deepspec"),
|
||||
pytest.param(QWEN3_6_DSPARK_SPECULATORS, id="qwen3.6-speculators"),
|
||||
],
|
||||
)
|
||||
def test_dspark_correctness_and_acceptance_rate(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
config: DSparkCorrectnessConfig,
|
||||
vllm_runner,
|
||||
):
|
||||
"""Guard GSM8K accuracy and acceptance metrics for DSpark models."""
|
||||
if config.disable_flashinfer_sampler:
|
||||
monkeypatch.setenv("VLLM_USE_FLASHINFER_SAMPLER", "0")
|
||||
|
||||
speculative_config = {
|
||||
"method": "dspark",
|
||||
"model": config.draft_model,
|
||||
"num_speculative_tokens": config.num_speculative_tokens,
|
||||
"draft_sample_method": "probabilistic",
|
||||
}
|
||||
if config.attention_backend is not None and current_platform.is_cuda():
|
||||
speculative_config["attention_backend"] = config.attention_backend
|
||||
|
||||
runner_config = {
|
||||
"block_size": None,
|
||||
"trust_remote_code": True,
|
||||
"speculative_config": speculative_config,
|
||||
"max_model_len": config.max_model_len,
|
||||
"gpu_memory_utilization": config.gpu_memory_utilization,
|
||||
"enforce_eager": config.enforce_eager,
|
||||
"enable_chunked_prefill": None,
|
||||
"enable_prefix_caching": False,
|
||||
"disable_log_stats": False,
|
||||
"compilation_config": CompilationConfig(),
|
||||
}
|
||||
if config.max_num_seqs is not None:
|
||||
runner_config["max_num_seqs"] = config.max_num_seqs
|
||||
if config.language_model_only:
|
||||
runner_config["language_model_only"] = True
|
||||
|
||||
with vllm_runner(config.model, **runner_config) as spec_runner:
|
||||
spec_llm = spec_runner.llm
|
||||
results = evaluate_gsm8k_offline(
|
||||
spec_llm,
|
||||
num_questions=config.num_questions,
|
||||
max_tokens=config.max_tokens,
|
||||
temperature=1.0,
|
||||
use_chat_completions=config.use_chat_completions,
|
||||
chat_template_kwargs=config.chat_template_kwargs,
|
||||
)
|
||||
accuracy = results["accuracy"]
|
||||
metrics = spec_llm.get_metrics()
|
||||
acceptance_rate = compute_acceptance_rate(metrics)
|
||||
acceptance_len = compute_acceptance_len(metrics)
|
||||
context = f"DSpark target={config.model}, draft={config.draft_model}"
|
||||
metrics_summary = (
|
||||
f"gsm8k_accuracy={accuracy:.3f}, "
|
||||
f"acceptance_rate={acceptance_rate:.3f}, "
|
||||
f"acceptance_len={acceptance_len:.3f}"
|
||||
)
|
||||
print(f"{context}: {metrics_summary}")
|
||||
|
||||
assert accuracy >= config.reference_accuracy * REGRESSION_TOLERANCE, (
|
||||
f"{context}: {metrics_summary}"
|
||||
)
|
||||
assert (
|
||||
acceptance_rate >= config.reference_acceptance_rate * REGRESSION_TOLERANCE
|
||||
), f"{context}: {metrics_summary}"
|
||||
assert (
|
||||
acceptance_len >= config.reference_acceptance_len * REGRESSION_TOLERANCE
|
||||
), f"{context}: {metrics_summary}"
|
||||
@@ -1,56 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
from tests.utils import single_gpu_only
|
||||
from vllm import SamplingParams
|
||||
from vllm.config import CompilationConfig
|
||||
|
||||
from ...utils import compute_acceptance_len, get_test_prompts
|
||||
|
||||
|
||||
@single_gpu_only
|
||||
def test_synthetic_acceptance_rate(vllm_runner):
|
||||
"""Verify that synthetic rejection sampling produces an acceptance
|
||||
length close to the requested mean acceptance length."""
|
||||
num_spec_tokens = 3
|
||||
expected_acceptance_len = 1.875
|
||||
tolerance = 0.15
|
||||
|
||||
with vllm_runner(
|
||||
"meta-llama/Llama-3.2-1B-Instruct",
|
||||
block_size=None,
|
||||
trust_remote_code=True,
|
||||
speculative_config={
|
||||
"method": "eagle3",
|
||||
"model": "nm-testing/Llama3_2_1B_speculator.eagle3",
|
||||
"num_speculative_tokens": num_spec_tokens,
|
||||
"max_model_len": 2048,
|
||||
"rejection_sample_method": "synthetic",
|
||||
"synthetic_acceptance_length": expected_acceptance_len,
|
||||
},
|
||||
max_model_len=2048,
|
||||
enforce_eager=True,
|
||||
enable_chunked_prefill=None,
|
||||
disable_log_stats=False,
|
||||
compilation_config=CompilationConfig(),
|
||||
) as spec_runner:
|
||||
spec_llm = spec_runner.llm
|
||||
|
||||
test_prompts = get_test_prompts(mm_enabled=False, num_prompts=50)
|
||||
spec_llm.chat(
|
||||
test_prompts,
|
||||
SamplingParams(temperature=0, max_tokens=64, ignore_eos=True),
|
||||
)
|
||||
|
||||
metrics = spec_llm.get_metrics()
|
||||
acceptance_len = compute_acceptance_len(metrics)
|
||||
|
||||
print(
|
||||
f"Synthetic acceptance length: {acceptance_len:.3f}"
|
||||
f" (expected={expected_acceptance_len:.3f},"
|
||||
f" tolerance=±{tolerance})"
|
||||
)
|
||||
assert abs(acceptance_len - expected_acceptance_len) <= tolerance, (
|
||||
f"Synthetic acceptance length {acceptance_len:.3f} is not within"
|
||||
f" ±{tolerance} of expected {expected_acceptance_len:.3f}"
|
||||
)
|
||||
@@ -1,102 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
|
||||
from vllm import SamplingParams
|
||||
from vllm.config import CompilationConfig
|
||||
|
||||
from ..utils import compute_acceptance_len
|
||||
|
||||
|
||||
def load_and_process_dataset(data_name: str):
|
||||
from datasets import load_dataset
|
||||
|
||||
if data_name == "gsm8k":
|
||||
dataset = load_dataset("openai/gsm8k", "main", split="test")
|
||||
prompt_fmt = (
|
||||
"{question}\nPlease reason step by step,"
|
||||
" and put your final answer within \\boxed{{}}."
|
||||
)
|
||||
dataset = dataset.map(lambda x: {"turns": [prompt_fmt.format(**x)]})
|
||||
elif data_name == "mt-bench":
|
||||
dataset = load_dataset("HuggingFaceH4/mt_bench_prompts", split="train")
|
||||
dataset = dataset.map(lambda x: {"turns": x["prompt"]})
|
||||
elif data_name == "humaneval":
|
||||
dataset = load_dataset("openai/openai_humaneval", split="test")
|
||||
prompt_fmt = (
|
||||
"Write a solution to the following problem and make sure"
|
||||
" that it passes the tests:\n```python\n{prompt}\n```"
|
||||
)
|
||||
dataset = dataset.map(lambda x: {"turns": [prompt_fmt.format(**x)]})
|
||||
|
||||
return dataset
|
||||
|
||||
|
||||
def run_acceptance_length_eval(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
vllm_runner,
|
||||
spec_config: dict[str, Any],
|
||||
expected_acceptance_lengths: dict[str, float],
|
||||
chat_template_kwargs: dict[str, Any],
|
||||
use_mrv2: bool,
|
||||
):
|
||||
"""E2E acceptance-rate validation for speculative decoding.
|
||||
|
||||
Drives one or more datasets (keyed in ``expected_acceptance_lengths``)
|
||||
through the spec decode engine and asserts the mean acceptance length
|
||||
stays within tolerance of the reference figure for each dataset.
|
||||
"""
|
||||
monkeypatch.setenv("VLLM_USE_V2_MODEL_RUNNER", "1" if use_mrv2 else "0")
|
||||
runner_config = spec_config.copy()
|
||||
model = runner_config.pop("model")
|
||||
runner_config.setdefault("block_size", None)
|
||||
runner_config.setdefault("enable_chunked_prefill", None)
|
||||
runner_config.setdefault("compilation_config", CompilationConfig())
|
||||
with vllm_runner(model, **runner_config) as spec_runner:
|
||||
spec_llm = spec_runner.llm
|
||||
# MT-Bench has 80 prompts and HumanEval has 164; truncate GSM8K.
|
||||
max_prompts_per_dataset = 200
|
||||
|
||||
tokenizer = spec_llm.get_tokenizer()
|
||||
for dataset_name, expected_len in expected_acceptance_lengths.items():
|
||||
dataset = load_and_process_dataset(dataset_name)
|
||||
prev_metrics = None
|
||||
acceptance_lengths = []
|
||||
for i in range(min(max_prompts_per_dataset, len(dataset))):
|
||||
user_content = dataset[i]["turns"][0]
|
||||
prompt_text = tokenizer.apply_chat_template(
|
||||
[{"role": "user", "content": user_content}],
|
||||
tokenize=False,
|
||||
add_generation_prompt=True,
|
||||
**chat_template_kwargs,
|
||||
)
|
||||
|
||||
# Greedy (temp=0) so acceptance length is deterministic and comparable
|
||||
# across runs.
|
||||
spec_llm.generate(
|
||||
[prompt_text],
|
||||
SamplingParams(temperature=0, max_tokens=2048),
|
||||
use_tqdm=False,
|
||||
)
|
||||
current_metrics = spec_llm.get_metrics()
|
||||
acceptance_len = compute_acceptance_len(current_metrics, prev_metrics)
|
||||
prev_metrics = current_metrics
|
||||
acceptance_lengths.append(acceptance_len)
|
||||
|
||||
mean_acceptance_length = sum(acceptance_lengths) / len(acceptance_lengths)
|
||||
# Fairly tight tolerance of 95% against the reference figures,
|
||||
# watching for regressions. Can be relaxed if test is flaky but be sure to
|
||||
# check for genuine issues such as #40727.
|
||||
expected_len = expected_len * 0.95
|
||||
print(
|
||||
f"acceptance_len for {dataset_name}: {mean_acceptance_length:.2f}"
|
||||
f" (expected at least {expected_len:.2f})"
|
||||
)
|
||||
|
||||
assert mean_acceptance_length >= expected_len, (
|
||||
f"acceptance_len for {dataset_name} is below expected threshold: "
|
||||
f"{mean_acceptance_length:.2f} < {expected_len:.2f}"
|
||||
)
|
||||
Reference in New Issue
Block a user