.. _nki_deep-dives_home:

.. meta::
    :description: Documentation home for the AWS Neuron SDK NKI Deep Dives and other advanced materials.
    :keywords: NKI, AWS Neuron, Deep Dives, Advanced Programming
    :date-modified: 12/01/2025

NKI Deep Dives
==============

This section provides in-depth technical documentation and guides for advanced users of the Neuron Kernel Interface (NKI). These deep dives offer detailed explanations of NKI concepts, programming patterns, and best practices to help you maximize the performance and capabilities of your NKI code on AWS Neuron devices.

Optimizing a NKI Kernel
-----------------------

.. grid:: 2
   :margin: 4 1 0 0

   .. grid-item-card:: NKI Performance Optimizations
      :link: nki_perf_guide
      :link-type: ref
      :class-body: sphinx-design-class-title-small

Advanced NKI Programming
------------------------

.. grid:: 1
   :gutter: 3

   .. grid-item-card:: MXFP4/8 Matrix Multiplication Guide
      :link: mxfp-matmul
      :link-type: doc
      :class-body: sphinx-design-class-title-small

      Perform matrix multiplication using MXFP8 data types in NKI kernels, including data layout, quantization, and tiling strategies.

   .. grid-item-card:: MXFP8 Matmul Kernel Deep Dive
      :link: mxfp-matmul-kernel
      :link-type: doc
      :class-body: sphinx-design-class-title-small

      How the NKI Library MXFP8 matmul kernel blocks, tiles, loads and quantizes its operands, and how the fused backward, MoE and MLP kernels reuse it.

   .. grid-item-card:: NKI Compiler
      :link: nki_compiler_about
      :link-type: ref
      :class-body: sphinx-design-class-title-small

      Learn about the NKI Compiler.

   .. grid-item-card:: NKI Control Flow
      :link: nki-control-flow
      :link-type: ref
      :class-body: sphinx-design-class-title-small

      Learn about loops and conditionals in NKI.

   .. grid-item-card:: Descriptor Generation Engine (DGE)
      :link: dge-documentation
      :link-type: ref
      :class-body: sphinx-design-class-title-small

      Control how DMA descriptors are generated: pre-computed, software (GpSimd), or hardware DGE.

   .. grid-item-card:: DMA Bandwidth Guide
      :link: nki-dma-bandwidth-guide
      :link-type: ref
      :class-body: sphinx-design-class-title-small

      Guidelines for maximizing DMA bandwidth with large contiguous payloads.

   .. grid-item-card:: NKI Scalar Values
      :link: nki-scalar
      :link-type: ref
      :class-body: sphinx-design-class-title-small

      Read integers on device with nki.isa.scalar_load, and use them as dynamic offsets and loop bounds.

   .. grid-item-card:: NKI Access Patterns
      :link: nki-aps
      :link-type: ref
      :class-body: sphinx-design-class-title-small

      Learn about Access Patterns (AP) to directly specify how the Trainium hardware accesses tensors.

   .. grid-item-card:: NKI Tensor Indirection
      :link: nki-tensor-indirection
      :link-type: ref
      :class-body: sphinx-design-class-title-small

      Gather or scatter columns of an on-chip tensor inside one compute instruction, at offsets read at run time.

   .. grid-item-card:: NKI compile configuration
      :link: nki-compile-config
      :link-type: ref
      :class-body: sphinx-design-class-title-small

      How NKI allocation and scheduling work, and what each CompileConfig optimization changes in the compiled kernel.

   .. grid-item-card:: NKI Standalone
      :link: nki-standalone
      :link-type: ref
      :class-body: sphinx-design-class-title-small

      Run a kernel from plain Python with NumPy inputs and outputs, on one
      or more NeuronCores, without a framework or model.


Additional NKI Information
--------------------------

.. toctree::
    :maxdepth: 1
    :hidden:

    Performance Optimizations <nki_perf_guide>
    MXFP8/4 Matrix Multiplication <mxfp-matmul>
    MXFP8 Matmul Kernel Deep Dive <mxfp-matmul-kernel>
    NKI Access Patterns <nki-aps>
    NKI Tensor Indirection <nki-tensor-indirection>
    NKI Control Flow <nki-control-flow>
    NKI Scalar Values <nki-scalar>
    Descriptor Generation Engine (DGE) <nki-dge>
    DMA Bandwidth Guide <nki-dma-bandwidth-guide>
    NKI compile configuration <nki-compile-config>
    NKI Standalone <nki-standalone>
    nki-compiler
