From e575b5f1a967b7ebb44eb65c4a3203e269cfc54d Mon Sep 17 00:00:00 2001 From: Qiming Zhang Date: Tue, 18 Aug 2026 20:30:47 -0700 Subject: [PATCH] [XPU][CI] fix hf runner (#52730) Signed-off-by: mayuyuace --- tests/conftest.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index bc6d9cb281..53d448b9b5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -893,12 +893,15 @@ class HfRunner: return self.model.predict(prompts, *args, convert_to_tensor=True, **kwargs) def __enter__(self): - if current_platform.is_rocm(): - # Record starting memory usage stats on ROCm so that we can wait for - # memory to roughly settle back below these levels on shutdown. This is - # helpful in cases where the HfRunner is initialized after significant GPU - # memory is already occupied, e.g. in + if current_platform.is_rocm() or current_platform.is_xpu(): + # Record starting memory usage stats on ROCm/XPU so that we can + # wait for memory to roughly settle back below these levels on + # shutdown. This is helpful in cases where the HfRunner is + # initialized after significant GPU memory is already occupied, + # e.g. in # tests/basic_correctness/test_basic_correctness.py::test_models_distributed + # where vllm worker processes are still alive and holding GPU + # memory when hf_runner.__exit__ is called. from tests.utils import ( get_physical_device_indices, record_gpu_memory_usage_stats, @@ -918,8 +921,8 @@ class HfRunner: del self.model cleanup_dist_env_and_memory() - # ROCm frees VRAM lazily; wait so a runner started right after this HF - # model exits does not OOM on its startup memory guard. + # ROCm/XPU free VRAM lazily; wait so a runner started right after this + # HF model exits does not OOM on its startup memory guard. wait_for_memory_to_settle( threshold_ratio=getattr(self, "threshold_ratios", None) )