pytorch / pytorch/benchmark

CPU peak memory calculation overestimates memory usage by 100x

Open Beginner friendly
#2,707 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1k
Forks
346
PR merge metrics
No merged PRs in 30d

Description

In torchbenchmark/util/experiment/metrics.py, the CPU memory calculation in get_peak_memory() currently uses:

cpu_peak_mem = percentage * total / 10**9

psutil.Process.memory_percent() returns a percentage (for example, 5.0 means 5%), not a ratio between 0 and 1. Multiplying this value directly by total system memory causes the reported cpu_peak_mem to be 100x too large.

The conversion should divide the percentage by 100:

cpu_peak_mem = percentage * total / 100 / 10**9

For example, 5% of 100 GB should be reported as 5 GB, but the current formula reports 500 GB.

Related PR: #2706. The proposed fix only corrects the unit conversion and does not change the existing CPU peak memory measurement behavior.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open torchbenchmark/util/experiment/metrics.py and start at get_peak_memory(), focusing on the CPU memory calculation and the percentage returned by psutil.Process.memory_percent(). Correct the percent-to-ratio conversion so a 5% reading from a 100 GB system reports 5 GB rather than 500 GB. Done means the calculation changes only the unit conversion described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
performance
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
92/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.