Skip to content

Memory profiler #2061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

Memory profiler #2061

wants to merge 20 commits into from

Conversation

jainapurva
Copy link
Contributor

@jainapurva jainapurva commented Apr 15, 2025

This pull request introduces memory profiling capabilities to the microbenchmarking framework, alongside enhancements to the existing profiling infrastructure. Key changes include the addition of a memory profiler, updates to configuration files to enable memory profiling, and new test cases to validate the functionality.

Memory Profiling Enhancements:

  • Memory Profiling Implementation: Added generate_memory_profile and visualize_memory_profile functions in benchmarks/microbenchmarks/profiler.py to enable CUDA memory profiling and visualization. This includes memory snapshots, stats collection, and HTML visualizations of memory usage.
  • Validation for Pickle Files: Introduced _validate_pickle_file in profiler.py to ensure memory profile files are valid and readable.

Configuration Updates:

  • New Profiling Options: Updated benchmarks/microbenchmarks/README.md and benchmarks/microbenchmarks/test/benchmark_config.yml to include enable_memory_profiler as a configuration option. This allows users to enable memory profiling for specific models.

Benchmarking Framework Changes:

  • Integration of Memory Profiling: Updated benchmark_inference.py to run memory profiling when enable_memory_profiler is set. Results include memory stats and visualization paths.
  • Extended BenchmarkConfig and BenchmarkResult: Added enable_memory_profiler to BenchmarkConfig and memory profiling-related fields (memory_profile_path, memory_visualization_path, memory_stats) to BenchmarkResult in utils.py.

These changes enhance the profiling capabilities of the benchmarking framework, providing deeper insights into memory usage during inference, especially for CUDA-enabled devices.Add support for memory profiler

Copy link

pytorch-bot bot commented Apr 15, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/2061

Note: Links to docs will display an error until the docs builds have been completed.

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 15, 2025
@jainapurva jainapurva changed the base branch from main to model_shapes_config April 18, 2025 19:01
@jainapurva jainapurva added topic: performance Use this tag if this PR improves the performance of a feature topic: for developers Use this tag if this PR is mainly developer facing labels Apr 18, 2025
@jainapurva jainapurva requested review from Copilot and HDCharles April 18, 2025 21:32
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces memory profiling capabilities to the microbenchmarking framework, enabling CUDA memory profiling and visualization alongside the standard profiling functionality. Key changes include the implementation of memory profiling functions in profiler.py, updates to configuration files and utility classes to support new profiling options, and the addition of comprehensive tests to validate the functionality.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
benchmarks/microbenchmarks/utils.py Added new fields and updated to_dict to carry memory profiling info
benchmarks/microbenchmarks/test/test_benchmark_profiler.py Added tests for memory profile generation and visualization
benchmarks/microbenchmarks/test/benchmark_config.yml Updated YAML config to include enable_memory_profiler flags
benchmarks/microbenchmarks/profiler.py Added generate_memory_profile and visualize_memory_profile functions, including pickle file validation
benchmarks/microbenchmarks/benchmark_inference.py Integrated memory profiling functions to run alongside model profiler
benchmarks/microbenchmarks/README.md Documented new memory profiling options and usage

@jainapurva jainapurva marked this pull request as ready for review April 21, 2025 18:05
Copy link
Contributor

@HDCharles HDCharles left a comment

Choose a reason for hiding this comment

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

lgtm

@jainapurva jainapurva changed the base branch from model_shapes_config to main April 25, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. topic: for developers Use this tag if this PR is mainly developer facing topic: performance Use this tag if this PR improves the performance of a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants