Skip to content

Commit 0060dd9

Browse files
bug fix
1 parent 47d39f2 commit 0060dd9

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

optimi/optimizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __init__(self, params: Iterable[Tensor] | Iterable[dict], defaults: dict[str
4646

4747
if not MIN_TORCH_2_6 and defaults.get("triton", False):
4848
raise ValueError(f"triton={defaults['triton']} requires PyTorch 2.6 or later. Set triton=False or upgrade PyTorch.")
49-
elif not HAS_TRITON and defaults.get("triton", False):
49+
if not HAS_TRITON and defaults.get("triton", False):
5050
raise ImportError("Triton could not be imported on this system. Set triton=False or install Triton.")
5151

5252
super().__init__(params, defaults)

optimi/utils.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
MIN_TORCH_2_1 = parse(torch.__version__) >= parse("2.1")
2121
MIN_TORCH_2_6 = parse(torch.__version__) >= parse("2.6")
22+
HAS_TRITON = HAS_TRITON and MIN_TORCH_2_6
2223

2324

2425
def debias(beta: float, step: int) -> float:
@@ -94,13 +95,9 @@ def _default_to_triton(params: list[torch.Tensor]) -> tuple[bool, bool]:
9495
if torch.jit.is_scripting():
9596
return False
9697

97-
triton = (
98-
MIN_TORCH_2_6
99-
and HAS_TRITON
100-
and all(
101-
p is None or (type(p) in _foreach_supported_types and _triton_kernels_supported_device(p) and torch.is_floating_point(p))
102-
for p in params
103-
)
98+
triton = HAS_TRITON and all(
99+
p is None or (type(p) in _foreach_supported_types and _triton_kernels_supported_device(p) and torch.is_floating_point(p))
100+
for p in params
104101
)
105102
return triton
106103

0 commit comments

Comments
 (0)