Skip to content

Commit

Permalink
Benchmarking: output allocated/reserved memory with two decimal digits (
Browse files Browse the repository at this point in the history
pytorch#2597)

Summary:
Pull Request resolved: pytorch#2597

Benchmarking used `.2g` format to output allocated/reserved memory, which shows 2 digits precisely (so e.g. `123`  would've been shown as `1.2e+2`). What we want is actually 2 *decimal* digits - and that is `.2f`

Reviewed By: arsatis

Differential Revision: D66527885

fbshipit-source-id: b778b7f3aa0a73c927878c155276f86970faa865
  • Loading branch information
che-sh authored and facebook-github-bot committed Nov 27, 2024
1 parent ef94338 commit 7e7819e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions torchrec/distributed/benchmark/benchmark_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ class BenchmarkResult:
rank: int = -1

def __str__(self) -> str:
runtime = f"Runtime (P90): {self.runtime_percentile(90):g} ms"
runtime = f"Runtime (P90): {self.runtime_percentile(90):.2f} ms"
mem_alloc = (
f"Peak Memory alloc (P90): {self.max_mem_alloc_percentile(90)/1000:.2g} GB"
f"Peak Memory alloc (P90): {self.max_mem_alloc_percentile(90)/1000:.2f} GB"
)
mem_reserved = f"Peak Memory reserved (P90): {self.max_mem_reserved_percentile(90)/1000:.2g} GB"
mem_reserved = f"Peak Memory reserved (P90): {self.max_mem_reserved_percentile(90)/1000:.2f} GB"
malloc_retries = f"Malloc retries (P50/P90/P100): {self.mem_retries(50) } / {self.mem_retries(90)} / {self.mem_retries(100)}"
return f"{self.short_name: <{35}} | {malloc_retries} | {runtime} | {mem_alloc} | {mem_reserved}"

Expand Down

0 comments on commit 7e7819e

Please sign in to comment.