OpenPay (1 crate, 2487 LOC, 33 tests)
op-fraud-graph Graph-based fraud detection. EntityKind (card/email/
device/IP/address/phone/BIN+last4/account) with
canonicalization + hashed EntityKey + billing↔shipping
mismatch detection. Adjacency-list FraudGraph with
idempotent upsert + edge-merge. Double-hashing Bloom
filter (capacity+FPR-sized). Union-find connected
components. PageRank with dangling-sink handling.
Louvain community detection. Shared-instrument hub
rings. Sliding ring-buffer velocity counters. Synthetic
identity heuristics (freshness + heavy-use + mail-drop).
Structuring / smurfing / mule-chain DFS. EntityRisk +
TransactionRisk + RiskBand combiner.
Smart Byte (1 crate, ~1844 LOC, 44 tests)
smart-byte-ilp Interledger Protocol v4. OER codec (length-determinant,
var-octet-string, BE u32/u64). Prepare/Fulfill/Reject
packet roundtrip with all 19 IL-RFC-27 reject codes.
SHA-256 Condition + Fulfillment with constant-time
verify. ILP address validator (7 schemes, 1-128 char
segments, 1023-byte cap, segment-aligned prefix match).
STREAM (15 frame types). BTP. SPSP payment-pointer
resolver. Open Payments API. Longest-prefix routing
Connector with fixed-point quote conversion + balance +
rate-limit checks.
EOC (1 crate, 1921 LOC, 36 tests)
eoc-quantize Quantization primitives. int8 (symmetric/asymmetric
with zero-inclusion fix), int4 (GPTQ + AWQ group quant),
int2 (BitNet), fp8 (E4M3/E5M2), nf4 (QLoRA). GGUF v3
header parse. safetensors read sketch. Calibration
datasets + per-channel scales. KV-cache quant. Energy
tradeoff curves (joules-per-token across schemes).
Co-Authored-By: Claude Opus 4.7 <[email protected]>
55 lines
2 KiB
Rust
55 lines
2 KiB
Rust
//! `eoc-quantize` — quantization primitives + format converters.
|
|
//!
|
|
//! Energy-Optimized Compute lives or dies on bits-per-weight. This
|
|
//! crate is the reference implementation of the quantization primitives
|
|
//! used across the EOC stack: int2/int4/int8 weight quantization, fp8
|
|
//! and NF4 for low-rank adapters, calibration helpers, KV-cache
|
|
//! quantization, and read sketches for the dominant on-disk formats
|
|
//! (GGUF v3, safetensors).
|
|
//!
|
|
//! It also exposes an `energy_tradeoff` estimator that converts a
|
|
//! chosen scheme into an estimated joules-per-token figure — the bridge
|
|
//! between this crate and the wider EOC meter / cascade machinery.
|
|
//!
|
|
//! ## INGEST
|
|
//!
|
|
//! The implementations here are pure-Rust sketches inspired by the
|
|
//! public literature:
|
|
//!
|
|
//! * **int8** — symmetric and asymmetric PTQ
|
|
//! (Jacob et al., 2018; Krishnamoorthi 2018).
|
|
//! * **int4** — group-quantized weights with per-group scale + zero
|
|
//! point as used by GPTQ (Frantar et al., 2022) and AWQ
|
|
//! (Lin et al., 2023).
|
|
//! * **int2** — sign-magnitude / ternary weights as in BitNet
|
|
//! (Wang et al., 2023).
|
|
//! * **fp8** — E4M3 and E5M2 (OFP8 / Nvidia Hopper).
|
|
//! * **nf4** — NormalFloat4 (Dettmers et al., 2023, QLoRA).
|
|
//! * **GGUF v3** — llama.cpp on-disk format header sketch.
|
|
//! * **safetensors** — Hugging Face zero-copy tensor container.
|
|
//! * **SmoothQuant** (Xiao et al., 2022) — bias migration between
|
|
//! activations and weights, exposed as a helper.
|
|
//! * **LLM.int8()** (Dettmers et al., 2022) — outlier-aware mixed
|
|
//! precision (sketched in `int8::mixed_precision`).
|
|
//!
|
|
//! Nothing here calls a vendor SDK; everything is byte-shuffling and
|
|
//! arithmetic in `alloc`.
|
|
|
|
#![forbid(unsafe_code)]
|
|
#![deny(missing_docs)]
|
|
|
|
pub mod calibration;
|
|
pub mod energy_tradeoff;
|
|
pub mod error;
|
|
pub mod fp8;
|
|
pub mod gguf;
|
|
pub mod int2;
|
|
pub mod int4;
|
|
pub mod int8;
|
|
pub mod kv_cache;
|
|
pub mod nf4;
|
|
pub mod safetensors;
|
|
pub mod scheme;
|
|
|
|
pub use error::QuantError;
|
|
pub use scheme::{Numeric, QuantizationScheme};
|