This document is relevant for: Trn2, Trn3

nki.isa.NkiInstruction#

class nki.isa.NkiInstruction(handle)[source]#

Opaque handle to a traced NKI instruction.

Returned by nki.isa operations during tracing. Use .depends_on(*producers, kind=...) to add runtime or scheduling-only dependencies.

Methods

depends_on

Run this instruction after each producer.

depends_on(*producers: NkiInstruction, kind: Optional[dependency] = None) → NkiInstruction[source]#

Run this instruction after each producer.

kind takes a nki.isa.dependency member.

Returns self, so the two forms compose:

c.depends_on(b, a, kind=dependency.runtime)
c.depends_on(b, kind=dependency.runtime).depends_on(
    a, kind=dependency.runtime
)

Omitting kind preserves the previous release’s behavior and is deprecated; a future release will require it. Pass kind=dependency.runtime or kind=dependency.schedule to choose.

kind=dependency.runtime lowers to a hardware semaphore wait that orders the pair across engines. Because that wait fires unconditionally, both instructions must sit at the same dynamic-loop nesting (or the producer in an enclosing scope).

kind=dependency.schedule adds an ordering constraint for the compiler schedulers but emits no hardware synchronization. It constrains instruction issue order; instructions on different engines may still overlap.

This document is relevant for: Trn2, Trn3