From 021006e1b00f0ee325e9e17d99985dac7abdc755 Mon Sep 17 00:00:00 2001 From: Josh Marshall Date: Wed, 26 Mar 2025 11:18:08 -0400 Subject: [PATCH] Fix removing "cpu" from frozenset in bitsandbytes.py to allow better ROCm support. (#36975) * Fix removing "cpu" from frozenset in bitsandbytes.py to allow better ROCm support. Related to https://github.com/bitsandbytes-foundation/bitsandbytes/issues/1573 and https://github.com/huggingface/transformers/issues/36949 , this resolves a bug in allowing ROCm/HIP support in bitsandbytes. * Related to bitsandbytes-foundation/bitsandbytes#1573 and huggingface#36949 , this resolves a bug in the biteandbytes integration, allowing ROCm/HIP support in bitsandbytes. --------- Co-authored-by: Mohamed Mekkouri <93391238+MekkCyber@users.noreply.github.com> --- src/transformers/integrations/bitsandbytes.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/transformers/integrations/bitsandbytes.py b/src/transformers/integrations/bitsandbytes.py index 61e9f8d8db..3973dc58c0 100644 --- a/src/transformers/integrations/bitsandbytes.py +++ b/src/transformers/integrations/bitsandbytes.py @@ -496,7 +496,9 @@ def _validate_bnb_multi_backend_availability(raise_exception): "You have Intel IPEX installed but if you're intending to use it for CPU, it might not have the right version. Be sure to double check that your PyTorch and IPEX installs are compatible." ) - available_devices.discard("cpu") # Only Intel CPU is supported by BNB at the moment + available_devices = frozenset( + [device for device in available_devices if device != "cpu"] + ) # Only Intel CPU is supported by BNB at the moment if not available_devices.intersection(bnb_supported_devices): if raise_exception: