pub struct Candidate {
pub kernel: KernelRef,
pub caps: KernelCaps,
pub backend: BackendId,
pub device: DeviceLocation,
pub precision: PrecisionGuarantee,
pub static_cost: CostEstimate,
pub inbound_transfer_ns: u64,
pub op_params: OpParams,
pub coupling: Vec<CouplingAdjustment>,
pub kernel_source: &'static str,
pub kernel_revision_hash: u64,
}Expand description
One concrete dispatch alternative the ranker is considering for a
graph decision point. Pre-resolved at plan time — by the time a
Candidate exists, the binding-table lookup has happened and the
KernelRef is in hand.
All fields are explicit on purpose: every successor phase (cost composition, executor consumption, runtime selection) reads from these fields by name, and adding a field is preferable to adding a derived getter.
§Where it comes from
Phase 1.2 (compile_plan successor) builds candidates by walking
crate::topology::SystemTopology-equivalent metadata: for each
DeviceLocation the graph node may run on, enumerate co-located
BackendIds, then for each (op_kind, dtypes, backend) triple
pull every entry from crate::kernel::KernelBindingTable::lookup_alternatives.
Each entry contributes one Candidate.
Fields§
§kernel: KernelRefPre-resolved kernel function pointer.
caps: KernelCapsCapability flags the executor reads to decide auto-Contiguize.
backend: BackendIdWhich backend this candidate runs on.
device: DeviceLocationSpecific device within backend.
precision: PrecisionGuaranteeWhat this kernel claims about its numerical behavior. Hard filters consume this to enforce user precision floors and tolerance budgets.
static_cost: CostEstimateLayer-1 static cost estimate (FLOPs + bandwidth + launch overhead) computed against the decision point’s input shapes. Phase 1.4’s cost composition reads this; Phase 3’s Judge integration refines it with Layer-2 measurements.
inbound_transfer_ns: u64Planner Stage-2 inbound-transfer term: estimated nanoseconds
to move this decision point’s inputs from their committed
residencies onto device, summed over every input whose
residency differs from device. Populated by
super::cost::apply_inbound_transfer_costs when a
TransferEstimator is threaded through PlanOptions; zero
when all inputs are co-resident, residency is unknown, or no
estimator is configured. Kept separate from static_cost so
Layer-2 Judge refinement (which REPLACES the kernel-time
estimate) never clobbers the transfer term — ranking adds the
two (composite_ns(static_cost) + inbound_transfer_ns).
op_params: OpParamsThe op-specific parameter payload that will accompany this
kernel call. Cloned here so the candidate is self-contained
for plan-time reasoning. Most ops carry OpParams::None.
coupling: Vec<CouplingAdjustment>Cost adjustments contingent on adjacent decision points’ resolutions — e.g. “this CUDA candidate’s cost is +2ms if the downstream join falls back to CPU.” Empty in Phase 1.1; Phase 2 populates it when transfer-op cost coupling lands. See architecture v1.0 §04 “Coupling between decisions” for the long-term shape.
kernel_source: &'static strDiagnostic tag identifying the kernel’s implementation source
(e.g. "portable-cpu", "aocl", "mkl", "cublas").
Copied from the BindingEntry::kernel_source of the binding
this candidate was enumerated from. Never used for dispatch —
the picker distinguishes candidates by kernel (function-
pointer identity). Surfaces in Judge telemetry and selector
diagnostics so logs can name which kernel won at a decision
point even when several share (backend, device).
kernel_revision_hash: u64Content-derived revision of this candidate’s kernel build, copied
from the same BindingEntry::kernel_revision_hash as
kernel_source. Together they form the variant-granular identity
the Judge oracle keys on, so the cost composer’s
measured_latency_ns lookup hits the cell measured for THIS
build rather than a sibling that shares the kernel_source tag.
0 for synthetic candidates and untracked kernels.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Candidate
impl RefUnwindSafe for Candidate
impl Send for Candidate
impl Sync for Candidate
impl Unpin for Candidate
impl UnsafeUnpin for Candidate
impl UnwindSafe for Candidate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more