This document is relevant for: Trn2, Trn3

nki.simulate#

nki.simulate(kernel)[source]#

Create a CPU-simulated version of an NKI kernel.

Warning

This API is experimental and may change in future releases.

See NKI CPU Simulator for full documentation including target platform selection, precise floating-point mode, debugging, and known limitations.

Example:

import os

@nki.jit
def my_kernel(a, b): ...

# Explicit simulation
result = nki.simulate(my_kernel)(a_np, b_np)

# With LNC2
os.environ["NEURON_LOGICAL_NC_CONFIG"] = "2"
result = nki.simulate(my_kernel)(a_np, b_np)
Parameters:

kernel – NKI kernel function, typically decorated with @nki.jit. If a plain function is passed, it is automatically wrapped.

Returns:

A callable that, when invoked with NumPy arrays or torch Tensors, executes the kernel on CPU and returns results in the same format (NumPy arrays or torch Tensors respectively).

This document is relevant for: Trn2, Trn3