[XPU][CI] fix hf runner (#52730)

Signed-off-by: mayuyuace <qiming1.zhang@intel.com>
This commit is contained in:
Qiming Zhang
2026-08-19 11:30:47 +08:00
committed by GitHub
parent deeeae75d0
commit e575b5f1a9
+10 -7
View File
@@ -893,12 +893,15 @@ class HfRunner:
return self.model.predict(prompts, *args, convert_to_tensor=True, **kwargs) return self.model.predict(prompts, *args, convert_to_tensor=True, **kwargs)
def __enter__(self): def __enter__(self):
if current_platform.is_rocm(): if current_platform.is_rocm() or current_platform.is_xpu():
# Record starting memory usage stats on ROCm so that we can wait for # Record starting memory usage stats on ROCm/XPU so that we can
# memory to roughly settle back below these levels on shutdown. This is # wait for memory to roughly settle back below these levels on
# helpful in cases where the HfRunner is initialized after significant GPU # shutdown. This is helpful in cases where the HfRunner is
# memory is already occupied, e.g. in # initialized after significant GPU memory is already occupied,
# e.g. in
# tests/basic_correctness/test_basic_correctness.py::test_models_distributed # 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 ( from tests.utils import (
get_physical_device_indices, get_physical_device_indices,
record_gpu_memory_usage_stats, record_gpu_memory_usage_stats,
@@ -918,8 +921,8 @@ class HfRunner:
del self.model del self.model
cleanup_dist_env_and_memory() cleanup_dist_env_and_memory()
# ROCm frees VRAM lazily; wait so a runner started right after this HF # ROCm/XPU free VRAM lazily; wait so a runner started right after this
# model exits does not OOM on its startup memory guard. # HF model exits does not OOM on its startup memory guard.
wait_for_memory_to_settle( wait_for_memory_to_settle(
threshold_ratio=getattr(self, "threshold_ratios", None) threshold_ratio=getattr(self, "threshold_ratios", None)
) )