Skip to content

PeakMemoryRecorder#1609

Open
dxqb wants to merge 1 commit into
Nerogar:masterfrom
dxqb:debug-peak-mem
Open

PeakMemoryRecorder#1609
dxqb wants to merge 1 commit into
Nerogar:masterfrom
dxqb:debug-peak-mem

Conversation

@dxqb

@dxqb dxqb commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

sibling to TorchProfiler and TorchMemoryRecorder (which records a memory profile)
disabled by default, only a dev tool

Test plan

  • pre-commit run --all-files passes
  • Launched the affected UI or script and exercised the change
  • Tested with at least one real preset / config when relevant (note which: ____)

AI assistance

  • AI-assisted — I have read every line in this diff and can defend each change

…manager

Reworks the always-on, import-time-started peak-memory instrumentation into a
scoped context manager alongside TorchMemoryRecorder/TorchProfiler in
profiling_util.py. Peak RAM is polled on a daemon thread only for the
duration of the with-block (Linux via /proc RssAnon, Windows via psutil
private bytes); peak VRAM uses CUDA's native counters, reset per block.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@hameerabbasi hameerabbasi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question

# psutil's pmem.private is process-private bytes, i.e. Windows' analogue of anon RSS.
import psutil
return psutil.Process().memory_info().private
raise RuntimeError(f"peak RAM tracking not supported on {platform.system()}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this allow a training to work on Macs? Should we catch this error somewhere?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll merge this disabled, see "enabled=False" above. it's dead code until a dev enables it.
if you think this tool is helpful for you as a dev on Macs feel free to add Mac support, but it's not an issue for a user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants