You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Still WIP but open to feedback on the API
## API Usage
```python
# LocalSGD example
model = SimpleModel()
optimizer = optim.SGD(model.parameters())
manager = create_autospec(Manager)
with LocalSGD(manager, model, optimizer, sync_every=2):
for inp, label in dataloader:
loss = model(inp).mean()
loss.backward()
optimizer.step()
# DiLoCo example
model = SimpleModel()
inner_optimizer = torch.optim.AdamW(
m.parameters(), lr=4e-4, weight_decay=0.1, betas=(0.9, 0.95)
)
outer_optimizer = torch.optim.SGD(
m.parameters(), lr=0.7, momentum=0.9, nesterov=True
)
manager = create_autospec(Manager)
with DiLoCo(manager, m, inner_optimizer, outer_optimizer, sync_every=2):
for inp, label in dataloader:
loss = model(inp).mean()
loss.backward()
inner_optimizer.step()
# outer_optimizer is used every 'sync_every' steps
```
## Changes
- Updated `LocalSGD` to be a context manager rather than a `nn.Module` wrapper. This required adding a pre_forward_hook to the model start the quorum
- Added DiLoCo. This is a subclass of LocalSGD since a lot of code is shared
- TODO: should be working, but still validating some tests
discussion doc: https://docs.google.com/document/d/11c5JwQpSzilrDvK-vNsgQhpXAihbMn-hTRC8y3LiGqY/edit?tab=t.0#heading=h.izo4yi6jz4mk
[ghstack-poisoned]
Copy file name to clipboardexpand all lines: README.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,7 @@ greatly improve efficiency by avoiding stop the world training on errors.
52
52
53
53
Before proceeding, ensure you have the following installed:
54
54
55
-
- Rust (with necessaray dependencies)
55
+
- Rust (with necessary dependencies)
56
56
-`protobuf-compiler` and the corresponding development package for Protobuf.
57
57
58
58
Note that the Rust versions available in many conda environments may be outdated. To install the latest version of Rust, we recommend downloading it directly from the official website as shown in the below command:
0 commit comments