Skip to main content

BackendCaps

Trait BackendCaps 

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

Source

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.

Source

const NAME: &'static str

Human-readable name, for the one message a dispatch failure prints.

Source

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§

Source

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.

Source

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".

Implementors§

Source§

impl BackendCaps for Cuda

Source§

const ID: Backend = Backend::Cuda

Source§

const NAME: &'static str = "CUDA"

Source§

const GEMM_FALLBACK: &'static str = "CUDA per-position matvec"

Source§

impl BackendCaps for Metal

Source§

const ID: Backend = Backend::Metal

Source§

const NAME: &'static str = "Metal"

Source§

const GEMM_FALLBACK: &'static str = "Metal N x matvec batch"

Source§

impl BackendCaps for Vulkan

Source§

const ID: Backend = Backend::Vulkan

Source§

const NAME: &'static str = "Vulkan"

Source§

const GEMM_FALLBACK: &'static str = "CPU apply_batch"