Skip to main content

Candidate

Struct Candidate 

Source
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: KernelRef

Pre-resolved kernel function pointer.

§caps: KernelCaps

Capability flags the executor reads to decide auto-Contiguize.

§backend: BackendId

Which backend this candidate runs on.

§device: DeviceLocation

Specific device within backend.

§precision: PrecisionGuarantee

What this kernel claims about its numerical behavior. Hard filters consume this to enforce user precision floors and tolerance budgets.

§static_cost: CostEstimate

Layer-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: u64

Planner 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: OpParams

The 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 str

Diagnostic 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: u64

Content-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§

Source§

impl Clone for Candidate

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Candidate

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more