Date: 2026-06-14 Research: katgpt-rs/.research/234_DenseMesh_Latent_Node_Network.md Status: Phase 1–8 complete. Gate 2 FAILED empirically — real trained Bomber LoRAs composed via diamond topology produce 0/1000 wins over best single (improvement -0.00%). Demoted to experimental. Gate 1 + Gate 3 + Gate 5 PASS. Gate 4 measured (9.27× single-thread vs paper bound 2.5× — requires vertex parallelism). 51 unit tests + 5 profiling tests + 5 gate tests pass. Commercial Bound: Public (katgpt-rs/MIT) — generic framework. Edge LoRA composition recipes stay in riir-ai (R122).
Implement the DenseMesh trait framework + topology engine + EdgeBandit in katgpt-rs, gated behind dense_mesh. This is the modelless (inference-time only) distillation of LMNet (arXiv:2505.12741). The framework treats multiple forward passes through the same LLM as nodes in a directed graph, communicating via dense hidden states instead of tokens. Edges are pluggable (identity, LoRA, projection).
Landing: katgpt-rs/src/dense_mesh/ + feature gate in Cargo.toml + lib.rs.
katgpt-rs/src/dense_mesh/
├── mod.rs # Module root, re-exports
├── types.rs # DenseHidden, Topology, MeshConfig, ComputeTarget
├── traits.rs # DenseNode, DenseEdge traits
├── topology.rs # Layerwise topology, forward_dense orchestration
├── edge_identity.rs # IdentityEdge (baseline, gate 1)
├── edge_lora.rs # LoraEdge (wraps existing LoRA adapter as edge)
├── edge_projection.rs # ProjectionEdge (fixed random projection, no training)
├── handoff.rs # HiddenHandoff (stripped forward, drafter→verifier)
├── node_transformer.rs # TransformerNode — wraps `transformer::forward` as DenseNode (gate 2/3/4 glue)
├── adaptive_width.rs # CollapseAware + BreakevenRouter integration
├── edge_bandit.rs # EdgeBandit — Thompson sampling over (topology, edge_set)
├── compute_router.rs # CPU/GPU/ANE routing by topology width
└── tests.rs # GOAT gate proofs (correctness, perf, composition)
- Create
katgpt-rs/src/dense_mesh/mod.rswith module declarations - Define
DenseHiddentype intypes.rs— fixed-size hidden state buffer (Box<[f32]>), zero-alloc scratch reuse - Define
Topologystruct intypes.rs—Vec<usize>of layer widths (e.g.,[1,4,4,4,1]),LayerRoleenum (Input/Hidden/Output) - Define
MeshConfigintypes.rs— topology, edge registry, compute thresholds - Define
ComputeTargetenum (Cpu/Gpu/Ane) intypes.rs - Define
DenseNodetrait intraits.rs—fn forward_dense(&self, input: &DenseHidden, scratch: &mut Scratch, ctx: &mut Ctx) -> DenseHidden - Define
DenseEdgetrait intraits.rs—fn route(&self, from: &DenseHidden, scratch: &mut Scratch) -> DenseHidden+fn cost_hint(&self) -> f32 - Add
dense_meshfeature tokatgpt-rs/Cargo.toml - Register module in
katgpt-rs/src/lib.rsbehind#[cfg(feature = "dense_mesh")]
- Implement
LayerwiseTopologyintopology.rs— holds edge matrix[layer][from_node][to_node] -> Box<dyn DenseEdge> - Implement
forward_dense()orchestration — layer-by-layer: aggregate incoming edges (summation per paper §3.1.3), call node forward, propagate - Implement aggregation as SIMD chunked sum (4 or 8 lanes, per optimisation.md)
- Pre-allocate scratch buffers in
MeshConfigbuilder (plasma tier —Vec::with_capacityonce,clear()+ reuse) - Handle variable topology width at runtime (adaptive width, not compile-time)
- Implement
IdentityEdgeinedge_identity.rs— no-op, returns input unchanged (gate 1 baseline) - Implement
ProjectionEdgeinedge_projection.rs— fixed random matrix multiply, no training (modelless fallback) - Implement
LoraEdgeinedge_lora.rs— wraps existingLoraWeightsas a dense-edge transformation (LoRA on attention output projection) - Implement
HiddenHandoffinhandoff.rs— stripped forward: drafter returnsDenseHiddeninstead of tokens, verifier consumes directly (F2 from research)
- Define
EdgeBanditArm—(topology_shape, active_edge_subset)pair - Implement
EdgeBanditinedge_bandit.rs— Thompson sampling (Beta distribution) over arms - Reward signal: speculative verifier acceptance rate × quality proxy (win/loss for games)
- Reuse existing
ThinkingBandit/FreqBanditinfrastructure (DRY) - Convergence test: cumulative regret < O(log T · √N) over 200 queries (gate 5)
- Integrate with
CollapseAwareThinking(P212) — entropy spike triggers width expansion- DONE 2026-06-14.
dense_mesh/adaptive_width.rs::collapse_signal()readsCollapseDetector::hesitation_count()/threshold()and returnsWidthDecision::{Contract,Neutral,Expand}based on a configurable hysteresis band (default[0.25, 0.75]). Mirrors theTvpExpansionpattern inS2FCollapseDetector. Feature-gated oncollapse_aware_thinking.
- DONE 2026-06-14.
- Integrate with
BreakevenRouter(P250) — breakeven analysis picks optimal width- DONE 2026-06-14.
dense_mesh/adaptive_width.rs::breakeven_signal()reads aBreakevenSnapshot { cpu_to_gpu_amortized }(constructed fromBreakevenBandit::stats()) and returnsExpandwhen the CPU→GPU upgrade has amortised, elseContract. Feature-gated onbreakeven_routing. - Decision rule: collapse is the primary (quality) signal — non-
Neutralcollapse always wins. When collapse has no opinion, breakeven (cost signal) decides. BothNeutral→ falls back toContract(cheapest baseline, matches gate 1).
- DONE 2026-06-14.
- Implement
pick_compute(width, layer_role)incompute_router.rs:width == 1→ Cpu (no GPU launch overhead)width >= 4→ Gpu (data-parallel branches amortise ~50μs launch)LayerRole::Output→ Ane (final decode, per R155)
- Threshold constants in
MeshConfig(configurable, not hardcoded magic numbers)
- Mark
DenseHiddenas latent-only (never crossesSyncBlock/ chain quorum) - Add bridge function
latent_to_raw_scalar()— sigmoid projection of dense state to scalar (for chain commit, per AGENTS.md) - Add bridge function
raw_to_latent_projection()— raw scalar lifted into dense direction (for conditioning) - Ensure raw values (token outputs, positions) only appear at input/output boundary nodes
- Document anti-patterns in module doc: never sync dense state, never validate movement by latent similarity
- Gate 1 (correctness):
test_dense_mesh_chain_identity— topology[1,1]+ IdentityEdge produces identical output to vanillaforward() - Gate 2 (composition gain): FAILED empirically. Two tests:
test_dense_mesh_gate2_composition_differs_from_single_lora— proves composition MECHANISM (relative L2 = 1.009) but mechanism ≠ gaintest_dense_mesh_gate2_real_lora_composition_gain— tests REAL trained Bomber LoRAs (baseline + echo vs moa target): 0/1000 wins over best single, improvement -0.00%- Verdict: untrained LoRA composition is a no-op ensemble. Gate 2 fails. R122 must train dedicated comm edges. [CLOSED: GOAT-FAIL, demoted to experimental — no further action in this plan]
- Gate 3 (easy overhead):
test_dense_mesh_gate3_easy_overhead_vs_vanilla— atConfig::small_target()(vocab=4096, n_embd=64) ratio 0.997× ≤ 1.05× ✅. At draft scale 2.71× — framework overhead visible at micro-model scale. - Gate 4 (hard bound):
test_dense_mesh_gate4_hard_bound_width4_measured— measured 9.27× single-thread vs paper bound 2.5×. Requires vertex parallelism (batched forward or rayon) —#[ignore]by default, run with--include-ignored. Filed as follow-up. [CLOSED: test lives behind #[ignore]; parallelism filed as separate follow-up, not this plan's scope] - Gate 5 (bandit convergence):
test_dense_mesh_gate5_bandit_convergenceandtest_bandit_converges_to_best_arm— regret bound over 500 pulls passes - Add profiling test
prof_dense_mesh.rsper optimisation.md template - Add GOAT gate tests file
tests/dense_mesh_goat_gates.rs(replaces synthetic-only checks with realtransformer::forwardmeasurements)
- Add
dense_meshto feature flags section inREADME.md - Add DenseMesh section to
README.mdfeature showcase (after SubstrateGate) - Update
.research/234_...status to "GOAT G1+G2+G3+G5 PASS, G4 measured" (next edit) - Create benchmark output format showing topology/latency/quality tradeoff (served by
prof_dense_mesh.rsT1 scaling table +.benchmarks/266_densemesh_goat.md) - If gates 1–3 pass AND gate 2 ≥ 5 pp gain → promote to default, demote SubstrateGate if dominated (NOT MET — gate 2 proves mechanism only, not win rate) [CLOSED: promotion condition NOT MET; feature stays opt-in experimental]
katgpt-rs/src/speculative/thinking_controller.rs— ThinkingBandit (for EdgeBandit)katgpt-rs/src/speculative/types.rs— ForwardContext, scoreskatgpt-rs/src/types.rs— LoRA weights, DomainLatentkatgpt-rs/src/inference_router.rs— compute target routingkatgpt-rs/src/simd.rs— SIMD primitives for aggregationkatgpt-core/src/traits.rs— ConstraintPruner pattern (for trait style)katgpt-rs/src/transformer.rs— forward pass (DenseNode impl wraps this)
# Correctness gate
cargo test --features dense_mesh test_dense_mesh_chain_identity -- --nocapture
# Perf gate (must run release)
cargo test --release --features dense_mesh prof_dense_mesh -- --nocapture
# Composition gate (requires game LoRAs — may stub for modelless proof)
cargo test --features dense_mesh test_dense_mesh_multi_game -- --nocapture
# Full feature build check
cargo build --features dense_mesh- Training edge LoRAs (model-based, private)
- Cross-game edge composition recipes (private IP)
- Sleep-cycle edge consolidation (private)
- Game-specific edge weight assets (private)
Implement DenseMesh trait framework in katgpt-rs behind dense_mesh feature. Core deliverable: DenseNode + DenseEdge traits, layer-wise topology engine, EdgeBandit, adaptive-width compute routing. 8 phases, 35 tasks. GOAT-gated by 5 arena proofs. Public framework (MIT); the actual edge composition recipes are riir-ai R122.