pytorch - ✅(Solved) Fix Enable profiler.ProfilerActivity.PrivateUse1 to be renamed to device-specific name [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

PR fix notes

PR #180421: [Profiler][PrivateUse1] Expose backend name as alias in ProfilerActivity for PrivateUse1

Description (problem / solution / changelog)

Fixes #179806

Summary

This pull request improves support for custom backends in PyTorch by ensuring that when a private use backend is renamed, the profiler activity enum (ProfilerActivity) also reflects this change. This allows users to refer to the custom backend by its new name in profiling code, making the API more intuitive and consistent.

Changes

Updates to profiler activity enum for renamed backends:

  • When rename_privateuse1_backend is called, a new alias is added to ProfilerActivity so users can reference the backend by its new name (e.g., ProfilerActivity.FOO), and the alias is added to the enum's members.
  • The test test_external_module_register_with_renamed_backend is updated to check that ProfilerActivity exposes the renamed backend as an alias for PrivateUse1 and that the alias is present in the enum's members.

cc @divyanshk @fffrog

Changed files

  • test/cpp_extensions/open_registration_extension/torch_openreg/tests/test_misc.py (modified, +8/-0)
  • test/test_extension_utils.py (modified, +6/-0)
  • torch/utils/backend_registration.py (modified, +7/-0)
RAW_BUFFERClick to expand / collapse

Thanks @divyanshk a lot for providing the entry point for new accelerators to integrate into Kineto. Great work!

However, unlike CPU or CUDA, where users can use profiler.ProfilerActivity.CPU or profiler.ProfilerActivity.CUDA, PrivateUse1-based accelerators can only use profiler.ProfilerActivity.PrivateUse1. This is somewhat confusing. We should provide the same capability by allowing PrivateUse1 to be renamed to a specific name like NPU.

cc @robieta @chaekit @guotuofeng @guyang3532 @dzhulgakov @davidberard98 @briancoutinho @sraikund16 @sanrise @mwootton @divyanshk @jiannanWang @scotts @ryanzhang22 @KarhouTam

extent analysis

TL;DR

Allowing PrivateUse1 to be renamed to a specific name like NPU could provide the same capability as CPU or CUDA for profiler activities.

Guidance

  • Identify the current implementation of profiler.ProfilerActivity.PrivateUse1 and its usage to understand the potential impact of renaming.
  • Consider adding a mapping or aliasing mechanism to allow PrivateUse1 to be referenced by a custom name, such as NPU.
  • Evaluate the feasibility of introducing a new profiler activity type, similar to CPU or CUDA, for NPU or other custom accelerators.
  • Review the API documentation and user-facing interfaces to ensure consistency and clarity in the usage of custom profiler activity names.

Notes

The solution may require modifications to the PyTorch codebase, particularly in the profiler module, and could involve collaborating with the maintainers and contributors of the project.

Recommendation

Apply workaround by introducing a custom mapping or aliasing mechanism to allow PrivateUse1 to be referenced by a specific name like NPU, as this approach seems to be a more feasible and less invasive solution compared to introducing a new profiler activity type.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING