[CI][Test] Add NPU nightly tests (#3480)
Signed-off-by: gcanlin <canlinguosdu@gmail.com>
This commit is contained in:
1 parent
56ca7dd612
commit
0ab1d30056
9 files changed
+513
-178
No files matched your search
@@ -4,6 +4,7 @@ import base64
|
||||
import concurrent.futures
|
||||
import copy
|
||||
import errno
|
||||
import gc
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
@@ -26,8 +27,11 @@ import torch
|
||||
import yaml
|
||||
from openai import APIError, OpenAI, omit
|
||||
from PIL import Image
|
||||
from vllm import TextPrompt
|
||||
from vllm.distributed.parallel_state import cleanup_dist_env_and_memory
|
||||
from vllm import TextPrompt, envs
|
||||
from vllm.distributed.parallel_state import (
|
||||
destroy_distributed_environment,
|
||||
destroy_model_parallel,
|
||||
)
|
||||
from vllm.logger import init_logger
|
||||
|
||||
from tests.helpers.assertions import (
|
||||
@@ -49,6 +53,39 @@ from vllm_omni.platforms import current_omni_platform
|
||||
logger = init_logger(__name__)
|
||||
|
||||
|
||||
def cleanup_dist_env_and_memory(shutdown_ray: bool = False):
|
||||
# Reset environment variable cache
|
||||
envs.disable_envs_cache()
|
||||
|
||||
# Reset rocm_aiter_ops class variables to match current os.environ.
|
||||
# These are class-level attributes that persist across tests and are
|
||||
# NOT restored by monkeypatch (which only restores os.environ).
|
||||
from vllm_omni.platforms import current_omni_platform
|
||||
|
||||
if current_omni_platform.is_rocm():
|
||||
from vllm._aiter_ops import rocm_aiter_ops
|
||||
|
||||
rocm_aiter_ops.refresh_env_variables()
|
||||
|
||||
# Ensure all objects are not frozen before cleanup
|
||||
gc.unfreeze()
|
||||
|
||||
destroy_model_parallel()
|
||||
destroy_distributed_environment()
|
||||
if shutdown_ray:
|
||||
import ray # Lazy import Ray
|
||||
|
||||
ray.shutdown()
|
||||
gc.collect()
|
||||
|
||||
if not current_omni_platform.is_cpu():
|
||||
current_omni_platform.empty_cache()
|
||||
try:
|
||||
torch._C._host_emptyCache()
|
||||
except AttributeError:
|
||||
logger.warning("torch._C._host_emptyCache() only available in Pytorch >=2.5")
|
||||
|
||||
|
||||
def _split_request_config_by_per_output_sizes(cfg: dict[str, Any]) -> list[dict[str, Any]] | None:
|
||||
"""If ``extra_body`` has list ``height``/``width``, return one config per index (scalar h/w, ``num_outputs_per_prompt=1``)."""
|
||||
eb = cfg.get("extra_body")
|
||||
@@ -88,13 +125,6 @@ PromptAudioInput = list[tuple[Any, int]] | tuple[Any, int] | None
|
||||
PromptImageInput = list[Any] | Any | None
|
||||
PromptVideoInput = list[Any] | Any | None
|
||||
|
||||
try:
|
||||
from vllm.distributed.parallel_state import cleanup_dist_env_and_memory # type: ignore
|
||||
except Exception: # pragma: no cover
|
||||
|
||||
def cleanup_dist_env_and_memory() -> None:
|
||||
return None
|
||||
|
||||
|
||||
def get_open_port(host: str = "127.0.0.1", *, max_attempts: int = 128) -> int:
|
||||
"""Return a local TCP port that is suitable for binding a new listener.
|
||||
|
||||
Reference in new issue
Block a user