Repository: huggingface/transformers
Pull request: rename get_cuda_warm_up_factor to get_accelerator_warm_up_factor

since hfquantizer now supports XPU too, so change `get_cuda_warm_up_factor` to a more device agnostic naming `get_accelerator_warm_up_factor`. 

@Rocketknight1 , pls help review, thx very much.

Changed files:
filename: src/transformers/modeling_utils.py
patch: @@ -6202,7 +6202,7 @@ def caching_allocator_warmup(model: PreTrainedModel, expanded_device_map: dict,
     - Loading speed bottleneck is now almost only tensor copy (i.e. changing the dtype) and moving the tensors to the devices.
     However, we cannot really improve on those aspects obviously, as the data needs to be moved/copied in the end.
     """
-    factor = 2 if hf_quantizer is None else hf_quantizer.get_cuda_warm_up_factor()
+    factor = 2 if hf_quantizer is None else hf_quantizer.get_accelerator_warm_up_factor()
 
     # Remove disk, cpu and meta devices, and cast to proper torch.device
     accelerator_device_map = {

filename: src/transformers/quantizers/base.py
patch: @@ -280,9 +280,9 @@ def dequantize(self, model):
 
         return model
 
-    def get_cuda_warm_up_factor(self):
+    def get_accelerator_warm_up_factor(self):
         """
-        The factor to be used in `caching_allocator_warmup` to get the number of bytes to pre-allocate to warm up cuda.
+        The factor to be used in `caching_allocator_warmup` to get the number of bytes to pre-allocate to warm up accelerator.
         A factor of 2 means we allocate all bytes in the empty model (since we allocate in fp16), a factor of 4 means
         we allocate half the memory of the weights residing in the empty model, etc...
         """

filename: src/transformers/quantizers/quantizer_finegrained_fp8.py
patch: @@ -59,8 +59,9 @@ def validate_environment(self, *args, **kwargs):
         device_map = kwargs.get("device_map")
         if device_map is None:
             logger.warning_once(
-                "You have loaded an FP8 model on CPU and have a CUDA device available, make sure to set "
-                "your model on a GPU device in order to run your model. To remove this warning, pass device_map = 'cuda'. "
+                "You have loaded an FP8 model on CPU and have a CUDA or XPU device available, make sure to set "
+                "your model on a GPU or XPU device in order to run your model. To remove this warning, "
+                "pass device_map = 'cuda' or 'xpu'. "
             )
         elif device_map is not None:
             if (
@@ -227,6 +228,6 @@ def is_serializable(self, safe_serialization=None):
     def is_trainable(self) -> bool:
         return False
 
-    def get_cuda_warm_up_factor(self):
+    def get_accelerator_warm_up_factor(self):
         # Pre-processing is done cleanly, so we can allocate everything here
         return 2

filename: src/transformers/quantizers/quantizer_torchao.py
patch: @@ -314,9 +314,9 @@ def is_serializable(self, safe_serialization=None) -> bool:
             return False
         return _is_torchao_serializable
 
-    def get_cuda_warm_up_factor(self):
+    def get_accelerator_warm_up_factor(self):
         """
-        This factor is used in caching_allocator_warmup to determine how many bytes to pre-allocate for CUDA warmup.
+        This factor is used in caching_allocator_warmup to determine how many bytes to pre-allocate for accelerator warmup.
         - A factor of 2 means we pre-allocate the full memory footprint of the model.
         - A factor of 4 means we pre-allocate half of that, and so on