PyTorch Performance Profiling in Practice: From torch.profiler to AWS Trainium Hardware Cycles

A hands-on PyTorch profiling playbook for AWS Trainium: from torch.profiler traces to hardware-level bottleneck analysis.
Engineers from AWS Annapurna Labs present a complete methodology for profiling PyTorch models on AWS Trainium. The key enabler is Torch Neuron, which makes Trainium a standard PyTorch device so teams can use familiar tools like `torch.profiler` without changing their workflow. The profiling process follows three progressive layers — capturing traces, drilling into hardware cycles, and tracing operator dependency chains — to pinpoint host overhead, communication stalls, and idle compute. The talk also highlights feeding Neuron Profile Explorer output into automated agentic pipelines, shifting performance optimization from purely manual work toward human-machine collaboration.
You've deployed your PyTorch model in production, only to find its performance falls far short of expectations — so where is the time actually going? This is a question every engineer working on large-scale training and inference will eventually face. Isha Lakotia and Pinak Panigrahi from AWS Annapurna Labs have laid out a practical, immediately actionable performance profiling methodology, centered around AWS Trainium — Amazon's purpose-built AI chip for large-scale training and inference.

Why Performance Profiling Matters
When a model runs slowly, there's rarely just one cause. Host overhead, communication stalls, and idle compute units can all become bottlenecks. The problem is that without a systematic profiling approach, it's nearly impossible to tell which part of the pipeline is dragging things down — let alone target it for optimization.
The value of this playbook lies in moving beyond theory: it teaches you how to actually locate problems, starting from capturing a single trace, drilling down to hardware cycles, tracing dependency chains, and ultimately establishing a hands-on workflow you can put to use today.

Trainium as a Standard PyTorch Device
One of the most significant developments covered in this talk is that, thanks to Torch Neuron, Trainium is now a standard PyTorch device. What does that mean in practice? It means you don't need to learn an entirely new toolchain — all the optimization tools are built in.
For developers already familiar with the PyTorch ecosystem, this dramatically lowers the barrier to migration and tuning. You can continue using the familiar torch.profiler API without having to rebuild an entire profiling stack just to support a specialized AI chip. The seamless integration between dedicated hardware and mainstream frameworks is exactly what makes development more efficient.

Torch Neuron — the PyTorch component of the AWS Neuron SDK — is Amazon's compilation and runtime framework for its custom AI chips (the Trainium and Inferentia families). By implementing PyTorch's device abstraction interface, it exposes Trainium as a standard device (similar to cuda or cpu), allowing users to simply move models and tensors to the xla or neuron device and reuse native tools like torch.profiler and torch.compile. Under the hood, Torch Neuron compiles PyTorch computation graphs through the XLA (Accelerated Linear Algebra) compiler into instructions targeting Trainium's NeuronCore neural network compute units. This architecture encapsulates hardware differences within the SDK layer, leaving model code and profiling code largely untouched.
The Full Pipeline: From torch.profiler to Hardware Cycles
The complete profiling workflow can be broken down into a series of progressively deeper steps:
Capturing a Trace
Use the standard torch.profiler API to capture a trace of a single run — this is the starting point for all subsequent analysis. The advantage is that the API is PyTorch-native, making the learning curve minimal.
Drilling Down to Hardware Cycles
Looking at a high-level timeline isn't enough. Real bottlenecks are often hiding at the hardware level. By diving into hardware cycle data, you can see the actual utilization of compute units at each stage and determine whether there's any wasted compute capacity.
Tracing Dependency Chains
Large-scale training involves a large number of parallel and communication operations with complex interdependencies. Tracing the dependency chain helps you uncover communication stalls — for example, when a computation is forced to wait idle while a data transfer completes.

Dependency chains are especially critical in large-scale distributed training. Take tensor parallelism or pipeline parallelism as examples: forward passes, backward passes, and cross-node AllReduce/AllGather communication operations are deeply interleaved. If a communication operation hasn't finished, downstream compute operators must wait, creating "bubbles." Tracing the dependency chain is fundamentally about visualizing these ordering constraints between operators to find the critical path — the longest dependency chain that determines overall latency. Once the blocking point on the critical path is identified (typically insufficient communication bandwidth or host-side scheduling latency), optimization can be targeted — for instance, by overlapping computation and communication to hide communication latency.
Explorer Output and Automated Bottleneck Analysis
Another noteworthy direction in this methodology is using Explorer output for agentic flows and automated bottleneck analysis.
Traditional performance profiling is heavily reliant on engineering expertise, requiring engineers to manually sift through massive volumes of trace data looking for clues. By feeding profiling output into an automated analysis pipeline, the system can assist in — or even automatically identify — where bottlenecks lie. This represents an emerging trend in performance optimization: moving from purely manual judgment toward human-machine collaboration, where agents handle the tedious data-wrangling work while engineers focus on higher-level decisions.
The "Explorer" referred to here is the Neuron Profile Explorer, a performance visualization tool provided by AWS Neuron that renders hardware-collected timeline data (operator execution times, NeuronCore utilization, DMA transfers, etc.) in an interactive graphical interface. Feeding Explorer's structured output (typically trace data in JSON or CSV format) into an agentic flow means using an LLM or rules engine to automatically interpret this data — for example, automatically flagging time windows where utilization falls below a threshold, identifying recurring communication wait patterns, or even generating optimization recommendations. This aligns with AIOps trends in distributed tracing tools like OpenTelemetry and Jaeger, with the key difference being that these traces contain chip-level hardware counter data, providing much finer granularity.
What This Playbook Really Means
For teams doing large-scale training and inference on AWS Trainium, this methodology offers a clear optimization path: capture data with familiar PyTorch tools, drill down layer by layer to the hardware level to locate real bottlenecks, then leverage automation to improve analysis efficiency.
Two key takeaways stand out: first, the deep integration between specialized AI chips and mainstream frameworks has made optimizing purpose-built hardware far more approachable than before; second, performance profiling is moving from a purely manual craft toward automation — which is especially important when managing the high cost of large-scale training workloads. Whether you're dealing with host overhead, communication stalls, or idle compute, this workflow gives you the tools to answer the question: where is the time actually going.
Related articles

Felix Rieseberg Personal Homepage
Felix Rieseberg's personal homepage sparks attention on Hacker News. This article covers the Slack engineer's technical background, the rise and fall of nativefier, and the value of a developer homepage as a tech calling card.

@ai-sdk/vue 3.0.306 Patch Release Syncs with [email protected] Update
@ai-sdk/vue 3.0.306 released, synced with [email protected]. A routine patch release for the Vercel AI SDK ecosystem with no public API changes; the Vue adapter layer stays version-aligned with the core package.

Gemini 4 Argon API Launches: The Era of Million-Token Output Begins
Google launches Gemini 4 Argon with sparse MoE architecture, up to 1M output tokens, and a 68.90% Vals Index score, available across API, AI Studio, and the Gemini app.