Skip to main content

fuel_quantized/
lib.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2//! Backend-agnostic quantized (ggml/gguf block-format) numerics.
3//!
4//! This crate owns the format-side of fuel's quantization stack:
5//!
6//! - [`k_quants`] — `BlockQX` block types, the [`GgmlType`](k_quants::GgmlType)
7//!   trait, and scalar reference impls of every fmt fuel supports.
8//! - [`avx`] / [`neon`] — cfg-gated CPU SIMD `vec_dot` helpers
9//!   used by `GgmlType::vec_dot` impls in `k_quants`. They live here (rather
10//!   than in `fuel-cpu-backend`) because the orphan rule pins them to the
11//!   crate that defines `BlockQX`.
12//! - [`utils`] — quantization-time helpers shared by k_quants impls.
13//! - [`cpu`] — CPU-side adapters that bridge `Vec<BlockQX>` to the
14//!   backend-agnostic [`fuel_backend_contract::quantized::DynQuantizedStorage`]
15//!   trait, plus the `QuantizedDeviceKernels` impl on
16//!   `fuel_cpu_backend::CpuBackendDevice`.
17//!
18//! Per-backend (CUDA, Metal, future Vulkan) quantized fast paths live in
19//! their own crates and implement the same trait pair from
20//! `fuel-core-types`.
21
22#[cfg(target_feature = "avx2")]
23pub mod avx;
24pub mod cpu;
25pub mod dequant;
26pub mod iq4;
27pub mod iq_grid_types;
28pub mod iq_grids;
29pub mod k_quants;
30#[cfg(target_feature = "neon")]
31pub mod neon;
32pub mod utils;
33
34pub use cpu::{QuantizedType, cpu_from_data, cpu_zeros};
35pub use dequant::dequant_ggml_bytes;
36pub use k_quants::{
37    BlockQ2K, BlockQ3K, BlockQ4_0, BlockQ4_1, BlockQ4K, BlockQ5_0, BlockQ5_1, BlockQ5K, BlockQ6K,
38    BlockQ8_0, BlockQ8_1, BlockQ8K, GgmlType, K_SCALE_SIZE, QK_K, QK4_0, QK4_1, QK5_0, QK5_1,
39    QK8_0, QK8_1, blocks_as_bytes, blocks_from_bytes_cow, matmul, matmul_f16,
40};
41
42// Re-export GgmlDType so downstream callers can write
43// `fuel_quantized::GgmlDType` without naming fuel-core-types.
44pub use fuel_backend_contract::quantized::{DynQuantizedStorage, QuantizedDeviceKernels};
45pub use fuel_ir::quantized::GgmlDType;