This document is relevant for: Trn2, Trn3
NKI Tutorials
This section provides hands-on tutorials for the Neuron Kernel Interface (NKI), demonstrating how to write custom kernels for AWS Trainium and Inferentia instances. These tutorials cover fundamental operations, advanced techniques, and distributed computing patterns using NKI.
The full source code of the following tutorials can be also viewed on the
nki-samples repository on GitHub.
Tiled-grid programming
Introduction to Tile grid semantics for writing NKI kernels
Advanced topics for Tile grids including support for
indirect indexing, sharding and transpose
Introduction to Block grids
Writing efficient kernels by overlapping compute with memory transfers
End to end MLP kernel using Tile based programming
Basic Operations
Learn the fundamentals of implementing matrix multiplication in your NKI kernels.
Implement efficient 2D matrix transpose operations using NKI
Create custom 2D average pooling kernels for computer vision workloads
Advanced Kernels
Implement fused Mamba state space model kernels
Learn the recommended workflow for optimizing NKI kernels using profiling and performance analysis
This document is relevant for: Trn2, Trn3