Skip to main content

ferrox_core/
lib.rs

1//! ferrox-core: tensor primitives, quantized matmul, RMSNorm, RoPE, and
2//! grouped-query causal attention with a simple KV cache.
3//!
4//! CPU reference implementation. The op set and naming (RMSNorm, RoPE,
5//! GQA, KV cache) follow the now-standard vocabulary popularized by
6//! llama.cpp / vLLM / candle-transformers; the actual Rust code below is
7//! written independently. See docs/THIRD_PARTY_NOTICES.md for design credit.
8
9pub mod attention;
10pub mod cache;
11pub mod csa_hca_compress;
12pub mod deepseek_v4_attention;
13pub mod expert_store;
14pub mod instance;
15pub mod kernel_registry;
16pub mod kv_block;
17pub mod kv_disk;
18pub mod kv_signature;
19pub mod kv_swa;
20pub mod matmul;
21pub mod tensor;
22pub mod threads;
23pub mod turboquant;
24pub mod weight_matrix;
25
26pub use attention::{
27    apply_rope_back, apply_rope_interleaved, apply_rope_interleaved_back,
28    apply_rope_interleaved_with_freq_factors, apply_rope_with_freq_factors, causal_gqa_attention,
29    causal_gqa_attention_paged, causal_gqa_attention_prefill,
30    causal_gqa_attention_prefill_shared_kv, causal_gqa_attention_prefill_shared_kv_windowed,
31    causal_gqa_attention_sinks, causal_gqa_attention_softcap, causal_gqa_attention_windowed,
32    causal_gqa_attention_windowed_softcap, lightning_indexer_topk,
33};
34pub use cache::{
35    KvBlockPool, KvCache, KvPoolExhausted, PagedKvCache, PagedKvStore, PagedStoreExhausted,
36};
37pub use csa_hca_compress::{channel_gated_pool, compress_block};
38pub use deepseek_v4_attention::{csa_attention, hca_attention};
39pub use kernel_registry::Registry as KernelRegistry;
40pub use kv_block::{full_blocks, BlockHash, BlockHasher};
41pub use kv_disk::{
42    decode_block, encode_block, encoded_len, BlockFormatError, DiskConfig, DiskKvStore, DiskStats,
43    ReadHandle, ReadOutcome, StoreError,
44};
45pub use kv_signature::{
46    CacheSignature, KvBlock, KvDtype, SignatureError, UnverifiedBlock, BLOCK_FORMAT_VERSION,
47    READABLE_FORMAT_VERSIONS,
48};
49pub use kv_swa::{aligned_block_size, BlockLayout, BlockLayoutError};
50pub use matmul::{
51    geglu, gelu, matmul_f32, rms_norm, rms_norm_per_head, silu, situ_and_mul, softcap_inplace,
52    swiglu,
53};
54pub use tensor::Tensor;
55#[cfg(feature = "cuda")]
56pub use weight_matrix::cuda_dense_enabled;
57#[cfg(feature = "metal")]
58pub use weight_matrix::metal_dense_enabled;
59pub use weight_matrix::{
60    active_backend, cpu_int_dot_kind_supported, cuda_matvec_kind_supported, metal_matvec_kind_name,
61    metal_mul_mm_kind_supported, BatchActs, QuantKind, WeightMatrix,
62};