Expand description
Compiled-node representation. Phase 7.5 B4 (interface only).
A CompiledNode is the output of dispatch resolution: a Node
plus its resolved kernel function pointer plus its OpParams.
The executor consumes these and runs them.
§Design intent: pipelined compile + execute (deferred)
The original B-plan called for pipelined compilation: a compiler
thread that walks the graph in topological order, resolves
kernels per node, and pushes CompiledNode entries onto a
crossbeam::channel. An executor thread consumes the channel,
looks up inputs from the graph’s storage map (blocking when
inputs aren’t yet realized), calls the kernel, and stores the
output back. Time-to-first-token wins because the compiler runs
ahead of the executor.
Today’s “compile” step is just a KernelBindingTable lookup —
roughly nanoseconds per node. There’s no meaningful work to
overlap with execution. Pipelining adds std::thread +
crossbeam::channel + lifecycle handling for zero current win.
When compile grows beyond trivial — residency-aware planning,
transfer-cost minimization, kernel auto-tuning, dynamic-shape
specialization — pipelining lands as a follow-up. The
interfaces in this module (CompiledNode +
compile_node + execute_compiled) are designed so the
threaded variant slots in without changing call sites.
Modules§
- op_
profile - Opt-in per-
(OpKind, BackendId)host-time accounting for kernel launches (execute_compiled_with_wait_hint). Off by default (one relaxed atomic load per launch). What it measures: wall time of the kernel call on the HOST. A kernel that only enqueues work (Vulkan batches into a command buffer, CUDA launches on a stream) is charged its enqueue cost, NOT its device time; a kernel that blocks (CPU math, a host-to-device upload, a forced flush) is charged all of it. Device time lands wherever the realize finally waits, so compare the per-op sum with the caller’s own wall clock around a step.
Structs§
- Compiled
Node - A graph node plus its resolved kernel function pointer and
op-specific parameters. Produced by
compile_node; consumed byexecute_compiled.
Enums§
- Completion
Handle - A node’s completion signal, returned by
execute_compiled. Step E Phase A1 foundation: today every dispatch is synchronous, so this is alwaysCompletionHandle::Ready(the work finished before the call returned) and callerswaitit immediately — byte-identical to the priorResult<()>. Phases A2/A3 add an async GPU path that returnsCompletionHandle::Pendingcarrying a device fence/event the executor defers the wait on.
Traits§
- Completion
- An async-dispatch completion signal — a backend’s wrapper over a CUDA event / Vulkan fence so the executor can defer the wait past the submit point (Step E Phase A2/A3). No implementors today; all dispatch is synchronous.
Functions§
- compile_
node - Resolve a node’s kernel from the binding table and return a
CompiledNodeready for execution. Production-correct: surfacesNoBackendForOpif the table doesn’t have a binding for the requested triple. - dispatched_
kernel_ ident - The
(kernel_source, kernel_revision_hash)identity of the kernel the executor dispatches fornode, derived from the SAME graph stamp + registry the executor resolves through:op_to_op_kind+build_lookup_dtypes+graph.target_backend→ the first-registered binding at(op, dtypes, backend)(the entrycompile_node’slookup_with_capspicks).Nonewhen the node has no dispatch mapping (view/structural op) or no registered binding. - execute_
compiled - Run a compiled node against the given inputs/outputs. The output
Storages must be pre-allocated (the executor’s responsibility, using the node’s shape + dtype). - execute_
compiled_ with_ wait_ hint - Step E A4b open question #4 — “event only where waited”. Identical to
execute_compiledexcept the caller supplieswill_be_waited: whether ANY later step in this realize will individually wait this node’s completion handle before the realize-end drain (today: the cross-deviceCopy/Moveproducer wait,wait_producer_handleinpipelined.rs).