Skip to content

Commit 3709f1d

Browse files
authored
Update fabric_methods.rst
1 parent e09941c commit 3709f1d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

docs/source-fabric/api/fabric_methods.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,17 @@ Moves the model and optimizer to the correct device automatically.
4040
4141
model = nn.Linear(32, 64)
4242
optimizer = torch.optim.SGD(model.parameters(), lr=0.001)
43+
scheduler = torch.optim.lr_scheduler.LinearLR(optimizer, start_factor=1.0, end_factor=0.3, total_iters=10)
4344
4445
# Set up model and optimizer for accelerated training
4546
model, optimizer = fabric.setup(model, optimizer)
4647
4748
# If you don't want Fabric to set the device
4849
model, optimizer = fabric.setup(model, optimizer, move_to_device=False)
4950
51+
# If you want to additionally register a learning rate scheduler with compatible strategies such as DeepSpeed
52+
model, optimizer, scheduler = fabric.setup(model, optimizer, scheduler)
53+
5054
5155
The setup method also prepares the model for the selected precision choice so that operations during ``forward()`` get
5256
cast automatically. Advanced users should read :doc:`the notes on models wrapped by Fabric <../api/wrappers>`.

0 commit comments

Comments
 (0)