This document is relevant for: Trn2, Trn3
nki.isa#
The nki.isa module exposes low-level ISA instructions for compute, data movement, and synchronization.
These APIs map to individual Tensor Engine, Vector Engine, Scalar Engine, and DMA Engine operations,
giving you fine-grained control over the underlying hardware capabilities.
NKI ISA#
Compute |
|
Compute matrix multiplication of MXFP8/MXFP4 quantized matrices with integrated dequantization using Tensor Engine. |
|
Perform a 2D transpose between the partition axis and the free axis of input |
|
Apply an activation function on every element of the input tile using Scalar Engine or GpSIMD Engine (on NeuronCore-v3+), with an optional scale/bias operation before the activation and an optional reduction operation after the activation in the same instruction (on Scalar Engine). |
|
Perform the same computation as |
|
Perform tensor activation with configurable tensor-scalar operations and optional reduction using Scalar Engine or GpSIMD Engine (on NeuronCore-v4+). |
|
Apply a reduction operation to the free axes of an input |
|
Apply a reduction operation across partitions of an input |
|
Perform an element-wise operation of input two tiles using Vector Engine or GpSimd Engine. |
|
Perform a scan operation of two input tiles using Vector Engine. |
|
Apply two math operators in sequence using Vector Engine: |
|
Apply up to two math operators to the input |
|
Perform the same computation as |
|
Perform tensor-scalar arithmetic operation with cumulative reduction using Vector Engine. |
|
Create a copy of |
|
Conditionally copy elements from the |
|
Apply exponential function to each element after subtracting a max_value using Vector Engine. |
|
Compute element-wise reciprocal (1.0/x) of the input |
|
Quantize FP16/BF16 data to MXFP8 tensors (both data and scales) using Vector Engine. |
|
Generate a constant literal pattern into SBUF using GpSimd Engine. |
|
Randomly replace some elements of the input tile |
|
Select elements between an input tile |
|
Select elements from |
|
Selectively copy elements from either |
|
Compute the sequence bounds for a given set of segment IDs using GpSIMD Engine. |
|
Initialize |
|
Compute mean- and variance-related statistics for each partition of an input tile |
|
Aggregate one or multiple |
|
Gather SBUF data in |
|
Gather elements from |
|
Copy data from |
|
Perform a transpose on input |
|
Perform math operations using compute logic inside DMA engines with element-wise scaling and reduction. |
|
Find the 8 largest values in each partition of the source tile. |
|
Find indices of the 8 given vals in each partition of the data tensor. |
|
Replace first occurrence of each value in |
|
Apply cross-partition data movement within a quadrant of 32 partitions from source tile |
|
Allocate a virtual register and optionally initialize it with a value. |
|
Load a scalar value from memory (HBM or SBUF) into a virtual register. |
|
Move a value into a virtual register. |
|
Store the value from a virtual register into memory (HBM/SBUF). |
|
Load a scalar value from a 1x1 tensor. |
|
Store a scalar value to a 1x1 tensor in memory. |
|
Apply a binary integer operation to two scalar values. |
|
Generate pseudo random numbers using the Vector or GpSimd Engine. |
|
Generate pseudo random numbers with uniform distribution using Vector Engine. |
|
Seed the pseudo random number generator (PRNG) inside the engine. |
|
Store the current pseudo random number generator (PRNG) states from the engine. |
|
Seed the pseudo random number generator (PRNG) inside the Vector Engine. |
|
Find indices of nonzero elements in an input tensor and their total count using GpSimd Engine. |
|
Find the k largest values and their indices in each 16-partition group using GpSIMD Engine. |
LNC compatibility APIs#
These entry points are deprecated in favor of the nki.lnc APIs.
They remain available for existing kernels and emit DeprecationWarning at
the call site. Migrate to the corresponding nki.lnc API. The legacy
pipe_id argument to nki.isa.sendrecv remains ignored; remove it when
migrating to nki.lnc.sendrecv.
Synchronize execution across physical NeuronCores sharing an HBM stack. |
|
Perform point-to-point communication between NeuronCores by sending and receiving data simultaneously using DMA engines. |
|
Perform point-to-point communication between NeuronCores and reduce the local and received tiles into a single result, using the DMA engine's reduction capability. |
NKI ISA Config Enums#
Neuron Device engines. |
|
DMA transfer engine. |
|
Engine register reduce commands. |
|
Instruction dependency kind. |
|
Descriptor Generation Engine mode. |
|
Out-of-bounds access mode. |
|
Performance mode for matmul. |
Target#
NeuronCore version. |
|
Returns the nc_version of the current target context. |
Constants#
NkiScalar is the core scalar type in NKI. |
|
A virtual register on engine. |
|
Handle or named reference to a NKI instruction. |
Scheduling references#
Reference an instruction by its name or tensor debug names. |
This document is relevant for: Trn2, Trn3