[ROCm][CI] Solidify entrypoint LLM lifecycle (#51280)
Signed-off-by: Andreas Karatzas <Andreas.Karatzas@amd.com> Signed-off-by: Andreas Karatzas <akaratza@amd.com>
This commit is contained in:
@@ -8,13 +8,13 @@ actual NCCL communication.
|
||||
"""
|
||||
|
||||
import os
|
||||
import weakref
|
||||
from dataclasses import dataclass
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
|
||||
from vllm import LLM
|
||||
from vllm.config import WeightTransferConfig
|
||||
from vllm.distributed.weight_transfer.base import (
|
||||
WeightTransferEngine,
|
||||
@@ -102,25 +102,24 @@ def mock_create_engine(config, vllm_config, device, model):
|
||||
|
||||
|
||||
@create_new_process_for_each_test()
|
||||
def test_get_world_size_tp1():
|
||||
def test_get_world_size_tp1(vllm_runner):
|
||||
"""Test world_size is correctly configured for TP=1."""
|
||||
if torch.accelerator.device_count() < 1:
|
||||
pytest.skip("Need at least 1 GPU for this test")
|
||||
|
||||
llm = LLM(
|
||||
model=MODEL_NAME,
|
||||
with vllm_runner(
|
||||
MODEL_NAME,
|
||||
enforce_eager=True,
|
||||
load_format="dummy",
|
||||
tensor_parallel_size=1,
|
||||
weight_transfer_config=WeightTransferConfig(backend="nccl"),
|
||||
)
|
||||
|
||||
world_size = llm.llm_engine.vllm_config.parallel_config.world_size
|
||||
assert world_size == 1
|
||||
) as runner:
|
||||
world_size = runner.llm.llm_engine.vllm_config.parallel_config.world_size
|
||||
assert world_size == 1
|
||||
|
||||
|
||||
@create_new_process_for_each_test()
|
||||
def test_init_weight_transfer_engine_calls_engine():
|
||||
def test_init_weight_transfer_engine_calls_engine(vllm_runner):
|
||||
"""Test that init_weight_transfer_engine calls the engine's
|
||||
init_transfer_engine method."""
|
||||
if torch.accelerator.device_count() < 1:
|
||||
@@ -131,17 +130,20 @@ def test_init_weight_transfer_engine_calls_engine():
|
||||
# Enable insecure serialization to allow pickling functions for collective_rpc
|
||||
os.environ["VLLM_ALLOW_INSECURE_SERIALIZATION"] = "1"
|
||||
|
||||
with patch(
|
||||
"vllm.v1.worker.gpu_worker.WeightTransferEngineFactory.create_engine",
|
||||
mock_create_engine,
|
||||
):
|
||||
llm = LLM(
|
||||
model=MODEL_NAME,
|
||||
with (
|
||||
patch(
|
||||
"vllm.v1.worker.gpu_worker.WeightTransferEngineFactory.create_engine",
|
||||
mock_create_engine,
|
||||
),
|
||||
vllm_runner(
|
||||
MODEL_NAME,
|
||||
enforce_eager=True,
|
||||
load_format="dummy",
|
||||
tensor_parallel_size=1,
|
||||
weight_transfer_config=WeightTransferConfig(backend="nccl"),
|
||||
)
|
||||
) as runner,
|
||||
):
|
||||
llm = weakref.proxy(runner.llm)
|
||||
|
||||
# Verify engine was created
|
||||
def check_engine_exists(self):
|
||||
@@ -170,7 +172,7 @@ def test_init_weight_transfer_engine_calls_engine():
|
||||
|
||||
|
||||
@create_new_process_for_each_test()
|
||||
def test_update_weights_calls_engine():
|
||||
def test_update_weights_calls_engine(vllm_runner):
|
||||
"""Test that update_weights calls the engine's receive_weights method."""
|
||||
if torch.accelerator.device_count() < 1:
|
||||
pytest.skip("Need at least 1 GPU for this test")
|
||||
@@ -180,17 +182,20 @@ def test_update_weights_calls_engine():
|
||||
# Enable insecure serialization to allow pickling functions for collective_rpc
|
||||
os.environ["VLLM_ALLOW_INSECURE_SERIALIZATION"] = "1"
|
||||
|
||||
with patch(
|
||||
"vllm.v1.worker.gpu_worker.WeightTransferEngineFactory.create_engine",
|
||||
mock_create_engine,
|
||||
):
|
||||
llm = LLM(
|
||||
model=MODEL_NAME,
|
||||
with (
|
||||
patch(
|
||||
"vllm.v1.worker.gpu_worker.WeightTransferEngineFactory.create_engine",
|
||||
mock_create_engine,
|
||||
),
|
||||
vllm_runner(
|
||||
MODEL_NAME,
|
||||
enforce_eager=True,
|
||||
load_format="dummy",
|
||||
tensor_parallel_size=1,
|
||||
weight_transfer_config=WeightTransferConfig(backend="nccl"),
|
||||
)
|
||||
) as runner,
|
||||
):
|
||||
llm = weakref.proxy(runner.llm)
|
||||
|
||||
# First init the weight transfer
|
||||
llm.init_weight_transfer_engine(
|
||||
@@ -233,7 +238,7 @@ def test_update_weights_calls_engine():
|
||||
|
||||
|
||||
@create_new_process_for_each_test()
|
||||
def test_full_weight_transfer_flow():
|
||||
def test_full_weight_transfer_flow(vllm_runner):
|
||||
"""Test the complete weight transfer flow: init -> start -> update -> finish."""
|
||||
if torch.accelerator.device_count() < 1:
|
||||
pytest.skip("Need at least 1 GPU for this test")
|
||||
@@ -243,17 +248,20 @@ def test_full_weight_transfer_flow():
|
||||
# Enable insecure serialization to allow pickling functions for collective_rpc
|
||||
os.environ["VLLM_ALLOW_INSECURE_SERIALIZATION"] = "1"
|
||||
|
||||
with patch(
|
||||
"vllm.v1.worker.gpu_worker.WeightTransferEngineFactory.create_engine",
|
||||
mock_create_engine,
|
||||
):
|
||||
llm = LLM(
|
||||
model=MODEL_NAME,
|
||||
with (
|
||||
patch(
|
||||
"vllm.v1.worker.gpu_worker.WeightTransferEngineFactory.create_engine",
|
||||
mock_create_engine,
|
||||
),
|
||||
vllm_runner(
|
||||
MODEL_NAME,
|
||||
enforce_eager=True,
|
||||
load_format="dummy",
|
||||
tensor_parallel_size=1,
|
||||
weight_transfer_config=WeightTransferConfig(backend="nccl"),
|
||||
)
|
||||
) as runner,
|
||||
):
|
||||
llm = weakref.proxy(runner.llm)
|
||||
|
||||
assert llm.get_weight_version() == "default"
|
||||
|
||||
@@ -309,20 +317,19 @@ def test_full_weight_transfer_flow():
|
||||
|
||||
|
||||
@create_new_process_for_each_test()
|
||||
def test_weight_transfer_config_backend():
|
||||
def test_weight_transfer_config_backend(vllm_runner):
|
||||
"""Test that WeightTransferConfig backend is properly configured."""
|
||||
if torch.accelerator.device_count() < 1:
|
||||
pytest.skip("Need at least 1 GPU for this test")
|
||||
|
||||
# Test with nccl backend
|
||||
llm = LLM(
|
||||
model=MODEL_NAME,
|
||||
with vllm_runner(
|
||||
MODEL_NAME,
|
||||
enforce_eager=True,
|
||||
load_format="dummy",
|
||||
tensor_parallel_size=1,
|
||||
weight_transfer_config=WeightTransferConfig(backend="nccl"),
|
||||
)
|
||||
|
||||
config = llm.llm_engine.vllm_config.weight_transfer_config
|
||||
assert config is not None
|
||||
assert config.backend == "nccl"
|
||||
) as runner:
|
||||
config = runner.llm.llm_engine.vllm_config.weight_transfer_config
|
||||
assert config is not None
|
||||
assert config.backend == "nccl"
|
||||
|
||||
Reference in New Issue
Block a user