Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions ScaFFold/utils/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,19 @@ def setup_training_components(self):
"""Set up the optimizer, scheduler, gradient scaler, and loss function."""
# Set up optimizer
if self.config.optimizer == "ADAM":
self.log.info("Using ADAM optimizer.")
# Fused Adam does the whole update in one kernel; parameters are
# replicated, so this is the one cost spatial sharding does not
# shrink. CUDA only: the fused kernels are device-specific. Fused
# and foreach accumulate in different orders, so the two are not
# bitwise comparable; each is reproducible with itself, including
# across checkpoint/resume (the fused path keeps ``step`` on the
# device).
fused = self.device.type == "cuda"
self.log.info(f"Using ADAM optimizer{' (fused)' if fused else ''}.")
self.optimizer = optim.Adam(
self.model.parameters(), lr=self.config.starting_learning_rate
self.model.parameters(),
lr=self.config.starting_learning_rate,
fused=fused,
)
elif self.config.optimizer == "SGD":
self.log.info("Using SGD optimizer.")
Expand Down
Loading