Skip to content

Commit d05c6c1

Browse files
authored
Merge pull request #12 from Belilovsky-Lab/xiao_elo
Add learned optimizers meta-trianed with ELO
2 parents 7905428 + dd899e7 commit d05c6c1

23 files changed

Lines changed: 3338 additions & 12 deletions

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ wandb
88
mup
99
_build
1010
dist
11-
snippets
11+
snippets
12+
# Learned-optimizer checkpoints (hosted on the Hugging Face Hub)
13+
*.pickle

README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ PyLO provides efficient PyTorch implementations of cutting-edge learned optimize
1717
- **PyTorch-native API** designed for simplicity and familiarity
1818
- **Hugging Face integration** for sharing and loading meta-models
1919

20+
Learned optimizers:
21+
* ELO series: [https://arxiv.org/abs/2506.10315](https://arxiv.org/abs/2506.10315)
22+
2023
# Installation
2124

2225
### Via URL (slow, no Kernels)
@@ -72,22 +75,28 @@ python -m pylo.util.patch_mup
7275

7376
## Quick Start
7477

78+
Taking `ELO-CELO2` (the strongest LO) for example.
79+
7580
```python
7681
import torch
77-
from pylo.optim import VeLO_CUDA
82+
from pylo.optim import ELO_CELO2_CUDA
7883

79-
# Initialize a model
8084
model = torch.nn.Linear(10, 2)
8185

82-
# Create a learned optimizer instance
83-
optimizer = VeLO_CUDA(model.parameters())
86+
num_steps = 1000 # total optimization steps
87+
88+
# Meta-learned weights download automatically from the Hugging Face Hub on first use.
89+
# The optimizer has no built-in LR schedule; drive it with a standard
90+
# torch.optim.lr_scheduler (warmup, cosine, etc.).
91+
optimizer = ELO_CELO2_CUDA(model.parameters(), lr=3.16e-4, weight_decay=0.1, adam_lr_mult=20)
92+
scheduler = torch.optim.lr_scheduler.CosineAnnealingLR(optimizer, T_max=num_steps, eta_min=3.16e-5)
8493

85-
# Use it like any PyTorch optimizer
86-
for epoch in range(10):
94+
for step in range(num_steps):
8795
optimizer.zero_grad()
8896
loss = loss_fn(model(input), target)
8997
loss.backward()
90-
optimizer.step(loss) # pass the loss
98+
optimizer.step()
99+
scheduler.step()
91100
```
92101

93102
## Sharing Learned Optimizers

pylo/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@
55
"MetaMLP",
66
"VeLOMLP",
77
"VeLORNN",
8+
"CELO2MLP",
89
"AdafacLO_naive",
910
"MuLO_naive",
1011
"VeLO_naive",
12+
"CELO2_naive",
13+
"ELO_CELO2_naive",
14+
"ELO_naive",
15+
"CELO2",
16+
"ELO_CELO2",
17+
"ELO",
1118
# Default aliases (re-exported from pylo.optim). These resolve to the
1219
# CUDA implementations when available, falling back to the naive ones
1320
# otherwise, so downstream code can simply `from pylo import VeLO`.

0 commit comments

Comments
 (0)