Skip to content

Commit 4f91dd9

Browse files
authored
feat: Add support for compute capability 12.1 (Grace Blackwell) (#785)
1 parent 6282fda commit 4f91dd9

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

nunchaku/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def get_precision(
219219
device = torch.device(device)
220220
capability = torch.cuda.get_device_capability(0 if device.index is None else device.index)
221221
sm = f"{capability[0]}{capability[1]}"
222-
precision = "fp4" if sm == "120" else "int4"
222+
precision = "fp4" if sm in ["120", "121"] else "int4"
223223
if pretrained_model_name_or_path is not None:
224224
if precision == "int4":
225225
if "fp4" in str(pretrained_model_name_or_path):
@@ -305,7 +305,7 @@ def check_hardware_compatibility(quantization_config: dict, device: str | torch.
305305
device = torch.device(device)
306306
capability = torch.cuda.get_device_capability(0 if device.index is None else device.index)
307307
sm = f"{capability[0]}{capability[1]}"
308-
if sm == "120": # you can only use the fp4 models
308+
if sm in ["120", "121"]: # you can only use the fp4 models
309309
if quantization_config["weight"]["dtype"] != "fp4_e2m1_all":
310310
raise ValueError('Please use "fp4" quantization for Blackwell GPUs. ')
311311
elif sm in ["75", "80", "86", "89"]:

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,16 @@ def get_sm_targets() -> list[str]:
4646
for i in range(torch.cuda.device_count()):
4747
capability = torch.cuda.get_device_capability(i)
4848
sm = f"{capability[0]}{capability[1]}"
49-
if sm == "120" and support_sm120:
50-
sm = "120a"
51-
assert sm in ["75", "80", "86", "89", "120a"], f"Unsupported SM {sm}"
49+
if sm in ["120", "121"] and support_sm120:
50+
sm = sm + "a"
51+
assert sm in ["75", "80", "86", "89", "120a", "121a"], f"Unsupported SM {sm}"
5252
if sm not in ret:
5353
ret.append(sm)
5454
else:
5555
assert install_mode == "ALL"
5656
ret = ["75", "80", "86", "89"]
5757
if support_sm120:
58-
ret.append("120a")
58+
ret.extend(["120a", "121a"])
5959
return ret
6060

6161

0 commit comments

Comments
 (0)