Skip to main content

Crate fuel_quantized

Crate fuel_quantized 

Source
Expand description

Backend-agnostic quantized (ggml/gguf block-format) numerics.

This crate owns the format-side of fuel’s quantization stack:

  • k_quants — BlockQX block types, the GgmlType trait, and scalar reference impls of every fmt fuel supports.
  • [avx] / [neon] — cfg-gated CPU SIMD vec_dot helpers used by GgmlType::vec_dot impls in k_quants. They live here (rather than in fuel-cpu-backend) because the orphan rule pins them to the crate that defines BlockQX.
  • utils — quantization-time helpers shared by k_quants impls.
  • cpu — CPU-side adapters that bridge Vec<BlockQX> to the backend-agnostic fuel_backend_contract::quantized::DynQuantizedStorage trait, plus the QuantizedDeviceKernels impl on fuel_cpu_backend::CpuBackendDevice.

Per-backend (CUDA, Metal, future Vulkan) quantized fast paths live in their own crates and implement the same trait pair from fuel-core-types.

Re-exports§

pub use cpu::QuantizedType;
pub use cpu::cpu_from_data;
pub use cpu::cpu_zeros;
pub use dequant::dequant_ggml_bytes;
pub use k_quants::BlockQ2K;
pub use k_quants::BlockQ3K;
pub use k_quants::BlockQ4_0;
pub use k_quants::BlockQ4_1;
pub use k_quants::BlockQ4K;
pub use k_quants::BlockQ5_0;
pub use k_quants::BlockQ5_1;
pub use k_quants::BlockQ5K;
pub use k_quants::BlockQ6K;
pub use k_quants::BlockQ8_0;
pub use k_quants::BlockQ8_1;
pub use k_quants::BlockQ8K;
pub use k_quants::GgmlType;
pub use k_quants::K_SCALE_SIZE;
pub use k_quants::QK_K;
pub use k_quants::QK4_0;
pub use k_quants::QK4_1;
pub use k_quants::QK5_0;
pub use k_quants::QK5_1;
pub use k_quants::QK8_0;
pub use k_quants::QK8_1;
pub use k_quants::blocks_as_bytes;
pub use k_quants::blocks_from_bytes_cow;
pub use k_quants::matmul;
pub use k_quants::matmul_f16;

Modules§

cpu
Format-agnostic CPU helpers for quantized storage.
dequant
Byte-to-f32 dequantization dispatched on GgmlDType, for callers holding a raw GGUF tensor byte slice and its declared dtype (the common shape at a model-loader’s from_gguf site).
k_quants
utils

Enums§

GgmlDType
The ggml block-format dtype tag. Mirrors llama.cpp’s ggml_type @9d57ce456c for the subset fuel supports (the classic 15 — F32/F16/BF16 plus Q4_0..Q8_1 and Q2K..Q8K; NOT the IQ*/TQ*/MXFP4/NVFP4 families).

Traits§

DynQuantizedStorage
Object-safe per-backend quantized storage. Each backend (CPU, CUDA, Metal, …) supplies a concrete type that implements this trait; fuel-core holds them as Box<dyn DynQuantizedStorage> and dispatches without naming backends.
QuantizedDeviceKernels
Backend device → quantized-kernel constructors. fuel-core looks this up per Device to allocate fresh QStorage of a given dtype, or to load pre-quantized bytes.