Skip to content
worth noting Coding

Guide shows how to profile inference with TorchNeuron on AWS Trainium chips

only one source so far

Hugging Face Blog has published a guide to measuring inference performance on AWS Trainium chips. It brings together torch.profiler, the TorchNeuron tool and the Neuron Explorer viewer, demonstrating the procedure with three implementations of the RMSNorm operation.

Hugging Face Blog has published a guide to system-level inference profiling with TorchNeuron on AWS Trainium chips. It assumes no prior profiling experience and describes how to record an execution trace, compare CPU and device time, and follow an operation from its handoff by the framework through to execution on a NeuronCore core.

The NeuronConfig object specifies the data streams to record, the cores to monitor and the output directory. The correlate_device_time=True option makes device time available in the key_averages() table. The NeuronProfiler object provides the export_trace function for saving the trace. The example enables ProfilerActivity.PrivateUse1 and passes NeuronConfig as experimental_config. Calling torch.neuron.synchronize() inside the measurement loop ensures that computation finishes before export; without it, the device time column may remain empty.

The procedure compares three RMSNorm implementations: individual PyTorch operations, the built-in torch.rms_norm() function and the original sequence of operations with torch.compile. It uses the same inputs, profiling settings and measurement schedule. The Neuron Explorer viewer is used to inspect the system trace, the device timeline and the flow between individual operations. Scripts for reproducing the results are available among the examples in the torch-neuronx package.

What changed

Why it matters

Developers can connect aggregate operation timings to specific execution traces on the hardware and identify where time is spent during inference. Comparing three implementations under identical conditions provides a basis for choosing the next optimization steps; the guide itself does not demonstrate across-the-board speedups.

Two audiences, two different impacts

What this means

01

For individuals

If you develop for AWS Trainium chips, this gives you a concrete procedure for comparing CPU time with device time and tracing execution when investigating a slow operation.

What to do Try profiling the RMSNorm example with correlate_device_time=True enabled and device synchronization inside the measurement loop.
More practical updates →
02

For a business

When optimizing inference, teams can compare implementation variants under identical conditions and base decisions on measured behavior. However, the procedure described does not establish any specific reduction in operating costs.

Development
What to decide Before choosing an implementation, compare the three RMSNorm variants described using the same inputs, profiling settings and measurement schedule.
More business impacts →
AWS Trainium Neuron Explorer PyTorch TorchNeuron torch.profiler

Check the original

Event sources

only one source so far · 1 publisher, 0 independent. We count feeds from the same owner only once.

1
Hugging Face Blog primary source · first detected Profiling TorchNeuron (Part 1): System-level profiling on AWS Trainium.