ruvector_attn_mincut/lib.rs
1//! # ruvector-attn-mincut
2//!
3//! Dynamic min-cut gating as an alternative to softmax attention.
4//!
5//! Instead of applying softmax uniformly over all Q*K^T logits, this crate
6//! builds a weighted directed graph from the logits and computes a minimum
7//! cut (via Dinic's max-flow algorithm) to gate irrelevant edges. Surviving
8//! edges are then normalised with row-softmax and multiplied by V.
9//!
10//! ## Key features
11//!
12//! - **Graph construction** from attention logits (`graph` module).
13//! - **Dinic's max-flow / min-cut** solver (`mincut` module).
14//! - **Gating operators**: standard softmax and min-cut gated (`gating` module).
15//! - **Temporal hysteresis** to stabilise gating over time (`hysteresis` module).
16//! - **Witness logging** with SHA-256 hashing for determinism verification (`witness` module).
17//! - **Configuration** with sane defaults (`config` module).
18
19pub mod config;
20pub mod gating;
21pub mod graph;
22pub mod hysteresis;
23pub mod mincut;
24pub mod witness;
25
26// Re-export primary types for ergonomic usage.
27pub use config::MinCutConfig;
28pub use gating::{attn_mincut, attn_softmax, AttentionOutput};
29pub use graph::{graph_from_logits, AttentionGraph, Edge};
30pub use hysteresis::HysteresisTracker;
31pub use mincut::{dynamic_min_cut, CutResult, DinicSolver, GatingResult};
32pub use witness::{hash_tensor, witness_log, WitnessEntry};