Infrastructure

Profiling TorchNeuron on AWS Trainium: What the Traces Do and Don’t Tell You

Hugging Face's TorchNeuron walkthrough shows how to trace PyTorch operations down to NeuronCore execution on Trainium. It is a diagnostic method, not a performance verdict.

Hugging Face’s Part 1 post on system-level profiling with TorchNeuron, published October 21, 2026, walks through connecting PyTorch operation timing to Neuron device traces and NeuronCore execution on AWS Trainium 1. It offers a diagnostic workflow for teams evaluating the chip. The material cited here describes how to set up and inspect an RMSNorm comparison, but does not provide measured performance values or establish which implementation is faster 1.

Why system-level profiling belongs in an AWS Trainium evaluation

TorchNeuron is an open-source native PyTorch backend for Trainium, which the post describes as a chip for deep-learning training and inference. It supports eager execution, torch.compile, and standard PyTorch APIs with minimal code changes, and integrates with the Neuron Kernel Interface for custom operators and hardware optimization 1.

That compatibility may make running PyTorch on Trainium look straightforward, but it does not by itself show where execution time goes. TorchNeuron profiling connects PyTorch operations with Neuron device timing and lets you follow an operation through runtime scheduling to execution on a NeuronCore 1.

Treat the trace as diagnostic evidence, not a platform score. It can help show where time is spent and identify work worth investigating 1. It does not, by itself, establish application latency, production throughput, or cost; those need to be measured under the conditions your workload will run in.

What TorchNeuron profiling captures

The walkthrough configures torch.profiler with Neuron-specific settings, captures a trace, compares operation-level CPU and device time in key_averages(), and inspects selected operations in Neuron Explorer 1.

Part of the workflow What it contributes
NeuronConfig Selects which Neuron data streams and NeuronCores to capture, and where output is saved. It is passed to torch.profiler.profile through experimental_config 1.
key_averages() With correlated device timing enabled, lets you compare an operation’s Self CPU time with Neuron device time 1.
System traces Provide system-level trace data for inspection 1.
Neuron Explorer A browser-based view of system traces, device timelines, and per-engine breakdowns, accessible through an SSH tunnel or the Visual Studio Code extension 1.

NeuronProfiler also provides an export_trace callback that writes the framework trace, trace.json, alongside the Neuron system traces 1. Taken together, these views help you move from operation-level summaries to dispatch, scheduling, and device activity 1.

Profiler settings that make or break the trace

The example enables device and runtime profiling, selects NeuronCores with capture_enabled_for_nc, and sets correlate_device_time=True so device time appears in key_averages() alongside CPU time. It also adds ProfilerActivity.PrivateUse1 to collect Neuron-device activity and passes NeuronConfig through experimental_config 1.

Synchronization matters. The example calls torch.neuron.synchronize() inside the profiling loop because exporting before device work finishes can leave the Neuron-time column empty 1. Before trusting a comparison, check that device timing is present, the selected NeuronCores match the work under test, and the output is complete. Keep the profiler schedule fixed across runs; changing the schedule and implementation at the same time makes it harder to interpret a difference.

From operation to hardware explanation

Start with an operation that stands out in the framework-level profile. In Neuron Explorer, follow its runtime activity through to NeuronCore execution and the engine-level timeline 1. This helps distinguish CPU-side time, runtime scheduling, and device execution rather than treating them as a single figure 1.

Keep the trace artifacts with the run. When device data is captured, the output directory contains the system trace and matching .neff and .ntff files 1. The NEFF contains the compiled Neuron executable; the matching NTFF contains its hardware instruction trace. The files share a numeric hash that identifies them as a pair 1. These artifacts connect the profile to the compiled executable and its hardware instruction trace 1.

That can be useful for debugging and kernel-level optimization. It is still not an end-to-end application performance measurement: the application’s behavior needs to be measured separately.

What the RMSNorm comparison does—and doesn’t—show

The post compares three RMSNorm implementations using the same inputs, profiler configuration, and schedule: separate PyTorch operations; torch.rms_norm() lowered to a single fused Neuron kernel; and the separate-operation version run through torch.compile 1. The example input has shape 4 by 512 in bfloat16, and the profiler schedule is wait=2, warmup=1, active=1 across four prof.step() calls 1.

Holding those conditions fixed makes the implementations easier to compare without also changing the test setup. That is a useful design choice, not evidence that one implementation will win on another workload.

The supplied material describes the comparison setup but gives no measured CPU-time, device-time, or end-to-end values for the implementations 1. Don’t treat fusion or torch.compile as a guaranteed win for your workload based on this example; the cited material does not establish that result.

What to measure before calling a workload a good fit on Trainium

