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 matmul;
20pub mod tensor;
21pub mod threads;
22pub mod turboquant;
23pub mod weight_matrix;
24
25pub use attention::{
26    apply_rope_back, apply_rope_interleaved, apply_rope_interleaved_back,
27    apply_rope_interleaved_with_freq_factors, apply_rope_with_freq_factors, causal_gqa_attention,
28    causal_gqa_attention_paged, causal_gqa_attention_prefill,
29    causal_gqa_attention_prefill_shared_kv, causal_gqa_attention_prefill_shared_kv_windowed,
30    causal_gqa_attention_sinks, causal_gqa_attention_softcap, causal_gqa_attention_windowed,
31    causal_gqa_attention_windowed_softcap, lightning_indexer_topk,
32};
33pub use cache::{
34    KvBlockPool, KvCache, KvPoolExhausted, PagedKvCache, PagedKvStore, PagedStoreExhausted,
35};
36pub use csa_hca_compress::{channel_gated_pool, compress_block};
37pub use deepseek_v4_attention::{csa_attention, hca_attention};
38pub use kernel_registry::Registry as KernelRegistry;
39pub use kv_block::{full_blocks, BlockHash, BlockHasher};
40pub use kv_disk::{
41    decode_block, encode_block, encoded_len, BlockFormatError, DiskConfig, DiskKvStore, DiskStats,
42    ReadHandle, ReadOutcome, StoreError,
43};
44pub use kv_signature::{
45    CacheSignature, KvBlock, KvDtype, SignatureError, UnverifiedBlock, BLOCK_FORMAT_VERSION,
46    READABLE_FORMAT_VERSIONS,
47};
48pub use matmul::{
49    geglu, gelu, matmul_f32, rms_norm, rms_norm_per_head, silu, situ_and_mul, softcap_inplace,
50    swiglu,
51};
52pub use tensor::Tensor;
53#[cfg(feature = "cuda")]
54pub use weight_matrix::cuda_dense_enabled;
55#[cfg(feature = "metal")]
56pub use weight_matrix::metal_dense_enabled;
57pub use weight_matrix::{
58    active_backend, cpu_int_dot_kind_supported, cuda_matvec_kind_supported, metal_matvec_kind_name,
59    metal_mul_mm_kind_supported, BatchActs, QuantKind, WeightMatrix,
60};