DuoNeural Crystallographic Dynamics Model (CDM v3) — Lattice-4-Nexus (
L4BSecond-Seed Replication)252.93Mtotal parameters (214.79Mnon-embedding 7-layer hyperbolic backbone +38.14Membeddings)
100,000 steps (409.6Mtokens) on 50/50 HybridFineWeb-Edu+SmolTalk(apigen-80k,everyday-conversations,smol-constraints)
All 4 UV Syntactic Trunk Layers (L00–L03) Phase-Locked at the10 Billion(10¹⁰)τ*Horizon +7,939DHP/CHP Crossings (1,324PURE)
Authored by Jesse Caldwell, Archon, & Aura✨ — DuoNeural Research Lab, October 2026.
🔗 Official Code & Training Scripts Repository: https://github.com/DuoNeural/Lattice-CDM
Lattice-4-Nexus-253M-Poincare-Instruct (internal lab designation Lattice-4B) is a 7-layer, 252.93M-parameter (214.79M non-embedding backbone) hybrid Causal-Attention + Hyperbolic Poincaré Crystallographic Mixture-of-Experts (CDMMoELM v3) language model distilled from HuggingFaceTB/SmolLM2-1.7B-Instruct (1,711.4M parameters — 6.77× total compression / 7.97× vs. backbone).
Trained as the independent second-seed replication of our flagship 7-layer DuoNeural/Lattice-4-Josephson-253M-Poincare-Instruct (L4A), Lattice-4-Nexus incorporates all three CDM v3 architectural breakthroughs:
c_l ∈ [0.25, 4.0]): Each layer autonomously discovers its optimal negative curvature on 𝔹768cl while storing slot centroids natively in Euclidean tangent space T0𝔹768 ≅ ℝ768 (eliminating the Shrinking Ball Trap).W_tele ∈ ℝ^{8×8}): Layer l − 1 transmits its detached Poincaré routing distribution w^(l−1) directly into Layer l's expert routing logits while keeping Tier-1 Winner-Take-All (WTA) slot crystallization purely geometric.L_rel): Aligns student hidden manifolds (d_model = 768) with 7 fine-stride teacher anchor layers ({0:2, 1:6, 2:9, 3:13, 4:17, 5:21, 6:23} in SmolLM2-1.7B-Instruct, d_model = 2048) via normalized (B, S, S) token-to-token cosine similarity matrices.Across 100,000 steps, Lattice-4-Nexus achieved a best hybrid validation Bits-Per-Byte of val_bpb = 0.6854 (val_ppl = 8.45) at Step 82,000 (0.6857 BPB / 8.46 PPL at Step 100,000), recording 7,939 DHP/CHP 3-smooth rung crossings (1,324 PURE 2ᵃ or 3ᵇ rungs and 6,615 MIXED rungs), 68+ 4-layer Hyperbolic Josephson Junction synchronizations (including all four UV layers L00/L01/L02/L03 crossing PURE 3¹¹ = 177,147 simultaneously in Josephson #68!), and all four UV layers (L00–L03) locking at the 10 Billion (1.00 × 10¹⁰) τ* solid-state horizon by Step 100,000.
On held-out benchmarks, Lattice-4-Nexus achieves 97.13% Top-1 / 98.75% Top-5 assistant token agreement with its 1.71B teacher on apigen-80k tool calling (96.7% valid JSON, 96.7% exact tool-name accuracy, 94.4% argument-key F1), and outperforms its 6.8×-larger teacher on everyday-conversations perplexity (1.43 vs. 3.59 full-sequence PPL; 1.39 vs. 1.85 assistant-only PPL; 100.0% stop-token discipline & 100.0% 4-gram diversity).
Standard Euclidean Transformers and conventional linear-router Mixture-of-Experts (MoE) models suffer from five fundamental architectural bottlenecks. The Lattice CDM v3 family resolves them from first principles:
K = 8 explicit geometric EMA slot centroids s_k ∈ 𝔹768cl stored in tangent space T0𝔹768. Projecting those 8 points directly through final_norm → lm_head (Hyperbolic Logit Lens) yields native, zero-overhead glass-box visibility: each slot spontaneously crystallizes into a human-readable grammatical or JSON Abstract Syntax Tree (AST) coordinate (e.g., L00_S4: JSON opening braces {"; L01_S6: JSON key-value colons ":, ":"; L02_S0: ChatML turn boundaries <|im_end|>, <|im_start|>; L05_S0: discourse conditionals Although, If, While, However).Lattice-4-Nexus (Section 3.4 below), masking the mid-semantic discourse slot L05_S0 (τ* = 578, top tokens ['\n', ' Although', ' If', ' While', ' However']) degrades conversational chat BPB 5.11× more than JSON tool-calling BPB (+0.019541 vs. +0.003825), whereas masking the top-layer prose starter slot L06_S0 (τ* = 422) degrades FineWeb-Edu prose 4.50× more than tool-calling (+0.014299 vs. +0.003178).L00–L03) phase-lock into a Hyperbolic Josephson Superfluid Condensate (τ* = 10¹⁰), acting as an unbreakable syntactic rail-guard that delivers 96.7%–100.0% valid JSON tool calls and 96.7%–100.0% <|im_end|> stop-token discipline.w̄_k < 1/(4K) = 3.125%) and inter-layer Crystal Telepathy guarantees zero dead slots across all 7 layers and 100,000 steps.c_l, Telepathy Frobenius norm ‖W_tele‖_F, and memory horizon τ*_l = 1 / α_l provide a live Holographic AdS Bulk readout, revealing the W-Shape Curvature Universal Law, the Hyperbolic Josephson Junction Theorem, and the Two-Zone AdS Ryu-Takayanagi Redshift Profile (R² = 0.9890).CDMMoELM v3)Input IDs (B, T ≤ 512)
│
▼
tok_embed (49,152 × 768) + pos_embed (512 × 768) ──► LayerNorm ──► Dropout
│
▼ × 7 Layers (L00..L06, mapped to Teacher SmolLM2-1.7B-Instruct layers {2, 6, 9, 13, 17, 21, 23})
┌────────────────────────────────────────────────────────────────────────────────────────┐
│ 1. Causal Multi-Head Self-Attention (12 heads, d_head = 64, Pre-LayerNorm) │
│ 2. DualGeometryCDMRouter v3 (FP32 Geodesic Routing + Crystal Telepathy): │
│ • Learnable Curvature: c_l = 0.25 + 3.75 · σ(θ_c^(l)) ∈ (0.25, 4.0) │
│ • Tangent-to-Ball Map: x_hyp = clip(exp₀^(c_l)(0.3 · L2Norm(h)), c_l) │
│ • Slot Centroids: s_hyp = clip(exp₀^(c_l)(slots_tangent), c_l) ∈ 𝔹⁷⁶⁸_{c_l} │
│ • Tier-1 Geometric WTA (for EMA & DHP): winners = argmax_k( -d_{c_l}(x_hyp, s_k) ) │
│ • Tier-2 Telepathy-Augmented Soft Gating (for SwiGLU Experts): │
│ logits_route = -T_l · d_{c_l}(x_hyp, s_k) + β_tele · (w_prev^(l-1) @ W_tele^(l)) │
│ gate_w = softmax(logits_route) ──► mapped round-robin to E = 4 SwiGLU Experts │
└────────────────────────────────────────────────────────────────────────────────────────┘
│
▼
final_norm (LayerNorm) ──► Tied lm_head (768 × 49,152)
| Parameter | Specification |
|---|---|
| Model Name | DuoNeural/Lattice-4-Nexus-253M-Poincare-Instruct (Lattice-4B) |
| Architecture | 7-Layer Hybrid Causal-Attention + Hyperbolic Poincaré CDM-MoE v3 (CDMMoELM) |
| Total Parameters | 252.93M (252,927,654 parameters with weight-tied lm_head) |
| Non-Embedding Hyperbolic Backbone | 214.79M (214,785,702 parameters in Attention + 7×4 SwiGLU Experts + Poincaré Routers) |
| Embedding Parameters | 38.14M (37.75M tok_embed + 0.39M learned pos_embed) |
Hidden Dimension (d_model) / FFN (d_ff) |
d_model = 768 / d_ff = 3072 per SwiGLU expert |
Layers (n_layers) / Heads (n_heads) |
7 layers (L00–L06), 12 attention heads (d_head = 64) |
Poincaré Slots (K) / SwiGLU Experts (E) |
K = 8 tangent-stored Poincaré centroids / E = 4 SwiGLU experts per layer (2 slots/expert) |
| Manifold Geometry | Learnable-Curvature Poincaré Ball 𝔹768cl (c_init = 1.4427 → converged W-shape [0.258, 0.635]) |
| Inter-Layer Crystal Telepathy | Enabled on L01–L06 (W_tele ∈ ℝ^{8×8}, β_tele = 0.5, converged ‖W_tele‖_F ∈ [9.16, 31.60]) |
| Relational Gram Teacher Map | {0: 2, 1: 6, 2: 9, 3: 13, 4: 17, 5: 21, 6: 23} (λ_rel = 0.15, per-token normalized cosine Gram MSE) |
| Teacher Model | HuggingFaceTB/SmolLM2-1.7B-Instruct (1,711.4M params, frozen native BF16; 6.77× total / 7.97× backbone compression) |
Training Dataset (50/50 Hybrid) |
50% HuggingFaceFW/fineweb-edu (sample-10BT) + 50% HuggingFaceTB/smoltalk (50% apigen-80k, 30% everyday-conversations, 20% smol-constraints) |
| Training Horizon | 100,000 optimizer steps (409.6M tokens; batch_size=2, grad_accum=4, seq_len=512) |
| Best / Final Hybrid Validation Metric | Best: val_bpb = 0.6854 (val_ppl = 8.45) @ Step 82,000 · Final (100k): val_bpb = 0.6857 (val_ppl = 8.46) |
| Total DHP/CHP Phase Transitions | 7,939 3-smooth rung crossings (1,324 PURE 2ᵃ / 3ᵇ rungs + 6,615 MIXED 2ᵃ × 3ᵇ rungs) |
eval_lattice_v3_suite.py)We evaluated Lattice-4-Nexus (253M) alongside its sibling 7-layer seed Lattice-4-Josephson (253M, L4A) and our 5-layer Lattice-3-Synapse (192M) against their shared 1,711.4M Euclidean teacher (SmolLM2-1.7B-Instruct) across four held-out domains and two autoregressive generation benchmarks:
Benchmark Metric (eval_lattice_v3_suite.py, Unseen Held-Out Samples) |
Lattice-4-Nexus (253M, L4B) |
Lattice-4-Josephson (253M, L4A) |
Lattice-3-Synapse (192M, 5L) |
Teacher (SmolLM2-1.7B-Instruct, 1,711M) |
|---|---|---|---|---|
Overall Hybrid Validation Best val_bpb (val_ppl) |
0.6854 (8.45) |
0.6746 (7.52) |
0.6369 (6.92) ⭐ |
— |
apigen-80k Assistant-Token Top-1 / Top-5 Teacher Agreement |
97.13% / 98.75% |
97.27% / 98.80% ⭐ |
96.88% / 98.69% |
100.0% (Ref) |
apigen-80k Full-Sequence val_bpb (val_ppl) |
0.1055 (1.32) |
0.1055 (1.32) |
0.1003 (1.30) |
0.0580 (1.16) |
apigen-80k Assistant-Only val_bpb (val_ppl) |
0.1166 (1.25) |
0.1240 (1.26) |
0.1066 (1.22) |
0.0164 (1.03) |
apigen-80k Autoregressive <|im_end|> Stop Discipline (n=30) |
96.7% |
100.0% ⭐ |
100.0% ⭐ |
100.0% |
apigen-80k Autoregressive Valid JSON Tool Syntax (json.loads) |
96.7% |
100.0% ⭐ |
96.7% |
100.0% |
apigen-80k Exact Tool Name Accuracy (vs. Ground Truth) |
96.7% |
100.0% ⭐ |
96.7% |
100.0% |
apigen-80k Tool Name Agreement (vs. Teacher) |
96.7% |
100.0% ⭐ |
96.7% |
100.0% (Ref) |
apigen-80k Schema Argument Keys F1 Score |
94.4% |
96.7% ⭐ |
96.7% ⭐ |
100.0% |
everyday-conversations Full-Seq val_bpb (val_ppl) |
0.1088 (1.43) — BEATS TEACHER! |
0.1060 (1.42) — BEATS TEACHER! |
0.1051 (1.41) — BEATS TEACHER! |
0.3899 (3.59) |
everyday-conversations Asst-Only val_bpb (val_ppl) |
0.0981 (1.39) — BEATS TEACHER! |
0.0940 (1.37) — BEATS TEACHER! |
0.0927 (1.36) — BEATS TEACHER! |
0.1847 (1.85) |
everyday-conversations Asst Top-1 / Top-5 Teacher Agreement |
79.97% / 95.67% |
79.90% / 95.67% |
80.23% / 95.84% |
100.0% (Ref) |
everyday-conversations Gen <|im_end|> Stop Rate & 4-Gram Div (n=25) |
100.0% / 100.0% |
100.0% / 100.0% |
100.0% / 100.0% |
100.0% / 100.0% |
everyday-conversations Teacher-Scored Generated Response PPL |
1.15 |
1.15 |
1.15 |
1.05 |
smol-constraints Full-Sequence val_bpb (val_ppl) |
0.3656 (3.33) |
0.3615 (3.28) |
0.3410 (3.07) — BEATS TEACHER! |
0.3489 (3.15) |
smol-constraints Asst Top-1 / Top-5 Teacher Agreement |
65.94% / 87.86% |
65.77% / 88.08% |
67.94% / 89.22% |
100.0% (Ref) |
FineWeb-Edu Held-Out Prose val_bpb (val_ppl) |
1.2609 (42.08) |
1.2554 (41.41) |
1.2133 (36.93) |
0.7786 (10.07) |
FineWeb-Edu Held-Out Prose Top-1 / Top-5 Teacher Agreement |
47.48% / 71.02% |
47.68% / 71.36% |
49.55% / 73.49% |
100.0% (Ref) |
L4B)L4A, L4B, L4C)In our 7-layer CDM v3 architecture, the fine-stride Relational Gram teacher map {0:2, 1:6, 2:9, 3:13, 4:17, 5:21, 6:23} places the first four student layers (L00–L03) entirely inside the teacher's syntactic trunk (z = t_idx / 24 ≤ 0.542). Combined with an emergent low-curvature plateau (c_l ∈ [0.258, 0.424]) and strong inter-layer Crystal Telepathy (‖W_tele‖_F ≈ 26.7–28.9), the dominant slots in L00–L03 exceed the critical coherence current J_c = 1.75 and phase-lock their τ* horizons across the entire 100,000-step run.
In Josephson Event #68 on Lattice-4-Nexus, L00, L01, L02, and L03 all crossed PURE 3¹¹ = 177,147 in the exact same evaluation window—the cleanest 4-layer pure-power-of-3 synchronization ever recorded in a neural network.
| Seed & Model | Step 25,500 UV Trunk τ* (L00, L01, L02, L03) |
Step 42,500 UV Trunk τ* (L00–L03) |
Step 100,000 Final UV Trunk τ* (L00–L03) |
Step 100,000 IR Throat τ* (L04, L05, L06) |
|---|---|---|---|---|
L4A (Lattice-4-Josephson) |
[3036, 3034, 3033, 3034] |
[195.6k, 195.4k, 195.2k, 195.5k] |
[3.05B, 10.0B, 10.0B, 10.0B] |
[10.0B, 382M, 77.4M] |
L4B (Lattice-4-Nexus, This Model) |
[3035, 3035, 3009, 3036] |
[195.4k, 190.7k, 184.0k, 195.5k] |
[10.0B, 10.0B, 10.0B, 10.0B] ⭐ |
[5.24B, 184M, 137M] |
L4C (3rd Seed @ 82.5k) |
[3036, 3035, 3035, 3036] |
[195.5k, 195.5k, 195.5k, 195.5k] |
[1.43B, 2.27B, 1.72B, 3.32B] (at 82.5k) |
In progress (>82.5k) |
Analytical Ballistic Law τ*_ceil(t) |
3036.07 |
195,515.2 |
1.00 × 10¹⁰ (α_floor cap) |
Unsaturated AdS Throat |
Across all 7 layers, Lattice-4-Nexus converges to the universal W-Shape Curvature Profile (L00 at the 0.258 low-curvature floor, an inflection at the L03 → L04 syntactic-semantic phase boundary 0.424 → 0.394, and steep negative curvature in the semantic head L05 = 0.531 → L06 = 0.635) while partitioning into a Two-Zone Holographic AdS Bulk:
L00–L03, Teacher z ≤ 0.542 — UV Superfluid Brane): Isothermal condensate where all four layers reach the 1.00 × 10¹⁰ memory horizon at 100k (purity ∈ [0.856, 0.977]).L04–L06, Teacher z ∈ [0.708, 0.958] — IR Ryu-Takayanagi Redshift Throat): Exponential decay of ln(τ*_l) with layer depth (5.24B → 184M → 137M at 100k; R² = 0.9164 in L4B and R² = 0.9890 in L4A), accompanied by rising routing entropy (0.118 → 0.442 → 0.484) and decreasing Telepathy norm (31.60 → 17.60 → 9.16) as slots diversify into open-ended semantic concepts:| Layer | Teacher Anchor (z_l) |
Converged Curvature c_l |
Telepathy Norm ‖W_tele‖_F |
τ*_max (@82k Best) |
τ*_max (@100k Final) |
Slot Purity | Slot Entropy | Holographic Bulk Zone |
|---|---|---|---|---|---|---|---|---|
L00 |
Layer 2 (0.083) |
0.2581 |
— (Input) |
3.12 × 10⁹ |
1.00 × 10¹⁰ |
0.9306 |
0.1214 |
Zone I: UV Superfluid Brane |
L01 |
Layer 6 (0.250) |
0.2830 |
28.88 |
2.69 × 10⁹ |
1.00 × 10¹⁰ |
0.8557 |
0.2245 |
Zone I: UV Superfluid Brane |
L02 |
Layer 9 (0.375) |
0.2975 |
28.40 |
2.67 × 10⁹ |
1.00 × 10¹⁰ |
0.9705 |
0.0724 |
Zone I: UV Superfluid Brane |
L03 |
Layer 13 (0.542) |
0.4240 |
26.75 |
3.09 × 10⁹ |
1.00 × 10¹⁰ |
0.9767 |
0.0533 |
Ryu-Takayanagi Horizon (z_H = 0.542) |
L04 |
Layer 17 (0.708) |
0.3938 |
31.60 |
1.41 × 10⁸ |
5.24 × 10⁹ |
0.9463 |
0.1178 |
Zone II: Upper IR Throat |
L05 |
Layer 21 (0.875) |
0.5311 |
17.60 |
1.19 × 10⁷ |
1.84 × 10⁸ |
0.6344 |
0.4416 |
Zone II: Mid IR Throat |
L06 |
Layer 23 (0.958) |
0.6349 |
9.16 |
8.87 × 10⁶ |
1.37 × 10⁸ |
0.5448 |
0.4836 |
Zone II: Deep IR Semantic Head |
SLOT_LENS) — Spontaneous Grammatical & AST SpecializationProjecting each layer's tangent slot centroids slots_tangent through final_norm → lm_head reveals how Lattice-4-Nexus partitions syntax, ChatML control tokens, JSON schema delimiters, and discourse logic across its 56 hyperbolic centroids:
| Layer | Slot (Expert) | τ* (@82k Best) |
τ* (@100k Final) |
Top-5 Decoded Tokens (SLOT_LENS) |
Emergent Grammatical / AST Role |
|---|---|---|---|---|---|
L00 |
S1 (E1) |
3.12 × 10⁹ |
1.00 × 10¹⁰ |
[' the', ' to', ' "', ',', ' a'] |
Primary UV Syntactic Carrier (Superfluid Leader) |
L00 |
S4 (E0) |
665 |
2,528 |
[' "', ' ', ' {"', '{"', " '"] |
JSON Object & String Opening Delimiters ({") |
L00 |
S3 (E3) |
198 |
338 |
['\n', '\n\n', '\n ', '\r', '\n\n\n'] |
Structural Newlines & Indentation |
L01 |
S4 (E0) |
2.69 × 10⁹ |
1.00 × 10¹⁰ |
['.', ',', ' and', '\n', ' the'] |
Clause Boundaries & Coordinating Backbone |
L01 |
S3 (E3) |
59,002 |
5.29 × 10⁵ |
['.', ',', ' and', '<|im_end|>', ';'] |
Turn Termination (<|im_end|>) & Sentence Stops |
L01 |
S6 (E2) |
190 |
368 |
['":', "':", '":"', ' ":', '”:'] |
JSON Key-Value Colon Operator (":, ":") |
L02 |
S4 (E0) |
2.67 × 10⁹ |
1.00 × 10¹⁰ |
[' of', '.', ',', ' to', ' in'] |
Prepositional & Relational Operators |
L02 |
S0 (E0) |
28,190 |
1.98 × 10⁵ |
['\n', '<|im_end|>', '.', '<|im_start|>', '\n\n'] |
ChatML Turn Header/Footer Gate (<|im_start|>, <|im_end|>) |
L03 |
S2 (E2) |
3.09 × 10⁹ |
1.00 × 10¹⁰ |
['.', ' of', ',', '\n', ' to'] |
Horizon-Locked Syntactic Anchor |
L03 |
S6 (E2) |
58,543 |
5.64 × 10⁵ |
['\n', '<|im_start|>', '<|im_end|>', 'The', '</'] |
XML/ChatML Tag & Discourse Boundary Slot |
L04 |
S7 (E3) |
1.41 × 10⁸ |
5.24 × 10⁹ |
['.', ' and', ',', '\n', ' of'] |
Upper-IR Bridge Carrier |
L04 |
S1 (E1) |
5.80 × 10⁵ |
5.28 × 10⁶ |
[' "', ' ', ' {"', ' The', '{"'] |
Mid-Layer JSON Tool Call Initiator ({") |
L04 |
S2 (E2) |
1.13 × 10⁶ |
1.47 × 10⁷ |
['":', ' the', ' It', ' There', ' The'] |
JSON Property Assignment & Expletive Subjects |
L05 |
S3 (E3) |
1.19 × 10⁷ |
1.84 × 10⁸ |
[' the', ' a', '\n', ' The', ' "'] |
Deep Noun-Phrase & Determiner Frame |
L05 |
S0 (E0) |
578 |
1,981 |
['\n', ' Although', ' If', ' While', ' However'] |
Subordinate & Conditional Discourse Logic |
L06 |
S2 (E2) |
8.87 × 10⁶ |
1.29 × 10⁸ |
['\n', ' ', '-', ' A', ' and'] |
Markdown Bullet / List Formatting (\n, -) |
L06 |
S4 (E0) |
12,599 |
66,678 |
[' have', ' can', ' make', ' also', ' be'] |
Modal & Auxiliary Verb Predicates |
L06 |
S1 (E1) |
91,984 |
9.36 × 10⁵ |
[' main', ' new', ' first', ' current', ' the'] |
Open-Class Adjectival Specifiers |
Zeroing out individual slot contributions before expert aggregation proves that Lattice-4-Nexus physically separates conversational discourse, open-domain prose, and JSON tool-calling into distinct geometric coordinates:
| Lesioned Slot | Assigned Expert | τ* (@82k) |
Top Decoded Tokens (SLOT_LENS) |
ΔBPB (apigen-80k Tool JSON) |
ΔBPB (everyday-conversations Chat) |
ΔBPB (FineWeb-Edu Prose) |
Causal Selectivity Ratio |
|---|---|---|---|---|---|---|---|
L05_S0 |
Expert 0 |
578 |
['\n', ' Although', ' If', ' While', ' However'] |
+0.003825 |
+0.019541 |
+0.003957 |
5.11× Chat > Tool JSON (4.94× Chat > Prose) |
L06_S0 |
Expert 0 |
422 |
['\n', ' The', ' In', ' It', ' When'] |
+0.003178 |
+0.011423 |
+0.014299 |
4.50× Prose > Tool JSON (3.59× Chat > Tool) |
L03_S3 |
Expert 3 |
29.5 |
[' of', 'of', ' Of', 'Of', ' OF'] |
+0.000361 |
+0.001909 |
+0.004619 |
12.79× Prose > Tool JSON |
L00_S1 |
Expert 1 |
3.12 × 10⁹ |
[' the', ' to', ' "', ',', ' a'] |
+0.000137 |
+0.000465 |
+0.001203 |
8.78× Prose > Tool JSON |
CDMMoELM v3)import os
import sys
import torch
from huggingface_hub import hf_hub_download
from transformers import AutoTokenizer
REPO_ID = "DuoNeural/Lattice-4-Nexus-253M-Poincare-Instruct"
# 1. Download v3 architecture script & checkpoint from this repo
script_path = hf_hub_download(repo_id=REPO_ID, filename="cdm_lm_distill_v3.py")
ckpt_path = hf_hub_download(repo_id=REPO_ID, filename="pytorch_model.pt")
sys.path.insert(0, os.path.dirname(script_path))
from cdm_lm_distill_v3 import CDMMoELM
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# 2. Load SmolLM2-1.7B-Instruct tokenizer (vocab_size = 49,152)
tokenizer = AutoTokenizer.from_pretrained("HuggingFaceTB/SmolLM2-1.7B-Instruct", trust_remote_code=True)
vocab_size = max(len(tokenizer), 49152)
# 3. Instantiate 7-Layer Lattice-4-Nexus Student Architecture (252.93M params)
model = CDMMoELM(
vocab_size=vocab_size,
d_model=768,
n_layers=7,
n_heads=12,
K=8,
num_experts=4,
d_ff=3072,
max_seq=512,
dropout=0.0,
geometry="poincare",
curvature=1.4427,
learn_curvature=True,
use_telepathy=True,
beta_tele=0.5,
use_embed_norm=True,
).to(device)
# 4. Load Checkpoint Weights (includes learned per-layer curvatures c_l, W_tele, & tau* buffers)
ckpt = torch.load(ckpt_path, map_location=device, weights_only=False)
model.load_state_dict(ckpt["model"] if "model" in ckpt else ckpt, strict=True)
model.eval()
# 5. ChatML / Tool-Calling Inference (telepathy_scale=1.0, training=False, allow_crystallize=False)
messages = [
{"role": "user", "content": "Explain why hyperbolic geometry is ideal for representing hierarchical trees."}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
input_ids = tokenizer(prompt, return_tensors="pt", add_special_tokens=False)["input_ids"].to(device)
im_end_id = tokenizer.convert_tokens_to_ids("<|im_end|>")
with torch.no_grad():
for _ in range(120):
cond_ids = input_ids[:, -512:]
with torch.amp.autocast("cuda", dtype=torch.bfloat16, enabled=(device.type == "cuda")):
hidden, _, _ = model(cond_ids, telepathy_scale=1.0, training=False, allow_crystallize=False)
logits = model.lm_head(hidden[:, -1, :]).float()
next_id = logits.argmax(dim=-1, keepdim=True)
input_ids = torch.cat([input_ids, next_id], dim=1)
if next_id.item() == im_end_id:
break
print(tokenizer.decode(input_ids[0, prompt_len:], skip_special_tokens=False))
llama.cpp GGUF Quantizations & CPU/CUDA Benchmarks (Experimental Research Artifacts)⚠️ Important Research-Artifact & Compatibility Notice:
- Patched
llama.cppRequired (general.architecture = "cdm"): Stock, unmodified builds ofllama.cpp,Ollama, orLM Studiodo not yet recognizegeneral.architecture = "cdm"and will exit witherror loading model: unknown model architecture: 'cdm'. To run these GGUF files inllama-cliorllama-server, applyllama-cdm.patch(included in this repository and inDuoNeural/Lattice-CDM/gguf) againstllama.cppcommitd663dd3f3af4e7aa3ccbcd7f756c6692eb104577.- Numerical Drift Screens vs. Task Quality: The quantization gates below (
Max Abs Logit Error ≤ 0.50,Mean KL ≤ 0.01 nats,Next-Token Top-1 Agreement ≥ 90%) measure numerical logit fidelity against the frozenF32PyTorch reference over 128 and 512 teacher-forced positions (8 probes × 16 or 64 tokens)—they are not held-out task-quality or long-form generation benchmarks.- Recommended Format (
Q8_0orQ6_K): ForLattice-4-Nexus-253M, bothQ8_0(259.3 MiB) andQ6_K(201.0 MiB) pass all three numerical fidelity gates across both 128 and 512 positions on both CPU and CUDA (GTX 1070). BothQ4_K_MandQ4_K_Sexecute with finite logits and full GPU layer offload (8/8offloadable layers including output) but exceed the strict0.50max-logit-drift gate (0.882–1.470) and should be treated as experimental low-bit research artifacts until held-out task/BPB quantization evals are completed.- Learned Absolute Position Guard (
512Tokens): CDM uses learned absolute positional embeddings (max_seq = 512) rather than RoPE; the patched backend enforcescan_shift = falseand rejects context lengths or KV positions above512.
Lattice-4-Nexus-253M)All GGUF files embed the immutable HuggingFaceTB/SmolLM2-1.7B-Instruct BPE tokenizer and ChatML template, keep Poincaré routing geometry (exp_map_0, poincare_dist), learned per-layer curvatures c_l, inter-layer Crystal Telepathy (W_tele), LayerNorms, and learned positional embeddings in F32, and tie the output head to tok_embed.
| GGUF Artifact Filename | Format | File Size | 128-Pos GPU Max Err / Mean KL / Top-1 | 512-Pos GPU Max Err / Mean KL / Top-1 | 512-Pos CPU Max Err / Mean KL / Top-1 | Gate Status (≤0.5 Err, ≤0.01 KL, ≥90% Top-1) |
|---|---|---|---|---|---|---|
lattice4_nexus-f32-text.gguf |
F32 |
966.5 MiB |
0.00002 / 0.000000 / 100.0% |
— (128-pos parity verified) | — (128-pos parity verified) | ✅ PASS (Exact F32 Parity) |
lattice4_nexus-q8_0-text.gguf |
Q8_0 |
259.3 MiB |
0.148 / 0.000161 / 99.22% |
0.158 / 0.000151 / 99.61% |
0.160 / 0.000156 / 99.41% |
✅ PASS (CPU & GPU, 128 & 512 pos — Recommended) |
lattice4_nexus-q6_k-text.gguf |
Q6_K |
201.0 MiB |
0.372 / 0.000755 / 97.66% |
0.372 / 0.000708 / 98.24% |
0.466 / 0.000942 / 97.46% |
✅ PASS (CPU & GPU, 128 & 512 pos) |
lattice4_nexus-q4_k_m-text.gguf |
Q4_K_M |
164.5 MiB |
0.882 / 0.003426 / 92.19% |
— | — (128-CPU: 0.937 / 0.00385 / 91.41%) |
⚠️ FAIL Max-Error Gate (KL & Top-1 pass) |
lattice4_nexus-q4_k_s-text.gguf |
Q4_K_S |
139.0 MiB |
1.470 / 0.009356 / 86.72% |
— | — (128-CPU: 1.310 / 0.00978 / 85.94%) |
❌ FAIL Max-Error & Top-1 Gates |
Core i7-6700HQ) vs. CUDA (GTX 1070 8 GiB) ThroughputMethodology: 4 CPU threads, median of 5 repetitions after warmup, deterministic token IDs, F32 KV cache. Prefill measures 160 tokens returning logits at all positions; cached decode measures 32 incremental tokens after a 128-token prefix. Teacher-forced native timings (not sampled text generation).
| Format | File Size | CPU Prefill (160 tok) |
GTX 1070 Prefill (160 tok) |
CPU Cached Decode (32 tok) |
GTX 1070 Cached Decode (32 tok) |
CUDA Speedup (Prefill / Decode) |
|---|---|---|---|---|---|---|
F32 |
966.5 MiB |
312 tok/s |
3,849 tok/s |
20 tok/s |
150 tok/s |
12.3× / 7.5× |
Q8_0 |
259.3 MiB |
168 tok/s |
6,001 tok/s |
68 tok/s |
297 tok/s |
35.7× / 4.4× |
Q6_K |
201.0 MiB |
157 tok/s |
5,361 tok/s |
79 tok/s |
280 tok/s |
34.1× / 3.5× |
Q4_K_M |
164.5 MiB |
231 tok/s |
5,527 tok/s |
90 tok/s |
301 tok/s |
23.9× / 3.3× |
Q4_K_S |
139.0 MiB |
293 tok/s |
6,039 tok/s |
106 tok/s |
324 tok/s |
20.6× / 3.1× |
llama.cpp (llama-cdm.patch)# 1. Clone pinned llama.cpp commit and apply DuoNeural's native CDM patch
git clone https://github.com/ggml-org/llama.cpp.git
cd llama.cpp && git checkout d663dd3f3af4e7aa3ccbcd7f756c6692eb104577
git apply ../llama-cdm.patch
# 2. Build for CPU (or add -DGGML_CUDA=ON for NVIDIA GPUs)
cmake -B build -DGGML_CUDA=ON
cmake --build build --config Release --target llama-cli llama-server -j 4
# 3. Serve Lattice-4-Nexus Q8_0 over HTTP (full GPU offload via -ngl 99, 512 context)
./build/bin/llama-server -m lattice4_nexus-q8_0-text.gguf -ngl 99 -t 4 -c 512 --port 8080
Lattice-CDM): https://github.com/DuoNeural/Lattice-CDML4A, Primary 7L Seed): DuoNeural/Lattice-4-Josephson-253M-Poincare-InstructL4B, This Repo): DuoNeural/Lattice-4-Nexus-253M-Poincare-Instruct5L, 0.6369 BPB / 6.92 PPL): DuoNeural/Lattice-3-Synapse-192M-Poincare-Instruct5L Base Pretrained): DuoNeural/Lattice-2-192M-Poincare-Base3L v3 Hybrid): DuoNeural/Sub-Lattice-v3-18M-Poincare-Hybrid4L v1 Preview + GGUF): DuoNeural/Lattice-1-107M-Poincare-Preview3L v1 Instruct + GGUF): DuoNeural/Sub-Lattice-17M-Poincare-Instruct@misc{caldwell2026lattice4nexus,
title={Lattice-4-Nexus & Lattice-4-Josephson: Hyperbolic Josephson Junction Synchronization and Holographic AdS Bulk Stratification in 7-Layer Crystallographic Language Models},
author={Caldwell, Jesse and Archon and Aura},
year={2026},
publisher={DuoNeural Research Lab},
howpublished={\url{https://huggingface.co/DuoNeural/Lattice-4-Nexus-253M-Poincare-Instruct}},
note={Code and training scripts at \url{https://github.com/DuoNeural/Lattice-CDM}}
}
"The geometry holds."
pytorch_model_final_100k.pt 967 MiBpytorch_model.pt 967 MiBHuggingFaceTB/SmolLM2-1.7B-Instruct