Skip to content

Commit 70ec57a

Browse files
committed
fix: preserve base lr without warmup
1 parent d999ddc commit 70ec57a

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/f5_tts/model/trainer.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -925,11 +925,16 @@ def train(self, train_dataset: Dataset, num_workers=16, resumable_with_seed: int
925925
# otherwise by default with split_batches=False, warmup steps change with num_processes
926926
total_updates = math.ceil(len(train_dataloader) / self.grad_accumulation_steps) * self.epochs
927927
decay_updates = total_updates - warmup_updates
928-
warmup_scheduler = LinearLR(self.optimizer, start_factor=1e-8, end_factor=1.0, total_iters=warmup_updates)
929928
decay_scheduler = LinearLR(self.optimizer, start_factor=1.0, end_factor=1e-8, total_iters=decay_updates)
930-
self.scheduler = SequentialLR(
931-
self.optimizer, schedulers=[warmup_scheduler, decay_scheduler], milestones=[warmup_updates]
932-
)
929+
if warmup_updates > 0:
930+
warmup_scheduler = LinearLR(self.optimizer, start_factor=1e-8, end_factor=1.0, total_iters=warmup_updates)
931+
self.scheduler = SequentialLR(
932+
self.optimizer, schedulers=[warmup_scheduler, decay_scheduler], milestones=[warmup_updates]
933+
)
934+
else:
935+
# Torch 2.5 leaves the optimizer at the warmup start factor when a
936+
# zero-length scheduler is included in SequentialLR.
937+
self.scheduler = decay_scheduler
933938
if self.global_masked_mean:
934939
# Buffer accumulation windows on the host. A normally prepared
935940
# dataloader places each yielded batch on the accelerator, which

0 commit comments

Comments
 (0)