Skip to content

Commit 2fe9a70

Browse files
authored
[QLoRA][FSDP2] check is_fbcode before checking torchao version (#1074)
1 parent 0e0aff0 commit 2fe9a70

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

torchtune/modules/low_precision/_register_nf4_dispatch_ops.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
from torchao.dtypes.nf4tensor import implements as nf4_tensor_impl, to_nf4
1111

1212

13+
def is_fbcode():
14+
return not hasattr(torch.version, "git_version")
15+
16+
1317
@nf4_tensor_impl([torch.ops.aten.clone.default])
1418
def clone(func, *args, **kwargs):
1519
"""
@@ -21,7 +25,7 @@ def clone(func, *args, **kwargs):
2125
return to_nf4(args[0][0].get_original_weight())
2226

2327

24-
if version("torchao") < "0.2.0":
28+
if is_fbcode() or version("torchao") < "0.2.0":
2529
# TorchAO have `NF4.copy_` starting from `0.2.0`
2630
# it's a superset of `inplace_copy` since it covers `NF4.copy_(NF4)`
2731
@nf4_tensor_impl([torch.ops.aten.copy_.default])

0 commit comments

Comments
 (0)