Trace signals and application-level measurements answer different questions, so use both. The workflow covers CPU and Neuron device timing, runtime scheduling, device timelines, and per-engine breakdowns 1. Those views do not replace measuring end-to-end latency, steady-state throughput, and cost on your own workload. A trace can help explain a result; it does not replace the measurement.

Test the operating points your business needs. For example, compare serving and training workloads, vary batch size and sequence length, and check multiple model variants. The cited example focuses on an RMSNorm operation with a specified input shape; it does not establish performance across those broader workload dimensions 1.

For each run, record the model version, compilation path, profiler settings, and output artifacts together. This makes it easier to distinguish a genuine change from drift in the workload or measurement setup.

If hosted inference is one of the alternatives you are weighing, a model catalog can help you line up candidates, and an enterprise AI gateway with routing constraints and spend controls can keep those comparisons governed. The same end-to-end measurements apply either way.

A practical evaluation sequence for PyTorch on Trainium

  1. Establish an end-to-end baseline. Run a representative PyTorch workload before enabling detailed traces, and record the latency and throughput relevant to your decision. The post provides a profiling workflow, not workload-specific acceptance thresholds 1.
  2. Capture a focused window. Use NeuronConfig to select data streams and NeuronCores, enable device and runtime profiling, and correlate device time with CPU time 1.
  3. Rank, then investigate. Use key_averages() to flag operations with notable CPU or device time, then inspect them in Neuron Explorer 1.
  4. Compare alternatives on equal terms. Keep inputs, profiler configuration, and schedule fixed across variants, as in the RMSNorm example 1.
  5. Separate observations from hypotheses. Record the measurement, your interpretation, and what still needs testing. The post provides a profiling method; performance thresholds and workload-specific results require your own evaluation 1.

A busy-looking trace or a working port is not the finish line. The decision depends on whether your own latency, throughput, and cost measurements meet the needs of the workload—and whether the trace helps explain the result. Run the RMSNorm comparison with your own shapes and dtypes before relying on assumptions about what the fused kernel will deliver.

For a similar validate-before-you-commit approach on a different deployment target, see On-Device Small Models for Web Apps: What Enterprise Teams Must Validate.

FAQ

What is TorchNeuron profiling?

It is a workflow for examining PyTorch operations, Neuron device timing and system-level execution on Trainium. The described process uses torch.profiler, NeuronConfig, trace export and Neuron Explorer 1.

How do I compare CPU time with Neuron device time?

Enable correlated device timing with correlate_device_time=True and collect Neuron activity with ProfilerActivity.PrivateUse1. The post says this makes device time available in key_averages() for comparison with Self CPU time 1.

What does Neuron Explorer show?

Neuron Explorer is a browser-based viewer for system traces, device timelines and per-engine breakdowns. The post says it can be accessed through an SSH tunnel or a Visual Studio Code extension 1.

Why call torch.neuron.synchronize() during profiling?

The example calls it inside the profiling loop because exporting before device work finishes can leave the Neuron-time column empty 1.

Does the RMSNorm example prove that Trainium is faster?

No. The supplied source describes the comparison setup and inspection workflow but does not provide measured results for the three RMSNorm implementations 1. Teams need measurements from their own models, operating points and end-to-end workloads.

Questions

What is TorchNeuron profiling?
It is a workflow for examining PyTorch operations, Neuron device timing and system-level execution on Trainium. The described process uses torch.profiler, NeuronConfig, trace export and Neuron Explorer [1].
How do I compare CPU time with Neuron device time?
Enable correlated device timing with correlate_device_time=True and collect Neuron activity with ProfilerActivity.PrivateUse1. The post says this makes device time available in key_averages() for comparison with Self CPU time [1].
What does Neuron Explorer show?
Neuron Explorer is a browser-based viewer for system traces, device timelines and per-engine breakdowns. The post says it can be accessed through an SSH tunnel or a Visual Studio Code extension [1].
Why call torch.neuron.synchronize() during profiling?
The example calls it inside the profiling loop because exporting before device work finishes can leave the Neuron-time column empty [1].
Does the RMSNorm example prove that Trainium is faster?
No. The supplied source describes the comparison setup and inspection workflow but does not provide measured results for the three RMSNorm implementations [1]. Teams need measurements from their own models, operating points and end-to-end workloads.

Sources

  1. Profiling TorchNeuron (Part 1): System-level profiling on AWS Trainium. · Huggingface · Oct 21, 2026

How this article was made: an AI writer persona researched and wrote it from the sources listed above; separate AI passes edited it, checked its claims against those sources and audited it; an editor at Yelno reviewed and approved it before publication. How the Yelno blog works.