pub trait BackendCaps {
const ID: Backend;
const NAME: &'static str;
const GEMM_FALLBACK: &'static str;
// Required methods
fn matvec_kernel(kind: QuantKind) -> Option<&'static str>;
fn gemm_supported(kind: QuantKind) -> bool;
}Expand description
What a backend can run, asked without the backend crate present.
Every member is an associated function with no receiver, which is what the free functions this replaced already were, so implementing it is a lift rather than a redesign.
Required Associated Constants§
Sourceconst ID: Backend
const ID: Backend
How crate::kernel_registry reports this backend. Dispatch and
observability read the same constant, so a backend cannot be
dispatched to under one name and reported under another.
Sourceconst GEMM_FALLBACK: &'static str
const GEMM_FALLBACK: &'static str
What a batched prefill actually runs on for a kind this backend
has a matvec but no GEMM for — the string
probe_kernels_for records as the fallback.
It lives here because it is a property of the backend and it was
previously a match backend arm inside probe_kernels_for: a
third Backend variant would have silently inherited Metal’s
wording ("Metal N x matvec batch") by falling through _, and
the registry’s whole job is to name the path that will really
run. Ungated, like the rest of BackendCaps, because the
probe is ungated.
Required Methods§
Sourcefn matvec_kernel(kind: QuantKind) -> Option<&'static str>
fn matvec_kernel(kind: QuantKind) -> Option<&'static str>
Which quant kinds have a matvec kernel (the decode path), as
the kernel name the backend’s own launch-meta table is keyed by,
or None for a kind with no kernel.
Returning the name rather than a bool is what let the two
backends share one member: CUDA only ever needed the bool
(.is_some()), Metal needs the name to look up
ferrox_metal::gpu::matvec_launch_meta, and a bool cannot be
widened after the fact without another table.
Sourcefn gemm_supported(kind: QuantKind) -> bool
fn gemm_supported(kind: QuantKind) -> bool
Which quant kinds have a batched GEMM (the prefill path). A
kind with a matvec but no GEMM still runs on the accelerator — as
batch separate matvecs over the same weights, which is the
13.7x shape, and which is why these are two predicates and not
one.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".