enable misc cases on XPU & use device agnostic APIs for cases in tests (#38192)
* use device agnostic APIs in tests Signed-off-by: Matrix Yao <matrix.yao@intel.com> * more Signed-off-by: Matrix Yao <matrix.yao@intel.com> * fix style Signed-off-by: Matrix Yao <matrix.yao@intel.com> * add reset_peak_memory_stats API Signed-off-by: YAO Matrix <matrix.yao@intel.com> * update --------- Signed-off-by: Matrix Yao <matrix.yao@intel.com> Signed-off-by: YAO Matrix <matrix.yao@intel.com> Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
@@ -73,6 +73,7 @@ from transformers.models.auto.modeling_auto import (
|
||||
)
|
||||
from transformers.testing_utils import (
|
||||
CaptureLogger,
|
||||
backend_empty_cache,
|
||||
get_device_properties,
|
||||
hub_retry,
|
||||
is_flaky,
|
||||
@@ -2652,7 +2653,7 @@ class ModelTesterMixin:
|
||||
config = self.model_tester.get_large_model_config()
|
||||
|
||||
for model_class in self.all_parallelizable_model_classes:
|
||||
torch.cuda.empty_cache()
|
||||
backend_empty_cache(torch_device)
|
||||
|
||||
# 1. single gpu memory load + unload + memory measurements
|
||||
# Retrieve initial memory usage (can easily be ~0.6-1.5GB if cuda-kernels have been preloaded by previous tests)
|
||||
@@ -2668,7 +2669,7 @@ class ModelTesterMixin:
|
||||
|
||||
del model
|
||||
gc.collect()
|
||||
torch.cuda.empty_cache()
|
||||
backend_empty_cache(torch_device)
|
||||
|
||||
# 2. MP test
|
||||
# it's essential to re-calibrate the usage before the next stage
|
||||
@@ -2692,7 +2693,7 @@ class ModelTesterMixin:
|
||||
|
||||
del model
|
||||
gc.collect()
|
||||
torch.cuda.empty_cache()
|
||||
backend_empty_cache(torch_device)
|
||||
|
||||
@require_torch_gpu
|
||||
@require_torch_multi_gpu
|
||||
|
||||
Reference in New Issue
Block a user