pub struct CudaKnobs {
pub gemv_load: LoadWidth,
pub precision: MatmulPrecision,
pub kv_cache: bool,
pub cuda_graphs: bool,
pub fuse_quant: bool,
pub activations: Q8MatKind,
pub chip: CudaChip,
pub recurrent_state: StatePrecision,
pub cache_precision: CachePrecision,
}Expand description
The CUDA backend’s optimization knobs — one point in the lattice. Construct with CudaKnobs::default
for the best-general point and flip individual knobs to trade off. Every field is a trade-off; there are
deliberately no fields for strictly-better transforms (those are always applied, see STRICTLY_BETTER).
Fields§
§gemv_load: LoadWidthWeight-load width for GEMV/GEMM. Default LoadWidth::Int4 (measured best-general on the projections).
precision: MatmulPrecisionContraction precision. Default MatmulPrecision::Auto (⇒ always-correct int64).
kv_cache: boolKV-cache for autoregressive generation — skip recomputing past K/V. A large win for generation, but
costs VRAM and only applies to attention over a growing sequence. Default true.
cuda_graphs: boolCapture the steady-state (T=1) step as a CUDA graph and replay it — collapses ~540 launches/token to
one. Wins when many tiny kernels make launch latency dominate; neutral-to-negative for one big kernel.
Default true.
fuse_quant: boolFuse activation-quantization into the preceding norm/elementwise kernel — saves a global round-trip at
the cost of a slightly larger, less-reusable kernel. Default true.
activations: Q8MatKindThe activation precision of a projection by Q8_0 weights in the compiled generation lane: f32 activations
with f64 sums (Dequant), a high and a low int8 word per value (TwoPassInt8, ~14 bits), or one int8 word
(Int8Act, llama.cpp’s precision). Default Q8MatKind::TwoPassInt8.
chip: CudaChipThe GPU part this kernel targets — its SM arch, shared-memory budget, and realized precisions. Default
CudaChip::rtx3060 (the local dev GPU). Flipping it to CudaChip::b200 retargets the SAME
recognized op to Blackwell. A trade-off (portability vs hardware exploitation), hence a knob.
recurrent_state: StatePrecisionThe precision the compiled generation lane stores a gated-delta layer’s recurrent memory in between steps:
f32, or bf16 — computed in f32, rounded to bf16 after every row the delta rule walks. Default
StatePrecision::F32.
cache_precision: CachePrecisionThe precision the compiled generation lane stores an attention’s key and value cache in: f32, or binary16 —
each row computed in f32 and rounded to the nearest as it is written, every read of the cache taking the
rounded row. Default CachePrecision::F32.
Implementations§
Source§impl CudaKnobs
impl CudaKnobs
Sourcepub fn fabric_precision(&self) -> Precision
pub fn fabric_precision(&self) -> Precision
Map a MatmulPrecision to the fabric-level Precision descriptor (for FabricTarget gating).
Sourcepub fn tradeoffs() -> &'static [KnobTradeoff]
pub fn tradeoffs() -> &'static [KnobTradeoff]
The trade-off table — one row per knob, each naming the regime where the aggressive setting wins and the regime where it loses (the reason it can’t be baked in unconditionally). This is the lattice’s map; the knob-lattice lock asserts it stays complete and honest.
Trait Implementations§
impl Copy for CudaKnobs
impl Eq for CudaKnobs
impl StructuralPartialEq for CudaKnobs
Auto Trait Implementations§
impl Freeze for CudaKnobs
impl RefUnwindSafe for CudaKnobs
impl Send for CudaKnobs
impl Sync for CudaKnobs
impl Unpin for CudaKnobs
impl UnsafeUnpin for CudaKnobs
impl UnwindSafe for CudaKnobs
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.