chartexchange

AWS Challenger: Trainium3 Inference and Microarchitecture Deep Dive

SemiAnalysis | Nov 27, 2026 10:54 AM EST

The Nvidia GPU was originally built to shade pixels, and every Nvidia generation since 2017 has bolted on another piece of AI-specific hardware to fix the bottleneck the previous one exposed. Volta added Tensor Cores, Hopper added TMA for tile data movement between HBM and SRAM, and Blackwell added Tensor Memory for accumulating. Nvidia removed many hardware units that are required to render graphics for their datacenter GPUs In comparison, the Trainium microarchitecture is built ground-up specifically for ML workloads, with tiles as a first-class primitive instead of having a sea of threads and then bolting on tensor/tile compute and data movement engines. Trainium3 behaves the way the physics says it should. In this past this meant software was a humongous challenge, but now no longer. Source: Dwarkesh Podcast 7 months later, Trainium 3 and TPUs are live on InferenceX , both trading blows or even winning vs Nvidia GB300 in cost to generate tokens at TCO. We will dive into those details below. This advantage is not purely due to Amazon’s ultra low cost supply chain. It's also due to microarchitectural decisions, which we will dive into in this post. For example, using the Trainium Descriptor Generation Engines (DGE), the equivalent of Nvidia TMA and AMD MI455X TDM, our microbenchmarks show that Trainium can reach peak HBM bandwidth utilization (MBU) at small message sizes, which is not possible on Nvidia GPUs. Furthermore, our testing covers cycle-level SRAM scratchpad latency and bandwidth testing (SBUF to PSUM), rack-scale bandwidth and latency microbenchmarks, attention exponential testing, and the precise cycle-level latency of different shapes, including how different attention head_dim (K) would affect the percentage of roofline. Every result comes from UBenchX, our microbenchmark suite, and we model each unit from first principles before we measure it. We thank Nafea Bshara (Co-Founder of AWS Annapurna Labs), Ron Diamant (Trainium Chief Architect), Michael Shteinbok, Armin Ebrahim and the rest of their team for helping teach us their architecture and validate our benchmark experiments. Star the InferenceX & UBenchX GitHub repository if you find the open-source benchmark and data useful ! InferenceX is the only inference benchmark in the world to have TPUv7, OpenAI Jalapeño, Nvidia Rubin NVL72, AMD, and now, Trainium3. Source: SemiAnalysis Trainium’s Superior Inference Performance per Dollar - AgentX AgentX measures Trainium3 on a production end-to-end agentic inference workload. This is achieved by replaying real coding-agent sessions against a Trainium3 server. The goal is to compare accelerators’ realistic inference performance, that you may expect to see on actual agentic workloads. For those unfamiliar with InferenceX, the Pareto frontiers (curves) represent the fundamental inference tradeoff between throughput and latency. Each point is a different inference configuration targeting a different latency-throughput target. At each slice of the x-axis, higher perf per TCO is better and directly leads to higher inference gross margins. Today, we are excited to share that Trainium 3 PDS + vLLM achieves amazing perf/$ TCO across the entire frontier. In fact, it is better than every other accelerator besides Vera Rubin across the entire TCO versus p90 interactivity curve. This is an amazing achievement. Source: SemiAnalysis Trainium is also very competitive from an end-to-end latency perspective, across the entire curve. With that being said, there is still room for improvement, particularly with respect to TTFT. Source: SemiAnalysis Source: SemiAnalysis It is not surprising that Trainium lags behind in some p90 TTFT cases against GB300 as this metric is largely dictated by prefill, a compute bound operation. Trainium3 has only 17% the theoretical FP4 flops as Blackwell Ultra (2,517 TFLOPS versus 15,000 TFLOPS). It has more competitive interactivity since decode is memory bound and Trainium3 has 4.9 TB/s per chip against 8.0 TB/s for GB300, 61% of the bandwidth at about 30% the TCO. Also, pipelined prefill (which Trainium relies on, as discussed in the subsequent section) generally favors throughput over latency. In fact, at a p90 interactivity of 135 tok/s/user (a typical speed you’d observe on OpenRouter), Trainium3 with vLLM yields the highest profit margin at 73.5%, compared to runner up GB300 + SGLang at 53% (at 3 year rental prices). This assumes Z.ai list price for token pricing and a 60% hardware fleet utilization factor. Trainium3 achieves these margins with 144GB of HBM per chip, half GB300’s capacity per GPU. This reflects our Short King thesis: additional HBM capacity must deliver enough extra throughput at the target latency to justify its cost. This is also why 4-Hi is attractive industry wide option and next generation accelerators are primarily using 8-Hi. Source: SemiAnalysis What makes these results interesting for this article is how directly the software follows the hardware we measure in Section 2. Prefill and decode run on separate nodes, and each arranges the same 16 chips to suit the topology. Prefill A quick primer for this section: a Trainium3 chip has 8 NeuronCores, each pair sharing one HBM stack, and a node is 16 chips. Section 2 covers the hardware in detail. For a more in depth analysis, see our Trainium3 deep dive article. Source: SemiAnalysis A prefill node is a pipeline. The model’s layers are cut into 16 stages, one chip per stage, and a chunk of prompt tokens flows from chip to chip. Inside a stage, the chip’s 8 NeuronCores split the chunk between them, so all of the stage’s tensor and expert parallelism stays on one chip. This is the layout our collective benchmarks argue for. Chip-level collectives were well ahead of every wider group we tested, and all-to-all, the pattern MoE layers need, is slower once it leaves the chip. With the heavy exchanges kept on one chip, what limits a stage is TensorE, which is where the MXFP4 matmul modes covered below do their work. Decode Source: SemiAnalysis For decode, one copy of the model is spread across individual ranks on all 128 NeuronCores (across 16 chips), and every core takes part in the computation for each token. For those familiar with Nvidia architecture, each GPU is typically a separate rank whereas Trainium treats all 128 cores as logical devices and separate EP ranks. In the case of multi-user GLM-5.3, this assigns two routed experts per NeuronCore. Decode runs at LNC=1, so each physical NeuronCore is its own rank, whereas the rest of this article uses the default LNC=2. Again, each NeuronCore is its own device with local HBM, so nothing synchronizes across the chip unless the software invokes a collective. Nvidia added locality domains in CUDA 13.4 to pin Rubin kernels to one die’s memory in the same way. Source: SemiAnalysis Not every exchange spans the node though. Decode declares nested groups of cores: half a chip, one chip, the two chips of a tray, two trays, half the node, and the whole node, plus a second family that takes the same core position on every chip. The smaller exchanges, such as the dense layers and the shared expert, can run on the small groups. A group of 8 is one chip and a group of 16 is one tray, whose two chips share a direct link, so those exchanges never touch a switch. But activations are gathered across all 128 cores and the expert outputs are reduced across all 128, so that traffic crosses the switch on every layer. Trainium Profiler Fine-grain Accuracy - Better Than Nvidia and AMD Trainium’s profiler is by far the industry leader and is state of the art (SOTA). Trainium’s profiler is loved by all the performance engineers at Anthropic. Anthropic’s head of performance has publicly said that performance analysis on Trainium is way better than performance analysis on Nvidia GPUs (and obviously better than on AMD GPUs). In order to demonstrate how fine-grained their profiler is, we recreated the Olympic performance of the Bay Area’s own Alysa Liu on the actual Trainium3 hardware profile. We were mainly inspired by the Bad Apple post from Daniel Liu (Anthropic Performance Engineer). This combines fine art, performance art, and chip architecture all into one video. Source: SemiAnalysis Full video: Section 2: Microbenchmarks Hardware and Programming Model Trainium3 consists of 8 NeuronCore-v4s, and every 2 NeuronCores share an HBM stack. By default, 2 NeuronCores that share an HBM stack form a Logical NeuronCore (LNC). Users write kernels that map to LNCs, and in LNC=2, it follows the Single-Program Multiple-Data (SPMD) paradigm: NeuronCores in an LNC execute the same kernel program with separate hardware resources except the HBM. In a Neuron Kernel Interface (NKI) kernel, programmers can assign work to NeuronCores in an LNC with the API nl.program_id and synchronize NeuronCores with the barrier mechanism nisa.core_barrier. One of the most important concepts in data movement is the partition dimension (pdim) and the free dimension (fdim). Every tensor has a designated partition dimension, and other dimensions are called free dimensions. In principle, the partition dimension aligns with the dimensions of hardware components, and data can be processed in parallel. We explain the dimensions of each component throughout the article. Memory HBM Bandwidth Here we investigate the achievable HBM bandwidth of Trainium3. In Trainium3’s memory hierarchy, we move data from HBM to SBUF using the API nki.isa.dma_copy . Each NeuronCore comes with 16 main Direct Memory Access (DMA) engines, in charge of moving data between HBM and SBUF. For every data transfer, a main DMA engine ingests a DMA descriptor, which contains the source and destination address information. In Trainium3, there are three modes of generating DMA descriptors: static (None), software-based DGE (swdge), and hardware-based DGE (hwdge). Each mode generates and stores descriptors differently. Source: SemiAnalysis Starting from NeuronCore-v3 (Trainium2), GpsimdE comes with one integrated DMA engine per processor, totaling eight integrated DMA engines. With these integrated DMA engines, programmers can perform data movements in parallel with the main DMA engines, while also enabling indirect access patterns, such as gather and scatter operations. NeuronCore-v3 also comes with two Descriptor Generation Engines (DGE) . DGE accelerates descriptor generation with hardware: it frees up GpsimdE to perform other computation, frees up memory space, and accelerates address generation. DGE resembles Tensor Memory Accelerator (TMA) in Nvidia architecture and Tensor Data Mover (TDM) in AMD architecture. TMA focuses on accelerating large data copies at the cost of higher latency, while hardware-based DGE has no performance trade-offs compared to software DGE. However, while TMA is able to perform gather and scatter operations, not even the latest NeuronCore DGE can do so. As a result, NKI constrains DMA copy mode to swdge when performing indirect memory accesses. Source: SemiAnalysis Here we compare the achieved memory bandwidth of a single Trainium3 NeuronCore for the three descriptor modes. Static mode, since descriptors are compiled ahead of time, has the lowest descriptor generation overhead and achieves the highest memory utilization. At the smallest tested message size 64 KiB, static mode achieves 492 GB/s (80% utilization) for load and 544 GB/s (88.8% utilization) for store. Static mode also achieves near peak memory bandwidth at around 256 KiB. Hardware DGE, the default mode of DMA copy, follows closely behind static mode: it achieves 398 GB/s (65% utilization) for load and 476 GB/s (77.7% utilization) for store at 64 KiB message size, likely due to the address generation overhead. The gap narrows as message size increases, and hardware DGE mode matches static mode after 256 KiB. On the other hand, software DGE performs significantly worse than the other two. This likely indicates indirect memory access patterns may suffer great performance loss, as they are restricted to software DGE mode. Trainium3 consists of 8 physical NeuronCores, and while they have individual DMA engines, each pair of NeuronCores shares one HBM stack. Thus, we measure the memory bandwidth achieved by 8 concurrent NeuronCore programs to understand the utilization under full load. Overall, the HBM is able to sustain the high utilization, dropping by only about 3% for larger message sizes. Source: SemiAnalysis PSUM to SBUF Bandwidth In Trainium3, PSUM and SBUF are arranged in a 2D grid of 128 lanes of 16 KiB / 256 KiB capacity. The 128-lane setup is the partition dimension, and the data is accessed in parallel along the partition dimension. There are two main types of data movement between PSUM and SBUF: SBUF to PSUM: Upon an nki.isa.nc_matmul call, TensorE moves both input matrices from SBUF to PSUM PSUM to SBUF: Epilogue operations such as data type casting, activation, and quantization. These operations are mostly based on the nki.isa.tensor_copy API This section focuses on PSUM to SBUF. Two engines have PSUM read access: ScalarE and VectorE. We measure the achieved memory bandwidth for the two engines across different tile shapes, using the full 128 partitions with varied per-partition sizes. Source: SemiAnalysis Our results show that PSUM read bandwidth starts from 453.9 bytes per cycle for ScalarE and 413.9 bytes per cycle for VectorE at 32 KiB message size, and both reach near the theoretical bandwidth of 512 bytes per cycle (4 bytes per cycle per lane, 128 lanes) at around 256 KiB message size. This translates to a 614.4 GB/s bandwidth for each engine. Starting from NeuronCore-v3 (Trainium2), the two engines can perform PSUM reads in parallel. Our benchmarks show that parallel access causes near-zero bandwidth loss, indicating that the PSUM is well designed to sustain parallel access. When both engines are used in parallel, they reach 1024 bytes per cycle. Source: SemiAnalysis Source: SemiAnalysis The bandwidth gap between the two engines in the smaller message sizes indicates different instruction issue overhead: ScalarE has about 8 cycles of overhead, whereas VectorE has about 16 cycles. Tensor Engine Tensor Engine (TensorE) is the hardware unit that executes matrix multiplications. In terms of architecture, TensorE is a systolic array, which consists of a 128-by-128 processing element (PE) grid. The 128 dimension matches the number of partitions in SBUF and PSUM, and since TensorE reads both matrix inputs from SBUF and writes the results to PSUM, this simplifies programming. TensorE applies near-memory accumulation: the output accumulates in PSUM, avoiding a round trip to HBM, and it is especially useful for epilogue operations and consecutive matrix multiplications. This design is also present in Nvidia Blackwell, where the TensorCore output accumulates in TMEM. We invoke TensorE with the API nisa.nc_matmul . For a matrix multiplication of x @ y = z, the input dimensions are as follows: Stationary x.T: [K, M]. Maximum of M (stationary fdim) is 128; TensorE reaches full performance at K=128 Moving y: [K, N]. Maximum of N (moving fdim) is 4096. This is because PSUM has 16 KiB per partition, which can hold a maximum of 16384 B / 4B = 4096 FP32 elements Output z: [M, N] Note that TensorE requires the stationary matrix x to be transposed, meaning the hardware takes x.T as input but computes x @ y. This is due to TensorE’s systolic array design: the systolic array computes dot products between rows of x and columns of y. Simple Systolic Array Performance Model In the systolic array, each y column is staggered by one element. Every TensorE matrix multiplication involves two steps: LoadStationary (LS) loads the stationary matrix into the array, and MovingMultiply (MM) performs the calculation. During each cycle of MM, every PE computes a partial sum, passes the y element to the PE on its right, and passes the partial sum to the PE below. Trainium3 systolic array performance model animation. Source: SemiAnalysis With the understanding of the systolic array, we can model the instruction latency as N+254 cycles. In a matrix multiplication, the lower-right element is the last to complete computation, and it depends on how many cycles it takes to move the lowerleft element of y into the lower-right PE. Focusing on the dynamics of the lower-left element of y, we see there are three stages: fill, stream, and drain. The fill stage refers to the period when the input edge isn’t full due to staggering, which is R-1 cycles, where R represents the number of rows in the PE grid. The stream stage refers to the last row entering the PE grid, and it takes N cycles for the lower-left element to reach the input edge. Finally, the drain stage is when the PEs consume the moving matrix inputs, and it takes C-1 cycles for the lower-left element of y to get to the lower-right PE, where C represents the number of columns in the PE grid. Overall, the latency is (R-1)+N+(C-1)=127+N+127=N+254 cycles. We can also model the initiation interval as approximately N cycles for sufficiently large N. Initiation interval is the time gap between instruction launches when we consecutively launch many of the same instructions. In this case, we model the number of cycles between a series of MM instruction launches. From the perspective of the systolic array, we can continuously stream multiple input matrices y1, y2, … in the same staggered fashion, and the computation of the next MM instruction starts as soon as the next input matrix’s element streams into a PE. In a steady state where we ignore the fill and drain stages, each PE streams through one row of input matrix y for every MM instruction, meaning the initiation interval is N cycles. However, this only holds for large N due to our steady-state assumption. nisa.nc_matmul Performance We collect experimental results to verify our modeling. We are able to map the latency results to the formula N+393 with little error, indicating that there’s a roughly 140-cycle overhead for MM instructions, which may include things like writing results to PSUM. Source: SemiAnalysis As for the initiation interval, experiments show that by adding a constant 6-cycle overhead, we are able to reliably predict the initiation interval for matrix multiplication shapes N >= 64 and M=128. As we suspected, the model breaks down for small N, and we observe the initiation interval to be 30 cycles at N=8, likely dominated by other overheads. Source: SemiAnalysis Our model also predicts that M is irrelevant to both performance metrics, and our experiments corroborate this. At N=512, both latency and initiation interval stay constant across all M sizes. This has great implications for performance. LLM inference decode workloads tend to have small M for matrix multiplications, and M not being the main factor in performance alleviates many difficulties when optimizing decode workloads. Source: SemiAnalysis We also measure a more realistic scenario, where we change both stationary and moving matrices, so the kernel alternates between executing LS and MM instructions, and the two instructions of different matrix multiplications can overlap. Results show that we reach more than 90% utilization at N=64, and we reach near theoretical throughput for shapes larger than N=128. Source: SemiAnalysis Double FP8 Matmul Performance Starting from NeuronCore-v3 (Trainium2), TensorE supports FP8 matrix multiplication. In terms of programming, users set the argument perf_mode to nisa.matmul_perf_mode.double_row, and double row mode supports contraction dimension K=256, 2x the standard K=128. However, the systolic array is still a 128-by-128 PE grid, so under the hood, double row mode shards the input into two tiles along the K dimension and computes them in parallel. During computation, each PE takes in two FP8 elements from the moving matrix and computes two multiply and accumulation operations every cycle. Source: SemiAnalysis As a result, the latency of FP8 double row mode is near-identical to its BF16 counterpart, and we show this in the experiments below. TensorE can theoretically double the throughput of FP8 matrix multiplication, since the latency is still bounded by the same systolic array grid. In reality, we see FP8 demonstrating near-identical instruction latency and initiation interval as its BF16 counterpart. Source: SemiAnalysis Source: SemiAnalysis However, for realistic scenarios of alternating LS and MM instructions, double_row mode FP8 performance is mixed. When comparing the same shapes, FP8 underperforms BF16 until around N=96 and only reaches 2x the compute throughput after around N=256, which makes sense as FP8 is executing at half the N size. If we consider the effective N size, double row mode FP8 only starts showing throughput benefits at N=64. FP8 power throttles more frequently than its BF16 counterpart, indicating that typical performance may be less ideal than our full-rate measurements. Source: SemiAnalysis Microscaling Matmul Performance NeuronCore-v4 (Trainium3) introduces microscaling format (MXFP4, MXFP8) matrix multiplication support with the new API nisa.nc_matmul_mx . Quad-MX Matmul Further scaling the FP8 matrix shape, nc_matmul_mx supports the K dimension of 512 (4x the standard) through the quad-MXFP8 data type. Users pass the matrices into the API nisa.quantize_mx to compact the matrices along the K dimension, packing every 4 MXFP8 elements into one quad-MXFP8 element, resulting in the K to be 128. Trainium3 offloads the quantization step to the user, instead of TensorE doing it, and this is different from major MX-supporting hardware such as Nvidia and AMD GPUs. This reduces the quantization overhead during the matrix multiplication instruction but exposes the quantization step to users to optimize. With the quad-MXFP8 data type, how LS loads the stationary matrix and how MM streams the moving matrix behave closer to the standard nc_matmul, except each element is 4-bytes wide. nc_matmul_mx accepts quad-MXFP8 inputs and theoretically has the same performance characteristics as the BF16 nc_matmul, hence 4x the throughput. Realistically, quad-MXFP8 does have similar latency and initiation interval as BF16 nc_matmul, but still suffers from minor overhead, which is understandable given the dequantization step. As for computation throughput, quad-MXFP8 outperforms its BF16 counterpart for most shapes, but it only reaches 4x throughput for N greater than 128. Source: SemiAnalysis Source: SemiAnalysis Source: SemiAnalysis Row Tiling Mode Row tiling mode is another new feature in NeuronCore-v4 (Trainium3) unique to nc_matmul_mx. Row tiling mode allows users to concurrently execute multiple matrix multiplications with smaller K dimensions, improving the utilization of TensorE. TensorE achieves this by splitting up the systolic array along the rows and outputting the results without passing down the partial sums through the whole array. Row tiling mode offers multiple configurations, including tile sizes (32, 128) and (64, 128). A tile represents the cut-up systolic array, so tile size refers to the number of quad elements, and the packed K dimension is essentially the partition size, which we denote as Kp. Theoretically, row tiling mode should offer T times throughput, where T represents the number of tiles. Here we compare the un-tiled, the tiled, and the standard full array configurations. Source: SemiAnalysis Our results show that row tiling mode does improve utilization and achieve higher throughput, and it reaches near the theoretical 2x / 4x boost for N >= 128. Compared to the standard full array configuration, row tiling mode retains about 90% of the full array throughput and closes the gap at N=512. A caveat of row tiling mode is that it might not support certain shapes due to PSUM capacity limits, since the number of output matrix elements doubles / quadruples. Full Chip Performance and Power Throttling We further investigate the power throttling effects on TensorE performance by benchmarking with full chip activated, specifically, 8 matrix multiplication kernels on 8 NeuronCores in a chip. We compare all data types, including BF16, double row FP8, MXFP8, and MXFP4, and we run at the (M, N) = (128, 512) for a typical shape with max K size for each data type. Overall, we see BF16 executing at near max compute throughput, double row FP8 and MXFP4 running at around 90% MFU, and MXFP8 heavily throttled at 68.6% MFU. To set up a non-power throttled comparison, we use AWS power profile tools to apply a clock-limited profile, lowering the max boost clock from 2.4 GHz to 2 GHz. As shown below, all precisions except MXFP8 reach near the max throughput of 2 GHz rate, but are throttled at around 80% of the original MFU. For MXFP8, it reaches 84.5% MFU of 2 GHz rate, boosting the true MFU at 1.9%. This shows power throttling is a critical issue for the MXFP8 matrix multiplication using TensorE. Source: SemiAnalysis Transcendental Functions Transcendental functions are the math operations used in model activations, and those operations are critical to kernel performance due to their inherent mathematical calculation complexities. By default, ScalarE computes the transcendental functions, and to program ScalarE, we call nisa.activation and pass in the math operation, e.g. nl.gelu, as argument. Starting from NeuronCore-v4 (Trainium3), other engines support small sets of the transcendentals . For example, GpsimdE supports functions like sigmoid, and VectorE supports the exponential function through the new API nisa.exponential . We first benchmark the exponential function, since the exponential function throughput is a great performance bottleneck to FlashAttention operation . Here we compare VectorE and ScalarE to find out how much VectorE boosts the performance. The benchmark setup follows the most common softmax precisions, FP32 input / BF16 output and BF16 input / BF16 output. According to documentation ( here and here ), both engines have 128 compute lanes, matching the partition dimensions of PSUM and SBUF. For each cycle, ScalarE executes at 1 element per cycle, while VectorE at 2 FP32 elements / 4 BF16 elements per cycle. We sweep through different free dimension sizes while keeping partition dimension to 128, and the element process throughput is as below. Benchmarks show that ScalarE and FP32-input of VectorE quickly nears the theoretical throughput at around fdim=256, while it takes fdim=1024 for BF16-input to get to near 512 elements per cycle. As for instruction latency, ScalarE saturates quickly at fdim=16, after which latency scales with fdim, whereas VectorE saturates at fdim=64 for FP32 inputs and fdim=128 for BF16 inputs. Source: SemiAnalysis Source: SemiAnalysis nisa.exponential API offers many features relevant to FlashAttention, including subtract by max value for stable softmax, and input summation for running exponential sum calculations. We are delighted to see such ergonomic improvements. We further benchmarked activation functions commonly used in LLMs. All activation functions surprisingly perform identically, reaching near max 128 elements-per-cycle performance at fdim=256. Source: SemiAnalysis Source: SemiAnalysis Intra-Logical NeuronCore Communication Trainium supports grouping 2 physical NeuronCores into one Logical NeuronCore (LNC). Physically, an LNC maps to two NeuronCores that share an HBM stack. Physical NeuronCores within an LNC have two ways of communicating: exchanging data on SBUF through DMA engines and accessing the shared HBM with a semaphore mechanism. nisa.sendrecv implements the bi-directional data exchange, and it’s essentially a two-rank all-gather operation. sendrecv supports utilizing the main DMA engines and the ones in GpsimdE. sendrecv through GpsimdE (GpSIMD DMA) offers lower latency but has message size restrictions. Our benchmark shows GpSIMD DMA achieves up to 2.6x lower latency at a small message size of 512 bytes, but the speedup diminishes as message size increases, and the two transfer methods cross over at 32 KiB. For the main DMA engine, the latency greatly increases after 128 KiB message size, and the bandwidth nears saturation at 14 MiB, reaching 572 GB/s. We couldn’t increase the message size without errors, which is likely due to the SBUF size being 32 MiB. Source: SemiAnalysis Neuron also supports the all-reduce version, nisa.sendrecv_compute, where we pass in an NKI operator, and the NeuronCores perform a fused all-gather and reduce operation. Here we compare a naive sendrecv + tensor_tensor add setup with sendrecv_compute add. We see minor improvements for smaller message sizes but performance loss at large ones. Source: SemiAnalysis The shared HBM pattern is an all-gather that uses nl.shared_hbm to access the shared HBM and nisa.core_barrier to synchronize the NeuronCores. Both NeuronCores write their tiles from their own SBUF to the shared HBM, wait for the semaphore, and copy each other’s tiles from the shared HBM to their own SBUF. To understand the semaphore mechanism overhead, we also benchmark a local copy for a comparison. Source: SemiAnalysis Overall, the core barrier semaphore introduces 10-20% latency overhead. Compared to shared HBM + semaphore, sendrecv is the more performant option for doing 2-rank all-gather operations, as sendrecv skips HBM and transfers from SBUF to SBUF. The latency curve shows a peculiar dip around 8 KiB, and we investigate the reason. We hypothesize that the dip is due to the partition size matching the HBM burst write size. Smaller sizes trigger frequent read-modify-write operations, which adds to latency. On the other hand, data transfer time dominates latency for larger sizes. Partition size, rather than message size, appears to be the cause. When we hold the message size constant and vary the number of partitions and partition size, the latency drops 2-3x between partition size 16 bytes and 32 bytes. Source: SemiAnalysis Sweeping through partition sizes for the 128-partition configuration, we see latency drops for partition sizes that are multiples of 32. This implies the HBM write burst may be at 32 bytes. Source: SemiAnalysis Inter-LNC Collective Communications Neuron supports LNC-level communication, from intra-chip to full UltraServer, through the collective communication APIs nki.collectives. Using the Neuron collective benchmark nccom-test, we tested the major collective operations, including all-gather, all-reduce, reduce-scatter, and all-to-all. Intra-Chip LNC Collective Communication For intra-chip LNC, the NKI collectives API supports two types of data transfer source and destination: HBM to HBM and SBUF to SBUF. For the HBM-to-HBM collectives, we see the achieved bandwidth for all operations plateau at around 256 MiB message size and hold it up to 4 GiB. Which algorithm runs depends on Neuron’s collective algorithm selection. Neuron intra-node collective communications documentation says Neuron chooses different algorithms for different message sizes: Mesh for small message size, Recursive Doubling Halving (RDH) for medium, KangaRing for large, and Ring for backup. Source: Neuron Intra-node Collective Communications documentation On one chip, all-gather uses Mesh up to 2 MiB and RDH from 4 MiB. All-reduce, reduce-scatter and all-to-all stay on Mesh at every size we tested. SBUF to SBUF (sb2sb) collectives allocate the input, output, and buffers on SBUF instead of HBM. sb2sb avoids round trips to HBM, which is advantageous for communication-computation overlapped kernels to reduce latency. In our testing, we found sb2sb runs up to 24 MiB for all-gather, reduce-scatter and all-to-all, and up to 16 MiB for all-reduce, despite SBUF being 32 MiB in capacity; we believe the intermediate steps of collectives may require extra memory. Currently, sb2sb performs on par with HBM-to-HBM up to about 2 MiB. Above that, all-to-all stays on par, while the other three operations flatten and HBM keeps climbing. However, Amazon engineers are optimizing sb2sb collectives, and we expect the performance to rapidly improve in the future. Source: SemiAnalysis Cross-Node Collective Communications To show the scalability of Trainium3 on collective operations, we benchmarked the major collective operations with four world sizes: 1 chip (4-rank) as the baseline, 1 node (64-rank), 1 rack (128-rank), and 1 UltraServer (256-rank). We see chip-level collectives significantly outperform other world sizes, achieving roughly 1.5x to 3x the bandwidth at sizes below 16 MiB. The other three configurations perform similarly, with the 1-node setup performing slightly better at smaller message sizes. This shows the rack is designed to scale well without losing performance. For all-to-all, chip-level achieves about 9x to 10x the bandwidth of node and rack-level world sizes, meaning performing all-to-all within a chip is highly advantageous. Source: SemiAnalysis We will further test this in CollectiveX, which runs more complex, realistic collective patterns and will publicly launch in a few weeks. We compare the 2-node collective operation performance of different link types, including intra-rack NeuronLink, cross-rack peer NeuronLink, and cross-rack non-peer EFA. Overall, we see the NeuronLink types perform roughly the same, and intra-rack only visibly outperforms cross-rack at message sizes of 256 MiB and above. If we compare NeuronLink with EFA, NeuronLink types achieve about 1.65x the bandwidth. All-to-all is the unique case here: only intra-rack NeuronLink supports 128-rank all-to-all, while EFA supports a limited 2-rank 64-group all-to-all. Intra-rack NeuronLink reaches a max of 31 GB/s, while cross-rack non-peer EFA can only reach 8 GB/s. Source: SemiAnalysis Trainium3n In our AWS Trainium3 Deep Dive article , we explained the different network architectures of the Trainium3 NL32x2 Switched. We run all of our benchmarks on a Trainium3 NL32x2 Switched on gen1 switch trays , but in this section, we present the collective operation benchmark results of Trainium3 NL32x2 Switched on gen2 switch trays , comparing it with its gen1 counterpart. Gen1 uses 160-lane Astera Scorpio X switches to connect 32 chips in a rack, and the lane count constraints lead to a dual switch plane design. On the other hand, gen2, labeled as Trainium3n (trn3n) in AWS documentation, employs 320-lane Astera Scorpio X switches, and 8 switches form a single switch plane to connect all chips in a rack. Dual switch plane means some chips in a rack are two hops apart (a switch hop plus a tray link), whereas a single switch plane puts every chip in a rack one switch hop away. This theoretically lowers latency for node-level, rack-level, and UltraServer-level communications, and we show the experimental results below. At large message sizes, the Trainium3n design also raises bandwidth across all collective operations. Most notably, Trainium3n achieves a 2.8x bandwidth for all-to-all, which is very helpful to mixture-of-experts model workloads. Source: SemiAnalysis Latency tells the same story at small message sizes, where the time per operation is mostly fixed cost and not bandwidth. The largest gain is at rack level: on Trainium3n, a collective across the two nodes of a rack costs almost the same as one inside a single node for all-reduce and reduce-scatter, while gen1 pays a clear step for leaving the node. This is the removed switch hop showing up directly. The gain carries through to the full UltraServer, where both operations run about a fifth to a quarter faster than on gen1. SemiAnalysis All-to-all improves modestly at node and rack level. The only cross-rack all-to-all that runs is between two non-peer nodes in small 2-rank groups over EFA, and there the two generations are identical, at about three times the in-rack latency. Intra-Chip and Scale Up Cycle Latency and Bandwidth Topology Intra-Chip NeuronCore to NeuronCore Source: SemiAnalysis A Trainium3 chip is 2 dies of 2 SENGs each. A SENG, short for “shared engine”, is two NeuronCores sharing one HBM stack, so a chip has 8 cores and 4 stacks. Each core also has its own SRAM: SBUF for a kernel’s working tiles and PSUM for matrix-multiply partial sums. An HBM stack serves only its own pair of cores, so the pair never competes with the others for memory bandwidth. The cost is four separate HBM domains per chip: data needed outside its SEngine has to be moved by a DMA copy or a collective. In the core-to-core exchange latency/BW diagram, we can see transfers within SENGs being faster, and cross die being slowest, due to no diagonal links. Source: SemiAnalysis Node Level Cycle Latency and Bandwidth Topology As we covered in our previous Trainium3 article, the two chips in a tray are linked directly, and trays are joined through two switch planes per rack: one for the even-numbered chips and one for the odd-numbered chips. Traffic between an even chip and an odd chip in different trays therefore takes an extra hop, which shows up as a checkerboard pattern in the chip-to-chip matrix. Source: SemiAnalysis Newer racks use a single-plane design instead, where one switch plane connects all 32 chips in the rack. These use the Gen2 PCIe switch trays, removing the checkerboard pattern. Source: SemiAnalysis UltraServer Rack Scale Cycle Latency and Bandwidth Topology


Read more


Read original article