This document is relevant for: Trn2, Trn3

nki.lnc#

LNC communication#

The nki.lnc module provides data exchange, reduction, and synchronization between the paired physical NeuronCores that share an HBM stack. sendrecv and sendrecv_compute communicate within a Logical NeuronCore and require LNC degree 2. core_barrier synchronizes the paired cores at LNC degree 1 or 2. At LNC degree 1, each physical core forms a separate Logical NeuronCore, but the pair can still access shared HBM and use the barrier to wait for each other’s writes.

sendrecv and sendrecv_compute accept a priority from 0 (highest) to 3 (lowest) to control DMA quality of service on NeuronCore-v4 or newer. sendrecv requires priority=None when using nki.isa.dma_engine.gpsimd_dma; explicit priorities are rejected.

The corresponding nki.isa entry points are deprecated compatibility wrappers. They remain available for existing kernels and emit DeprecationWarning at the call site. Use the nki.lnc APIs when migrating or writing new kernels. nki.lnc.sendrecv has no pipe_id argument; remove it when migrating from nki.isa.sendrecv, where it remains ignored.

core_barrier

Synchronize execution across physical NeuronCores sharing an HBM stack.

sendrecv

Perform point-to-point communication between NeuronCores by sending and receiving data simultaneously using DMA engines.

sendrecv_compute

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.

This document is relevant for: Trn2, Trn3