replace cuda_device_count_stateless() to current_platform.device_count() (#37841)
Signed-off-by: Liao, Wei <wei.liao@intel.com> Signed-off-by: wliao2 <wei.liao@intel.com> Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: Kunshang Ji <kunshang.ji@intel.com>
This commit is contained in:
@@ -6,7 +6,6 @@ import pytest
|
||||
|
||||
from vllm.config import CompilationMode
|
||||
from vllm.platforms import current_platform
|
||||
from vllm.utils.torch_utils import cuda_device_count_stateless
|
||||
|
||||
from ...utils import compare_all_settings
|
||||
|
||||
@@ -109,10 +108,10 @@ def test_compile_correctness(
|
||||
tp_size = test_setting.tp_size
|
||||
attn_backend = test_setting.attn_backend
|
||||
method = test_setting.method
|
||||
if cuda_device_count_stateless() < pp_size * tp_size:
|
||||
if current_platform.device_count() < pp_size * tp_size:
|
||||
pytest.skip(
|
||||
f"Need at least {pp_size}*{tp_size} CUDA gpus but got "
|
||||
f"{cuda_device_count_stateless()}"
|
||||
f"{current_platform.device_count()}"
|
||||
)
|
||||
|
||||
final_args = [
|
||||
|
||||
@@ -412,7 +412,7 @@ def test_cudagraph_sizes_post_init(
|
||||
|
||||
with (
|
||||
ctx,
|
||||
patch("vllm.config.parallel.cuda_device_count_stateless", return_value=tp_size),
|
||||
patch.object(current_platform, "device_count", return_value=tp_size),
|
||||
):
|
||||
kwargs = {}
|
||||
if cudagraph_capture_sizes is not None:
|
||||
|
||||
@@ -13,7 +13,6 @@ from vllm.distributed.utils import StatelessProcessGroup
|
||||
from vllm.platforms import current_platform
|
||||
from vllm.utils.network_utils import get_open_port
|
||||
from vllm.utils.system_utils import update_environment_variables
|
||||
from vllm.utils.torch_utils import cuda_device_count_stateless
|
||||
|
||||
from ..utils import multi_gpu_test
|
||||
|
||||
@@ -21,7 +20,7 @@ from ..utils import multi_gpu_test
|
||||
@ray.remote
|
||||
class _CUDADeviceCountStatelessTestActor:
|
||||
def get_count(self):
|
||||
return cuda_device_count_stateless()
|
||||
return current_platform.device_count()
|
||||
|
||||
def set_cuda_visible_devices(self, cuda_visible_devices: str):
|
||||
update_environment_variables({"CUDA_VISIBLE_DEVICES": cuda_visible_devices})
|
||||
|
||||
@@ -15,7 +15,7 @@ from vllm.config import VllmConfig, set_current_vllm_config
|
||||
from vllm.platforms import current_platform
|
||||
from vllm.utils.flashinfer import has_flashinfer_cutlass_fused_moe
|
||||
from vllm.utils.import_utils import has_deep_ep, has_deep_gemm
|
||||
from vllm.utils.torch_utils import cuda_device_count_stateless, set_random_seed
|
||||
from vllm.utils.torch_utils import set_random_seed
|
||||
from vllm.v1.worker.workspace import init_workspace_manager
|
||||
|
||||
from .modular_kernel_tools.common import (
|
||||
@@ -310,10 +310,10 @@ def test_modular_kernel_combinations_multigpu(
|
||||
world_size: int,
|
||||
pytestconfig,
|
||||
):
|
||||
if cuda_device_count_stateless() < world_size:
|
||||
if current_platform.device_count() < world_size:
|
||||
pytest.skip(
|
||||
f"Not enough GPUs available to run, got "
|
||||
f"{cuda_device_count_stateless()} expected "
|
||||
f"{current_platform.device_count()} expected "
|
||||
f"{world_size}."
|
||||
)
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ from vllm.model_executor.model_loader.reload.meta import (
|
||||
from vllm.model_executor.model_loader.reload.types import LayerReloadingInfo
|
||||
from vllm.model_executor.model_loader.reload.utils import get_layer_tensors
|
||||
from vllm.platforms import current_platform
|
||||
from vllm.utils.torch_utils import cuda_device_count_stateless
|
||||
|
||||
|
||||
def test_move_metatensors():
|
||||
@@ -140,7 +139,7 @@ def test_get_numel_loaded():
|
||||
],
|
||||
)
|
||||
def test_reload_weights(base_model, mul_model, add_model, tp_size, vllm_runner):
|
||||
if cuda_device_count_stateless() < tp_size:
|
||||
if current_platform.device_count() < tp_size:
|
||||
pytest.skip(reason="Not enough CUDA devices")
|
||||
|
||||
if "FP8" in base_model and not current_platform.supports_fp8():
|
||||
@@ -206,8 +205,8 @@ def test_reload_weights(base_model, mul_model, add_model, tp_size, vllm_runner):
|
||||
def test_online_quantize_reload(
|
||||
base_model, mul_model, add_model, quantization, tp_size, vllm_runner
|
||||
):
|
||||
if cuda_device_count_stateless() < tp_size:
|
||||
pytest.skip(reason="Not enough CUDA devices")
|
||||
if current_platform.device_count() < tp_size:
|
||||
pytest.skip(reason="Not enough GPU devices")
|
||||
|
||||
if quantization == "fp8" and not current_platform.supports_fp8():
|
||||
pytest.skip(reason="Requires FP8 support")
|
||||
|
||||
@@ -21,8 +21,8 @@ import lm_eval
|
||||
import pytest
|
||||
from packaging import version
|
||||
|
||||
from vllm.platforms import current_platform
|
||||
from vllm.platforms.rocm import on_gfx950
|
||||
from vllm.utils.torch_utils import cuda_device_count_stateless
|
||||
|
||||
MODEL_ACCURACIES = {
|
||||
# Full quantization: attention linears and MoE linears
|
||||
@@ -89,7 +89,7 @@ def test_gpt_oss_attention_quantization(
|
||||
expected_accuracy: float,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
):
|
||||
if tp_size > cuda_device_count_stateless():
|
||||
if tp_size > current_platform.device_count():
|
||||
pytest.skip("Not enough GPUs to run this test case")
|
||||
|
||||
if "amd/gpt-oss-20b-MoE-Quant-W-MXFP4-A-FP8-KV-FP8" in model_name and on_gfx950():
|
||||
|
||||
@@ -58,7 +58,6 @@ from vllm.utils.argparse_utils import FlexibleArgumentParser
|
||||
from vllm.utils.mem_constants import GB_bytes
|
||||
from vllm.utils.network_utils import get_open_port
|
||||
from vllm.utils.torch_utils import (
|
||||
cuda_device_count_stateless,
|
||||
set_random_seed, # noqa: F401 - re-exported for use in test files
|
||||
)
|
||||
|
||||
@@ -384,7 +383,7 @@ class RemoteVLLMServer:
|
||||
elif current_platform.is_cuda():
|
||||
with _nvml():
|
||||
total_used = 0
|
||||
device_count = cuda_device_count_stateless()
|
||||
device_count = current_platform.device_count()
|
||||
for i in range(device_count):
|
||||
handle = nvmlDeviceGetHandleByIndex(i)
|
||||
mem_info = nvmlDeviceGetMemoryInfo(handle)
|
||||
@@ -1497,7 +1496,7 @@ def multi_gpu_marks(*, num_gpus: int):
|
||||
"""Get a collection of pytest marks to apply for `@multi_gpu_test`."""
|
||||
test_selector = pytest.mark.distributed(num_gpus=num_gpus)
|
||||
test_skipif = pytest.mark.skipif(
|
||||
cuda_device_count_stateless() < num_gpus,
|
||||
current_platform.device_count() < num_gpus,
|
||||
reason=f"Need at least {num_gpus} GPUs to run the test.",
|
||||
)
|
||||
|
||||
@@ -1529,7 +1528,7 @@ def gpu_tier_mark(*, min_gpus: int = 1, max_gpus: int | None = None):
|
||||
@gpu_tier_mark(max_gpus=1) # only on single-GPU
|
||||
@gpu_tier_mark(min_gpus=2, max_gpus=4) # 2-4 GPUs only
|
||||
"""
|
||||
gpu_count = cuda_device_count_stateless()
|
||||
gpu_count = current_platform.device_count()
|
||||
marks = []
|
||||
|
||||
if min_gpus > 1:
|
||||
|
||||
@@ -11,8 +11,8 @@ from tests.v1.shutdown.utils import (
|
||||
)
|
||||
from vllm import LLM, SamplingParams
|
||||
from vllm.engine.arg_utils import AsyncEngineArgs
|
||||
from vllm.platforms import current_platform
|
||||
from vllm.sampling_params import RequestOutputKind
|
||||
from vllm.utils.torch_utils import cuda_device_count_stateless
|
||||
from vllm.v1.engine.async_llm import AsyncLLM
|
||||
|
||||
MODELS = ["hmellor/tiny-random-LlamaForCausalLM"]
|
||||
@@ -34,7 +34,7 @@ async def test_async_llm_delete(
|
||||
tensor_parallel_size: degree of tensor parallelism
|
||||
send_one_request: send one request to engine before deleting
|
||||
"""
|
||||
if cuda_device_count_stateless() < tensor_parallel_size:
|
||||
if current_platform.device_count() < tensor_parallel_size:
|
||||
pytest.skip(reason="Not enough CUDA devices")
|
||||
|
||||
engine_args = AsyncEngineArgs(
|
||||
@@ -83,7 +83,7 @@ def test_llm_delete(
|
||||
enable_multiprocessing: enable workers in separate process(es)
|
||||
send_one_request: send one request to engine before deleting
|
||||
"""
|
||||
if cuda_device_count_stateless() < tensor_parallel_size:
|
||||
if current_platform.device_count() < tensor_parallel_size:
|
||||
pytest.skip(reason="Not enough CUDA devices")
|
||||
|
||||
with monkeypatch.context() as m:
|
||||
|
||||
@@ -15,7 +15,7 @@ from tests.v1.shutdown.utils import (
|
||||
from vllm import LLM, AsyncEngineArgs, SamplingParams
|
||||
from vllm.distributed import get_tensor_model_parallel_rank
|
||||
from vllm.model_executor.models.llama import LlamaForCausalLM
|
||||
from vllm.utils.torch_utils import cuda_device_count_stateless
|
||||
from vllm.platforms import current_platform
|
||||
from vllm.v1.engine.async_llm import AsyncLLM
|
||||
from vllm.v1.engine.exceptions import EngineDeadError
|
||||
|
||||
@@ -60,7 +60,7 @@ async def test_async_llm_model_error(
|
||||
|
||||
AsyncLLM always uses an MP client.
|
||||
"""
|
||||
if cuda_device_count_stateless() < tensor_parallel_size:
|
||||
if current_platform.device_count() < tensor_parallel_size:
|
||||
pytest.skip(reason="Not enough CUDA devices")
|
||||
|
||||
# Monkeypatch an error in the model.
|
||||
@@ -126,7 +126,7 @@ def test_llm_model_error(
|
||||
TODO(andy) - LLM without multiprocessing; LLM with multiprocessing
|
||||
and >1 rank
|
||||
"""
|
||||
if cuda_device_count_stateless() < tensor_parallel_size:
|
||||
if current_platform.device_count() < tensor_parallel_size:
|
||||
pytest.skip(reason="Not enough CUDA devices")
|
||||
|
||||
with monkeypatch.context() as m:
|
||||
|
||||
@@ -15,7 +15,7 @@ from vllm import LLM
|
||||
from vllm.distributed import get_tensor_model_parallel_rank
|
||||
from vllm.engine.arg_utils import AsyncEngineArgs
|
||||
from vllm.model_executor.models.llama import LlamaForCausalLM
|
||||
from vllm.utils.torch_utils import cuda_device_count_stateless
|
||||
from vllm.platforms import current_platform
|
||||
from vllm.v1.engine.async_llm import AsyncLLM
|
||||
|
||||
MODELS = ["hmellor/tiny-random-LlamaForCausalLM"]
|
||||
@@ -57,7 +57,7 @@ def test_async_llm_startup_error(
|
||||
Test profiling (forward()) and load weights failures.
|
||||
AsyncLLM always uses an MP client.
|
||||
"""
|
||||
if cuda_device_count_stateless() < tensor_parallel_size:
|
||||
if current_platform.device_count() < tensor_parallel_size:
|
||||
pytest.skip(reason="Not enough CUDA devices")
|
||||
|
||||
# Monkeypatch an error in the model.
|
||||
@@ -99,7 +99,7 @@ def test_llm_startup_error(
|
||||
# If MODELS list grows, each architecture needs its own test variant.
|
||||
if model != "JackFram/llama-68m":
|
||||
pytest.skip(reason="Only test JackFram/llama-68m")
|
||||
if cuda_device_count_stateless() < tensor_parallel_size:
|
||||
if current_platform.device_count() < tensor_parallel_size:
|
||||
pytest.skip(reason="Not enough CUDA devices")
|
||||
|
||||
with monkeypatch.context() as m:
|
||||
|
||||
Reference in New Issue
Block a user