Skip to content

Conversation

@manuelcandales
Copy link
Contributor

@manuelcandales manuelcandales commented Jan 15, 2026

This pull request introduces detailed performance tracking and reporting for the Metal backend, focusing on timing statistics for both initialization and execution phases. It adds infrastructure to collect, reset, and print timing data, and integrates statistics output into the Parakeet model example. Additionally, a preprocessor macro is defined to signal Metal backend availability.

Metal Backend Performance Statistics:

  • Added timing statistics collection for init() and execute() calls in the Metal backend, including total time, call count, and per-method breakdowns. Accessor and reset functions are provided in stats.h and implemented in metal_backend.cpp.
  • Introduced a new stats.cpp file with a function to print all collected Metal backend statistics, including per-method breakdowns for both initialization and execution.

Build and Integration Improvements:

  • Added runtime/stats.cpp to the Metal backend build sources and defined the ET_BUILD_METAL preprocessor macro to indicate Metal backend support.

Example Model Enhancements:

  • Updated the Parakeet example (main.cpp) to show Metal backend timing stats after model execution if Metal is enabled.

These changes provide better visibility into Metal backend performance and make it easier to profile and optimize model execution on Apple devices.

Copilot AI review requested due to automatic review settings January 15, 2026 21:54
@pytorch-bot
Copy link

pytorch-bot bot commented Jan 15, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/16639

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

❌ 1 New Failure, 2 Unrelated Failures

As of commit 3cfefbf with merge base d58c8ee (image):

NEW FAILURE - The following job has failed:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

@meta-cla meta-cla 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 Jan 15, 2026
@manuelcandales manuelcandales requested review from JacobSzwejbka and mergennachin and removed request for cccclai, Copilot, lucylq and shoumikhin January 15, 2026 21:54
@manuelcandales manuelcandales added the release notes: none Do not include this in the release notes label Jan 15, 2026
@manuelcandales manuelcandales changed the title Parakeet on Metal: compute metal backend init/execute times Metal backend: compute init/execute times Jan 15, 2026
Copilot AI review requested due to automatic review settings January 15, 2026 22:37
Copy link
Contributor

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 adds timing instrumentation to the Metal backend for measuring initialization and execution performance, and exposes these statistics in the Parakeet example application.

Changes:

  • Added timing measurement for Metal backend init() and execute() methods with per-method granularity
  • Created a new stats API module with accessor and print functions for timing data
  • Integrated Metal backend timing statistics into the Parakeet example to display performance metrics

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
backends/apple/metal/runtime/metal_backend.cpp Added timing instrumentation using std::chrono to measure and track init/execute times in global variables
backends/apple/metal/runtime/stats.h Defined public API for accessing Metal backend timing statistics
backends/apple/metal/runtime/stats.cpp Implemented function to print formatted timing statistics to stdout
backends/apple/metal/CMakeLists.txt Added stats.cpp to build and defined ET_BUILD_METAL preprocessor macro
examples/models/parakeet/main.cpp Added performance statistics output section that calls Metal backend stats when built with Metal support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings January 15, 2026 23:03
Copy link
Contributor

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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. release notes: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants