mirror of
https://github.com/pytorch/pytorch.git
synced 2026-11-20 09:04:25 +08:00
044e60e8c1
## Summary This PR adds a new accelerator documentation chapter, `docs/source/accelerator/profiler.md`, and wires it into the accelerator guide index. The doc explains PyTorch’s profiler integration paths at a high level (legacy autograd vs Kineto) and then focuses on how `PrivateUse1` accelerators can integrate via the legacy autograd path. It uses OpenReg as the illustrative example in the Implementation section, without coupling Design/Background to any specific backend. ## Motivation Third‑party accelerators integrating via `PrivateUse1` need a concise, device‑agnostic reference for profiler integration. Today, details are scattered across C++ stubs, Python control code, and tests. This documentation centralizes: - Where an accelerator plugs into the profiler surface - What hooks are required (record/elapsed/synchronize/onEachDevice/annotations) - How to validate behavior with multi‑stream/device, shapes, and chrome trace export ## What’s changed - Added `docs/source/accelerator/profiler.md` - Background: links to `torch/csrc/profiler/README.md` and outlines the two profiler paths - Design: backend‑agnostic control plane (Python, ProfilerStubs, backend runtime) - Implementation: introduces OpenReg as the example for `PrivateUse1` legacy path - Usage patterns: snippets for multi‑stream, training loops, and trace export - Validation and limitations: summarizes tested scenarios and current constraints - Updated `docs/source/accelerator/index.md` to include `profiler` in the toctree Pull Request resolved: https://github.com/pytorch/pytorch/pull/170276 Approved by: https://github.com/fffrog