Skip to content

[observability] Profile Neuron devices with the PrivateUse1 activity - #6

Closed
kvshbg-aws wants to merge 1 commit into
mainfrom
kvshbg/privateuse1-profiler
Closed

kvshbg-aws wants to merge 1 commit into
mainfrom
kvshbg/privateuse1-profiler

Conversation

@kvshbg-aws

@kvshbg-aws kvshbg-aws commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

On AWS Neuron (Trainium), build_torch_profiler recorded only CPU activity. This PR adds ProfilerActivity.PrivateUse1 when device_type == "neuron", in the same way the CUDA and XPU branches add their activities. No other device changes.

The Neuron branch also sets with_stack=True. Neuron Explorer uses the stacks to link framework events to source lines. The stacks add host overhead only on profiled steps.

Notes

  • requires torch-neuronx>=2.33 version This PR adds no Neuron imports or configuration.
  • TORCH_NEURONX_PROFILE_* environment variables set the Neuron profile options. The defaults capture rank 0.
  • Logs, metrics, MFU, and memory snapshots already work on Neuron through device_module. This PR does not change them.

Test plan

pytest tests/unit_tests/cpu/observability/
pre-commit run --files torchtitan/observability/profiler.py tests/unit_tests/cpu/observability/test_profiler.py
  • The unit tests give 135 passed. The new test checks the activities and with_stack on a mocked Neuron device.
  • Ran the profiler on Neuron hw with Qwen3 8B (64 NeuronCores). Rank 0 trace:
    • 34K privateuse1_runtime and 22K privateuse1_driver events;
    • source-linked framework events;
    • a Neuron session that opens in Neuron Explorer.

On Neuron, the profiler recorded only CPU activity. Add
ProfilerActivity.PrivateUse1 when device_type is "neuron", as the CUDA
and XPU branches do. Also set with_stack, so Neuron Explorer can link
framework events to source lines.
@kvshbg-aws
kvshbg-aws marked this pull request as ready for review October 5, 2026 22:00
@aws-arashj

Copy link
Copy Markdown
Collaborator

let's reword

requires a torch-neuronx change, that has been merged to the torch-neuronx repo

to requires totorch-neuronx ≥ 2.33 version

also

the trn2.48xlarge / 64-NeuronCore

to verified on Neuron hardware.

@kvshbg-aws

Copy link
Copy Markdown
Collaborator Author

closing this one since we have the upstream PR open - pytorch#5072

@kvshbg-aws kvshbg-aws closed this Oct 6, 2026
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