Skip to content

Commit cc3dc4b

Browse files
committed
fix: add custom loop and docs
Signed-off-by: Mehant Kammakomati <mehant.kammakomati2@ibm.com>
1 parent df70edf commit cc3dc4b

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

plugins/online-data-mixing/artifacts/custom_loop_usage.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ class State:
9595
if step_idx % 1 == 0:
9696
if torch.isnan(loss):
9797
loss = torch.tensor([10]) # nan -> very high loss
98-
print(f"Step {step_idx} ||| Loss: {loss.item():.4f}")
98+
if accelerator.is_main_process:
99+
print(f"Step {step_idx} ||| Loss: {loss.item():.4f}")
99100
state.log_history.append(
100101
{"loss": loss.item() if not torch.isnan(loss) else 1e100}
101102
)
102103
if step_idx % update_interval == 0:
103104
dataloader.dataset.update_sampling_weights(model, accelerator, state)
104-
max_steps -= 1
105-
if max_steps == 0:
105+
if step_idx > max_steps:
106106
break
107107

108108
print("training completed!")

0 commit comments

Comments
 (0)