Skip to main content

Module runtime_fused_kernels

Module runtime_fused_kernels 

Source
Expand description

Runtime fused-op kernel registration — the adopt/gate facade over the ONE binding registry.

The transitional FusedOpId-keyed kernel sidecar that used to live here is folded (the 2026-07-08 decisions-log end-state): a runtime kernel now registers into the global binding table (crate::dispatch::extend_global_bindings) under BindingKey::RuntimeFused, exactly like a startup kernel registers under BindingKey::Static — same table, same entry shape, same dtype-keyed dispatch lookup. This module keeps the runtime-op-shaped API (adopt_runtime_fused, fused_kernel_available, lookup_runtime_kernel) so callers stay id-oriented, but there is no second registry behind it.

Cost note: a runtime row is stored with the binding-native unknown_cost sentinel (never a lying zero). Deriving its Layer-1 estimate from the op’s recipe (decompose_region, keyed by the RuntimeFused id in the binding key — no stored closure needed) is the plan-path pricing follow-up; today a runtime arm is sparse-skip unpriced there, which is safe (arm 0 stays the runnability fallback).

Structs§

RuntimeKernelBinding
A runtime-fused binding row, as lookup_runtime_kernel returns it — a diagnostic/test view (dispatch resolves dtype-precisely through the binding table itself; see compile_one’s is_runtime arm).

Enums§

FusedLookupMiss
Why a runtime-fused lookup returned no kernel. Two distinct facts, kept distinct: an Option would make them indistinguishable, and they have different fixes — not bound means register one, ambiguous means say which signature you want.

Functions§

adopt_runtime_fused
Adopt a synthesized/imported runtime fused op: register its recipe (the region) in the fuel-graph metadata sidecar and bind its kernel in the global binding table, then return the freshly-allocated runtime FusedOpId. After this the capability gate sees the op as fusable on backend, and the executor’s is_runtime arm resolves it dtype-precisely from the same table every static kernel lives in.
fused_kernel_available
The capability predicate the optimizer’s gate consults: is there an admissible kernel for (id, backend) — static or runtime-registered? The dispatch layer passes |id| fused_kernel_available(id, backend) to capability_gated_rules, so a runtime op fuses only once its kernel is bound. Id-level (coarse) by design; the dtype-precise check is the dispatch-time binding lookup itself.
fused_kernel_available_in
Table-passing variant of fused_kernel_available — reads the CALLER’S binding table (the one optimize_graph already holds, threaded via OptimizationContext::bindings) instead of re-acquiring global_bindings(). This is the non-nesting gate: a background adopt’s global_bindings() WRITE can never queue between two reads this function takes, because it takes none — table is a plain reference the caller already resolved.
lookup_runtime_kernel
The runtime-fused binding for (id, backend) when exactly one dtype tuple is registered.
register_runtime_kernel
Bind a kernel for a runtime fused op (id >= RUNTIME_FUSED_BASE) into the global binding table under BindingKey::RuntimeFused(id). dtypes is the per-operand tuple (inputs in order, then output) — the same key shape every static registration uses.