Skip to content

Commit

Permalink
remove length printing
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessandro Sordoni committed Aug 5, 2024
1 parent d724f20 commit c7fd876
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion mttl/models/expert_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def forward(self, batch, reduction="mean"):
input_ids = batch["input_ids"]
labels = batch["labels"]

print(input_ids.shape[-1])
outputs = self.model.forward(input_ids, attention_mask=batch["attention_mask"])

# calculate loss, could also be done inside of the model
Expand Down Expand Up @@ -153,6 +152,18 @@ def training_step(self, batch, _):
f"{self._log_pref}train/total_loss", total_loss, on_step=True, prog_bar=True
)

# get peak and avg memory
peak_memory = torch.cuda.max_memory_allocated() / 1024**3
memory = torch.cuda.memory_allocated() / 1024**3

self.log(
f"{self._log_pref}train/peak_memory",
peak_memory,
on_step=True,
prog_bar=True,
)
self.log(f"{self._log_pref}train/memory", memory, on_step=True, prog_bar=True)

for i, pg in enumerate(self.optimizers().optimizer.param_groups):
self.log(f"train/lr_{i}", pg["lr"])
return total_loss
Expand Down

0 comments on commit c7fd876

Please sign in to comment.