Skip to content
Closed
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
4 changes: 2 additions & 2 deletions torchtitan/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def forward_backward_step(
with self.maybe_enable_amp:
pred = model_parts[0](inputs, eos_id=self.tokenizer.eos_id)
loss = self.loss_fn(pred, labels)
# need to free to before bwd to avoid peaking memory
# need to free pred before bwd to avoid peaking memory
del pred
loss.backward()

Expand All @@ -471,7 +471,7 @@ def train_step(
accumulated_losses = []
# If data runs out during gradient accumulation, that
# entire step will not be executed.
for microbatch in range(self.gradient_accumulation_steps):
for _microbatch in range(self.gradient_accumulation_steps):
input_dict, labels = next(data_iterator)
loss = self.forward_backward_step(input_dict, labels)
accumulated_losses.append(loss.detach())
Expand Down