[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
|
||||
"""Test that we handle a startup Error and shutdown."""
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.conftest import VllmRunner
|
||||
from tests.utils import create_new_process_for_each_test, wait_for_gpu_memory_to_clear
|
||||
from tests.v1.shutdown.utils import (
|
||||
SHUTDOWN_TEST_THRESHOLD_BYTES,
|
||||
SHUTDOWN_TEST_TIMEOUT_SEC,
|
||||
)
|
||||
from vllm import LLM, SamplingParams
|
||||
from vllm.config import KernelConfig
|
||||
from vllm.engine.arg_utils import AsyncEngineArgs
|
||||
from vllm.platforms import current_platform
|
||||
from vllm.sampling_params import RequestOutputKind
|
||||
from vllm.v1.engine.async_llm import AsyncLLM
|
||||
|
||||
MODELS = ["hmellor/tiny-random-LlamaForCausalLM"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.timeout(SHUTDOWN_TEST_TIMEOUT_SEC)
|
||||
@pytest.mark.parametrize("model", MODELS)
|
||||
@pytest.mark.parametrize("tensor_parallel_size", [2, 1])
|
||||
@pytest.mark.parametrize("send_one_request", [False, True])
|
||||
async def test_async_llm_delete(
|
||||
model: str, tensor_parallel_size: int, send_one_request: bool
|
||||
) -> None:
|
||||
"""Test that AsyncLLM frees GPU memory upon deletion.
|
||||
AsyncLLM always uses an MP client.
|
||||
|
||||
Args:
|
||||
model: model under test
|
||||
tensor_parallel_size: degree of tensor parallelism
|
||||
send_one_request: send one request to engine before deleting
|
||||
|
||||
"""
|
||||
if current_platform.device_count() < tensor_parallel_size:
|
||||
pytest.skip(reason="Not enough CUDA devices")
|
||||
|
||||
engine_args = AsyncEngineArgs(
|
||||
model=model,
|
||||
enforce_eager=True,
|
||||
tensor_parallel_size=tensor_parallel_size,
|
||||
kernel_config=KernelConfig(enable_jit_warmup=False),
|
||||
)
|
||||
|
||||
# Instantiate AsyncLLM; make request to complete any deferred
|
||||
# initialization; then delete instance
|
||||
async_llm = AsyncLLM.from_engine_args(engine_args)
|
||||
if send_one_request:
|
||||
async for _ in async_llm.generate(
|
||||
"Hello my name is",
|
||||
request_id="abc",
|
||||
sampling_params=SamplingParams(
|
||||
max_tokens=1, output_kind=RequestOutputKind.DELTA
|
||||
),
|
||||
):
|
||||
pass
|
||||
del async_llm
|
||||
|
||||
# Confirm all the processes are cleaned up.
|
||||
wait_for_gpu_memory_to_clear(
|
||||
devices=list(range(tensor_parallel_size)),
|
||||
threshold_bytes=SHUTDOWN_TEST_THRESHOLD_BYTES,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.timeout(SHUTDOWN_TEST_TIMEOUT_SEC)
|
||||
@pytest.mark.parametrize("model", MODELS)
|
||||
@pytest.mark.parametrize("tensor_parallel_size", [2, 1])
|
||||
@pytest.mark.parametrize("enable_multiprocessing", [True])
|
||||
@pytest.mark.parametrize("send_one_request", [False, True])
|
||||
def test_llm_delete(
|
||||
monkeypatch,
|
||||
model: str,
|
||||
tensor_parallel_size: int,
|
||||
enable_multiprocessing: bool,
|
||||
send_one_request: bool,
|
||||
) -> None:
|
||||
"""Test that LLM frees GPU memory upon deletion.
|
||||
TODO(andy) - LLM without multiprocessing.
|
||||
|
||||
Args:
|
||||
model: model under test
|
||||
tensor_parallel_size: degree of tensor parallelism
|
||||
enable_multiprocessing: enable workers in separate process(es)
|
||||
send_one_request: send one request to engine before deleting
|
||||
|
||||
"""
|
||||
if current_platform.device_count() < tensor_parallel_size:
|
||||
pytest.skip(reason="Not enough CUDA devices")
|
||||
|
||||
with monkeypatch.context() as m:
|
||||
MP_VALUE = "1" if enable_multiprocessing else "0"
|
||||
m.setenv("VLLM_ENABLE_V1_MULTIPROCESSING", MP_VALUE)
|
||||
|
||||
# Instantiate LLM; make request to complete any deferred
|
||||
# initialization; then delete instance
|
||||
llm = LLM(
|
||||
model=model,
|
||||
enforce_eager=True,
|
||||
tensor_parallel_size=tensor_parallel_size,
|
||||
kernel_config=KernelConfig(enable_jit_warmup=False),
|
||||
)
|
||||
if send_one_request:
|
||||
llm.generate(
|
||||
"Hello my name is", sampling_params=SamplingParams(max_tokens=1)
|
||||
)
|
||||
del llm
|
||||
|
||||
# Confirm all the processes are cleaned up.
|
||||
wait_for_gpu_memory_to_clear(
|
||||
devices=list(range(tensor_parallel_size)),
|
||||
threshold_bytes=SHUTDOWN_TEST_THRESHOLD_BYTES,
|
||||
)
|
||||
|
||||
|
||||
@create_new_process_for_each_test("fork" if current_platform.is_cuda() else "spawn")
|
||||
@pytest.mark.timeout(SHUTDOWN_TEST_TIMEOUT_SEC)
|
||||
@pytest.mark.parametrize("model", MODELS)
|
||||
@pytest.mark.parametrize("send_one_request", [False, True])
|
||||
def test_llm_delete_inprocess(
|
||||
monkeypatch,
|
||||
model: str,
|
||||
send_one_request: bool,
|
||||
) -> None:
|
||||
"""Test that VllmRunner frees GPU memory in in-process (no MP) mode."""
|
||||
with monkeypatch.context() as m:
|
||||
m.setenv("VLLM_ENABLE_V1_MULTIPROCESSING", "0")
|
||||
|
||||
with VllmRunner(
|
||||
model,
|
||||
kernel_config=KernelConfig(enable_jit_warmup=False),
|
||||
) as vllm_model:
|
||||
if send_one_request:
|
||||
vllm_model.generate(
|
||||
["Hello my name is"],
|
||||
SamplingParams(max_tokens=1),
|
||||
)
|
||||
|
||||
wait_for_gpu_memory_to_clear(
|
||||
devices=[0],
|
||||
threshold_bytes=SHUTDOWN_TEST_THRESHOLD_BYTES,
|
||||
# Activate the helper's ROCm idle-runtime floor. VllmRunner already
|
||||
# performed the stable-memory wait during context exit.
|
||||
threshold_ratio=0.01 if current_platform.is_rocm() else None,
|
||||
# Fail in the child before the outer pytest timeout expires.
|
||||
timeout_s=(
|
||||
SHUTDOWN_TEST_TIMEOUT_SEC // 2
|
||||
if current_platform.is_rocm()
|
||||
else SHUTDOWN_TEST_TIMEOUT_SEC
|
||||
),
|
||||
)
|
||||
@@ -1,76 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
"""Test error handling in Processor. Should not impact other reqs."""
|
||||
|
||||
import asyncio
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.v1.shutdown.utils import SHUTDOWN_TEST_TIMEOUT_SEC
|
||||
from vllm import SamplingParams
|
||||
from vllm.engine.arg_utils import AsyncEngineArgs
|
||||
from vllm.inputs import ExplicitEncoderDecoderPrompt
|
||||
from vllm.sampling_params import RequestOutputKind
|
||||
from vllm.v1.engine.async_llm import AsyncLLM
|
||||
from vllm.v1.engine.exceptions import EngineGenerateError
|
||||
|
||||
MODELS = ["meta-llama/Llama-3.2-1B"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.timeout(SHUTDOWN_TEST_TIMEOUT_SEC)
|
||||
@pytest.mark.parametrize("model", MODELS)
|
||||
async def test_async_llm_processor_error(model: str) -> None:
|
||||
"""Test that AsyncLLM propagates a processor error.
|
||||
Test empty tokens prompt (failure) and non-empty prompt (no failure.)
|
||||
AsyncLLM always uses an MP client.
|
||||
"""
|
||||
engine_args = AsyncEngineArgs(model=model, enforce_eager=True)
|
||||
async_llm = AsyncLLM.from_engine_args(engine_args)
|
||||
|
||||
async def generate(request_id: str):
|
||||
# An encoder/decoder prompt is rejected by the Processor for a
|
||||
# decoder only model.
|
||||
generator = async_llm.generate(
|
||||
ExplicitEncoderDecoderPrompt(
|
||||
encoder_prompt="Hello my name is", decoder_prompt=None
|
||||
),
|
||||
request_id=request_id,
|
||||
sampling_params=SamplingParams(),
|
||||
)
|
||||
try:
|
||||
async for _ in generator:
|
||||
pass
|
||||
except Exception as e:
|
||||
return e
|
||||
|
||||
NUM_REQS = 3
|
||||
tasks = [generate(f"request-{idx}") for idx in range(NUM_REQS)]
|
||||
outputs = await asyncio.gather(*tasks)
|
||||
|
||||
# Every request should have get an EngineGenerateError.
|
||||
for output in outputs:
|
||||
with pytest.raises(EngineGenerateError):
|
||||
raise output
|
||||
|
||||
# AsyncLLM should be errored.
|
||||
assert not async_llm.errored
|
||||
|
||||
# This should be no problem.
|
||||
EXPECTED_TOKENS = 5
|
||||
outputs = []
|
||||
async for out in async_llm.generate(
|
||||
"Hello my name is",
|
||||
request_id="abc",
|
||||
sampling_params=SamplingParams(
|
||||
max_tokens=EXPECTED_TOKENS, output_kind=RequestOutputKind.DELTA
|
||||
),
|
||||
):
|
||||
outputs.append(out)
|
||||
|
||||
generated_tokens = []
|
||||
for out in outputs:
|
||||
generated_tokens.extend(out.outputs[0].token_ids)
|
||||
assert len(generated_tokens) == EXPECTED_TOKENS
|
||||
|
||||
async_llm.shutdown()
|
||||
Reference in New Issue
Block a user