Skip to content

Commit

Permalink
Avoid negative values in eval metrics (#1533)
Browse files Browse the repository at this point in the history
  • Loading branch information
deepak-gowda-narayana authored Dec 2, 2024
1 parent 2368207 commit 246dd5d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions optimum/habana/transformers/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,14 @@ def evaluate(
num_samples = output.num_samples - self.args.throughput_warmup_steps * total_batch_size
num_steps = math.ceil(output.num_samples / total_batch_size) - self.args.throughput_warmup_steps

eval_steps = math.ceil(output.num_samples / total_batch_size)
if eval_steps <= self.args.throughput_warmup_steps:
logger.warning(
f" Warmup steps are taken into account for the throughput calculation because the number of evaluation steps ({eval_steps}) is smaller than the number of warmup steps ({self.args.throughput_warmup_steps})"
)
num_samples = output.num_samples
num_steps = eval_steps

output.metrics.update(
speed_metrics(
metric_key_prefix,
Expand Down

0 comments on commit 246dd5d

Please sign in to comment.