heavyball 0.23.3__py3-none-any.whl → 0.23.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- heavyball/utils.py +11 -9
- {heavyball-0.23.3.dist-info → heavyball-0.23.4.dist-info}/METADATA +1 -1
- {heavyball-0.23.3.dist-info → heavyball-0.23.4.dist-info}/RECORD +6 -6
- {heavyball-0.23.3.dist-info → heavyball-0.23.4.dist-info}/LICENSE +0 -0
- {heavyball-0.23.3.dist-info → heavyball-0.23.4.dist-info}/WHEEL +0 -0
- {heavyball-0.23.3.dist-info → heavyball-0.23.4.dist-info}/top_level.txt +0 -0
heavyball/utils.py
CHANGED
@@ -8,9 +8,9 @@ from typing import List, Optional, Tuple, Callable, Union
|
|
8
8
|
import numpy as np
|
9
9
|
import torch
|
10
10
|
from torch import Tensor
|
11
|
+
from torch._dynamo.exc import TorchDynamoException
|
11
12
|
from torch.backends import cudnn, opt_einsum
|
12
13
|
from torch.utils._pytree import tree_map
|
13
|
-
from torch._dynamo.exc import TorchDynamoException
|
14
14
|
|
15
15
|
compile_mode = "max-autotune-no-cudagraphs"
|
16
16
|
dynamic = False
|
@@ -23,26 +23,26 @@ def decorator(func):
|
|
23
23
|
|
24
24
|
@functools.wraps(func)
|
25
25
|
def _fn(*args, **kwargs):
|
26
|
-
if compile_mode is None:
|
26
|
+
if is_compiling() or compile_mode is None:
|
27
27
|
return func(*args, **kwargs)
|
28
28
|
nonlocal compiled
|
29
29
|
if compiled is None:
|
30
|
-
compiled = torch.compile(
|
30
|
+
compiled = torch.compile(fullgraph=True, dynamic=dynamic, mode=compile_mode_recommended_to_none)(func)
|
31
31
|
return compiled(*args, **kwargs)
|
32
32
|
|
33
33
|
return _fn
|
34
34
|
|
35
35
|
|
36
|
-
def decorator_knowngood(func):
|
36
|
+
def decorator_knowngood(func: Callable):
|
37
37
|
compiled = None
|
38
38
|
|
39
39
|
@functools.wraps(func)
|
40
40
|
def _fn(*args, **kwargs):
|
41
|
-
if compile_mode is None:
|
41
|
+
if is_compiling() or compile_mode is None:
|
42
42
|
return func(*args, **kwargs)
|
43
43
|
nonlocal compiled
|
44
44
|
if compiled is None:
|
45
|
-
compiled = torch.compile(
|
45
|
+
compiled = torch.compile(fullgraph=True, dynamic=dynamic, mode=compile_mode)(func)
|
46
46
|
return compiled(*args, **kwargs)
|
47
47
|
|
48
48
|
return _fn
|
@@ -58,7 +58,8 @@ def warmup(lr: float, step: int, warmup_steps: int):
|
|
58
58
|
|
59
59
|
|
60
60
|
@decorator_knowngood
|
61
|
-
def _compilable_schedule_free_(p: List[Tensor], z: List[Tensor], ckp1: Tensor, grad: List[Tensor], lr: Tensor,
|
61
|
+
def _compilable_schedule_free_(p: List[Tensor], z: List[Tensor], ckp1: Tensor, grad: List[Tensor], lr: Tensor,
|
62
|
+
beta1: Tensor):
|
62
63
|
p32, z32, g32 = [promote(x) for x in (p, z, grad)]
|
63
64
|
for p_, z_, g_ in zip(p32, z32, g32):
|
64
65
|
p_.lerp_(z_, ckp1)
|
@@ -158,7 +159,8 @@ def beta_debias(beta, step):
|
|
158
159
|
|
159
160
|
|
160
161
|
@decorator_knowngood
|
161
|
-
def _compilable_exp_avg_sq_(state: List[Tensor], grad: List[Tensor], beta2: Tensor, eps: Tensor,
|
162
|
+
def _compilable_exp_avg_sq_(state: List[Tensor], grad: List[Tensor], beta2: Tensor, eps: Tensor,
|
163
|
+
out: List[Optional[Tensor]]):
|
162
164
|
torch._foreach_mul_(state, beta2)
|
163
165
|
[s.addcmul_(g, g, value=1 - beta2) for s, g in zip(state, grad)]
|
164
166
|
denom = torch._foreach_sqrt(state)
|
@@ -1050,7 +1052,7 @@ class PSGDBase(StatefulOptimizer):
|
|
1050
1052
|
|
1051
1053
|
|
1052
1054
|
# TODO: Figure out why this sometimes crashes
|
1053
|
-
|
1055
|
+
# @decorator_knowngood
|
1054
1056
|
def _compilable_precond_grad_cached_(ea: Tensor, expr: str, param: Tensor, lr: Tensor, weight_decay: Tensor,
|
1055
1057
|
clip_fn: callable, caution: bool, grad: Optional[Tensor], *cached_q: Tensor):
|
1056
1058
|
md = min_dtype(list(cached_q) + [ea])
|
@@ -16,9 +16,9 @@ heavyball/precond_schedule_sfpsoap.py,sha256=ey-mUIjAy9ny5vJac0vRZHUXgef1bc7u7_-
|
|
16
16
|
heavyball/psgd_kron.py,sha256=4eiGPXAFjvGIXLdiai1UJfAvTozAV1TXaE9UGkE4BLc,6051
|
17
17
|
heavyball/pure_psgd.py,sha256=344NdVNHwUFX3fU2R1S_Xh9SXAML3E4ryHr7xfMh9Cc,5076
|
18
18
|
heavyball/schedule_free_palm_foreach_soap.py,sha256=irvlIXF-oABpWWycZPMV-JG9XTiXSlgHtrM-ygfATic,7207
|
19
|
-
heavyball/utils.py,sha256=
|
20
|
-
heavyball-0.23.
|
21
|
-
heavyball-0.23.
|
22
|
-
heavyball-0.23.
|
23
|
-
heavyball-0.23.
|
24
|
-
heavyball-0.23.
|
19
|
+
heavyball/utils.py,sha256=FFZLqq_bnQUDXOMBO_hBu32yNMHi18W13wxlOJ0Q_78,39665
|
20
|
+
heavyball-0.23.4.dist-info/LICENSE,sha256=CGdGJim64YifGmUVPaeyRsxkvyExtClswhRNIp8FY_U,1322
|
21
|
+
heavyball-0.23.4.dist-info/METADATA,sha256=ebfSVWG2CeKxSfE5Ru0VipLE23DQiQKOmODVdlFW4aY,11926
|
22
|
+
heavyball-0.23.4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
23
|
+
heavyball-0.23.4.dist-info/top_level.txt,sha256=SzCxSVg_qCUPA4kZObW3Zyo4v-d_mMOD-p7a-WXTl2E,10
|
24
|
+
heavyball-0.23.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|