Initial release of Tablinum-Loop: TBLR v1 34-table hierarchical router (210M passages), EngramBench atom shards, and Mode A/B prototypes
3f51d96 verified |
Download ARCHITECTURE.md from tablinum/tablinum-loop: direct link, hf CLI and curl.
- Browser
- Download file 5.03 kB
-
https://huggingface.co/datasets/tablinum/tablinum-loop/resolve/main/ARCHITECTURE.md
- Command line
-
hf download hf://datasets/tablinum/tablinum-loop/ARCHITECTURE.md
-
curl -L -o ARCHITECTURE.md https://huggingface.co/datasets/tablinum/tablinum-loop/resolve/main/ARCHITECTURE.md
5.03 kB
| # Tablinum-Loop (`schema: 2`): Scalable External Engram Architecture for Looped MoE Models | |
| ## Why Tablinum-3 (`schema: 1`) Bottlenecks on Looped Models | |
| Tablinum-3 + `terrabeam 0.3` uses **single-shot pre-turn retrieval** (`Pool::Global` across `N` tables, injecting `k=3` full passages before generation). While effective for single-pass models, it hits four structural bottlenecks as table counts grow and models loop: | |
| 1. **Loop Prefill Amplification:** Every token injected into the prompt traverses all `L` layers *plus* `passes − 1` extra executions of the looped band (`L12–19 ×2` on Moon-Beam 2 = `+33%` attention & MoE prefill compute per retrieved token). | |
| 2. **Linear Table Scaling (`O(N)`):** `Pool::Global` pulls `8` vector candidates + `1` BM25 hit from every table (`9 × N` candidates). Scaling from `29` tables to `100+` domain tables pushes cross-encoder reranking latency into multiple seconds per query. | |
| 3. **Distractor Overload:** Past engram ablations (`engram-knowledge-tables`) showed injecting `k=5` full passages degraded AA-Omniscience from `8.0` down to `0.5` because off-target context lures small/quantized experts into near-miss hallucinations. | |
| 4. **No Loop / Multi-Format Metadata:** `schema: 1` has no fields for looped band geometry (`band`, `passes`, `reenter`, `per_pass_cache`), adaptive early exit, or non-GGUF hardware formats (`mlx`, `nvfp4`, `npu`, `pytorch_loop`). | |
| --- | |
| ## Four Pillars of Tablinum-Loop (`schema: 2`) | |
| ### 1. Hierarchical Centroid Table Router (`domain_router.npz` / `.bin`) | |
| - **Offline:** Run `k-means` (`K=8` centroids per table) on each table's `256`-dimensional `static-retrieval-mrl-en-v1` embeddings and pack them into a tiny contiguous matrix `[N × K, 256]` (`~82 KB` per `10` tables, `<1 MB` for `100` tables). | |
| - **Online:** Single BLAS dot product (`q @ C.T`) scores all `N` tables in `<0.2 ms` CPU time and routes only to the **top-`M=5` tables** (plus fallback lexical triggers). | |
| - **Scaling:** Keeps IVF + BM25 + MiniLM cross-encoder cost **strictly `O(1)` in `N`** (`~45` candidates regardless of whether the pack has `20` or `200` tables). | |
| ### 2. Atom-Then-Expand Shards (`atoms.parquet`) | |
| - Instead of injecting three `200–350` token passages upfront, each passage (`pid`) is indexed alongside distilled `40–80` token **fact atoms** (`atom_id -> pid`). | |
| - **Pass 1** reads compact atoms (`~150` tokens total instead of `~900` tokens — cutting looped prefill overhead by **6×** and suppressing off-target distractors). | |
| - **Pass 2** only calls `expand(pid)` for the 1–2 passages the model actually cites or queries. | |
| ### 3. Mode A — Two-Stage Engram-Loop with Early Exit (Deployable Today on `terrabeam` + `llama.cpp`) | |
| Runs directly over any OpenAI-compatible `llama-server` / `terrabeam` backend: | |
| 1. **Pass 1 (Fast Draft & Confidence Check):** Model evaluates the user prompt (thinking off / short budget) with zero retrieval (`0` extra engram tokens) and outputs either a high-confidence direct answer (`confidence >= 0.85` → **Early Exit**, skipping both retrieval and Pass 2) OR `1–2` crisp targeted micro-queries (`<query>...</query>`). | |
| 2. **Hierarchical Fetch:** `HierarchicalTableRouter` selects the top-`M` tables and `AtomStore` fetches compact Pass-1 atoms (and optional expanded parent passages). | |
| 3. **Pass 2 (Grounded Synthesis):** Full thinking-ON synthesis grounded on retrieved evidence, preserving canonical reasoning traces. | |
| ### 4. Mode B — Mid-Band Hidden-State Engram Bridge (Zero Extra Context Tokens) | |
| For native PyTorch / future `llama.cpp` loop execution inside `loopmb.LoopBand`: | |
| - After Pass 1 exits `L19` (`hidden_size = 1536`), a tiny projection head `W_q: 1536 → 256` maps the current token's hidden representation directly into normalized `static-retrieval-mrl-en-v1` / IVF-SQ8 space. | |
| - Top-`k=4` retrieved passage/entity embeddings `[K_mem, V_mem]` are mixed via zero-initialized cross-attention (`reenter_engram_up = 0` at initialization, guaranteeing exact mathematical identity at step 0) into Pass 2's re-entry state before `L12–19` execute a second time. | |
| - Because knowledge enters directly between Pass 1 and Pass 2 inside the latent stream, **zero retrieved context tokens enter the KV/KDA cache**. | |
| --- | |
| ## `terrabeam 0.4` Rust Crate Touchpoints (`~/optane-llm/terrabeam`) | |
| | Component | Target File | Change | | |
| |---|---|---| | |
| | Table Router | `crates/engram/src/router.rs` | Memory-map `domain_router.bin` (`[N×K, 256]`), select top-`M` table IDs via SIMD dot product before `Engram::retrieve()` | | |
| | Atom Expander | `crates/engram/src/passages.rs` | Optional `atoms.parquet` lookup + `expand_pid(pid)` endpoint | | |
| | Adaptive Loop Proxy | `crates/terrabeam/src/proxy.rs` | Implement `loop_policy: pass1_draft_pass2_verify` with early-exit threshold and `/v1` `X-Tablinum-Loop` telemetry header | | |
| | Multi-Format Manifest | `crates/terrabeam/src/manifest.rs` | Parse `schema: 2` (`loop`, `formats`, `engram.routing`, `engram.granularity`) while staying backwards-compatible with `schema: 1` | | |