support bitsandbytes 8-bit and FP4 quantized models (#7445)

This commit is contained in:
chenqianfzh
2024-08-29 19:09:08 -04:00
committed by GitHub
parent 257afc37c5
commit 4664ceaad6
6 changed files with 435 additions and 189 deletions
+6
View File
@@ -209,8 +209,14 @@ class HfRunner:
def wrap_device(self, input: _T) -> _T:
if not is_cpu():
# Check if the input is already on the GPU
if hasattr(input, 'device') and input.device.type == "cuda":
return input # Already on GPU, no need to move
return input.to("cuda")
else:
# Check if the input is already on the CPU
if hasattr(input, 'device') and input.device.type == "cpu":
return input # Already on CPU, no need to move
return input.to("cpu")
def __init__(