Skip to content

Commit

Permalink
🎨 Fix formatting for trainer utils
Browse files Browse the repository at this point in the history
Signed-off-by: gkumbhat <[email protected]>
  • Loading branch information
gkumbhat committed Sep 27, 2023
1 parent c9852cd commit b1f4d81
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions caikit_nlp/toolkit/trainer_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@
# Standard
from datetime import datetime

# First Party
import alog

# Third Party
import torch

# First Party
import alog

log = alog.use_channel("TRNR_UTILS")


def log_step(state, logs):
if state.epoch is not None:
logs["epoch"] = round(state.epoch, 2)


# Get Rank
if torch.distributed.is_initialized():
rank = torch.distributed.get_rank()
Expand All @@ -40,18 +40,15 @@ def log_step(state, logs):

log.debug(
"process rank: {} loss: {} step: {}".format(
rank,
float(logs['loss']),
state.global_step
rank, float(logs["loss"]), state.global_step
)

)
output = {
"epoch": float(logs["epoch"]),
"step": state.global_step,
"value": float(logs["loss"]),
"timestamp": datetime.isoformat(datetime.now()),
}
output = {
"epoch": float(logs["epoch"]),
"step": state.global_step,
"value": float(logs["loss"]),
"timestamp": datetime.isoformat(datetime.now()),
}
state.log_history.append(output)
else:
output = {**logs, **{"step": state.global_step}}
Expand Down

0 comments on commit b1f4d81

Please sign in to comment.