Get more right answers from a local reasoning model on one GPU, and stop it from burning minutes in silent thinking loops.
LoopCD-Cortheon combines LoopCD-Logits (trimming runaway internal thinking loops inside the engine), Gated Cortheon (hardware-aware routing and sandboxed Python/SymPy/Z3/code verification), and Patch 0050 (rescuing stray tool calls instead of dropping turns). Use the verification proxy on any local OpenAI-compatible server, or run the full stack natively on Linux + NVIDIA CUDA GPUs.
Reasoning models can get stuck thinking in circles: re-checking the same step or hitting length caps without writing an answer. A server can look fast on a tok/s counter while the model spends those tokens going nowhere.
What you actually wait for is time until a verified, working answer. Even though LoopCD-Logits lowers raw single-stream decode speed slightly (11–18%), real agent loops finish faster with fewer tokens, and hard tasks solve dramatically more often.
| Goal | Where to look |
|---|---|
| Run the stack right now | Quickstart · GETTING_STARTED.md |
| See where we started → every patch → exact gains | docs/HOW_WE_GOT_HERE.md · patches/README.md |
| Skip already-tested dead ends | docs/EXPERIMENTS_AND_DECISIONS.md · docs/FAILURES_AND_LESSONS.md |
| Build on isolated wins & inference optimizations | Promising Isolated Wins · Inference Optimization Roadmap |
| Inspect verified benchmarks & raw JSONLs | docs/REPORT.md · results/history/ · 07_spark_adapter_cortheon_20261203 |
All numbers below are paired measurements in docs/REPORT.md on Inkling 2 Mini (EXL3 4.0 bpw + DFlash2) on a single 32 GB RTX PRO 4500 Blackwell:
Agents finish faster. On Python REPL coding agent tasks (
n=12), LoopCD-Logits cut median time from 35.8 s → 18.1 s (−49.5%) and median tokens from 7,442 → 3,130 (−57.9%). Across all 36 multi-turn agent tasks, passes rose from 16/36 → 20/36; on jointly solved tasks, agents finished 17% faster with 29% fewer tokens, and degenerate loop traps dropped from 3 → 0.More tasks solved. Gated Cortheon + LoopCD-Logits lifted overall accuracy across 8 benchmarks (
n=336paired) from 58.9% → 72.9% (+14.0 pp,245/336, 95% CI+9.8to+18.5, McNemarp < 0.0001):
- LiveCodeBench hard: 20.0% → 45.0% (
12/60 → 27/60)- AIME 2026: 76.7% → 93.3% (
23/30 → 28/30)- HMMT Feb 2026: 56.7% → 73.3% (
17/30 → 22/30)- SuperGPQA: 46.7% → 63.3% (
28/60 → 38/60)Open-ended synthesis actually finishes. On 10 open-ended tasks at an 8K budget: 0/10 → 9/10. Even against a plain run given twice the output budget (
16Ktokens), LoopCD-Cortheon improved 4/10 → 9/10 in 38% less median time (80.2 s → 50.1 s) and 52% fewer tokens (16,384 → 7,939).Stray tool calls are rescued, not lost. Patch 0050 recovered stray tool/code turns in 6/6 A/B probes on each of two DGX Sparks with bit-identical non-stray generation.
Honest trade-offs. Raw decode speed drops
~11–18%with LoopCD-Logits on (11%on EXL3 C=1, up to18%on NVFP4). Agent loops and open-ended synthesis still finish faster overall; hard competitive coding takes longer (~1.9–2.0×median wall time) to more than double solved problems (12 → 27 of 60).
| Mode | What You Get | Platform & Hardware Requirements |
|---|---|---|
| Option A — Cortheon Proxy | Gated Cortheon routing, sandboxed B=4 Python/SymPy/Z3 & CodeForge consensus, client-side stray-call rescue |
Any OS (Linux, macOS, Windows), Python 3.11+, any local OpenAI-compatible server (Ollama, llama.cpp, vLLM, LM Studio, TensorFold) |
| Option B — Full Native CUDA Stack | Everything in Option A + LoopCD-Logits engine decoding + SM-aware EXL3 kernels + Patch 0050 (required to reproduce the LoopCD + Cortheon numbers) |
Linux + NVIDIA CUDA GPU required: RTX 30 (sm_86), RTX 40 (sm_89), RTX 50 / RTX PRO Blackwell (sm_120), or DGX Spark (sm_121). Requires NVIDIA CUDA 13+ driver, nvcc 13.2+ (13.4 recommended for Blackwell), Zig 0.17.0, and 16 GB+ VRAM (3.3bpw) or 24–32 GB+ (4.0bpw + parallel verification) |
(Python verification code executes inside an OS sandbox — bubblewrap (bwrap) on Linux or Seatbelt on macOS. See SECURITY.md for sandbox guarantees and cortheon guard's non-Python runner note.)
Copy and paste this prompt into Claude Code, Codex, Cursor, or OpenCode:
Set up LoopCD-Cortheon on this machine:
1. Check `nvidia-smi`, OS, `python3`, `zig`, and `nvcc` first.
- If I have an NVIDIA CUDA GPU (`sm_86`/`sm_89`/`sm_120`/`sm_121`) with CUDA 13+, `nvcc >= 13.2`, and Zig `0.17.0`, build the full native TensorFold stack (Option B):
- Clone `https://github.com/Maxrio9/TensorFold.git` branch `inkling2-mini-sm-aware` (contains LoopCD-Logits, SM-aware EXL3 kernels, and Patch 0050 pre-applied).
- Compile with `zig build native -Dsm=<detected_sm> -Dnvcc="$(command -v nvcc)" -Doptimize=safe` (add `-Dtarget=aarch64-linux-gnu.2.28` on DGX Spark `sm_121`).
- Download `Maxrio/Inkling-2-Mini-exl3` (`3.3bpw` on 16 GB VRAM or `4.0bpw` on 24 GB+) plus DFlash2 (`Maxrio/Inkling-2-Mini-DFlash2-FP8` on Blackwell or `incoai/Inkling-2-Mini-DFlash2` on RTX 30/40) and start `tensorfold-native serve` with `--kv-cache fp8 --parallel 8 --loopcd-logits 0.5 --port 8080`.
- Otherwise, use my already-running local OpenAI-compatible server as upstream (`http://127.0.0.1:8080/v1`, Ollama `:11434/v1`, or LM Studio `:1234/v1`).
2. Clone `https://github.com/Maxrio9/loopcd-cortheon.git`, create a venv with Python 3.11+ (`uv venv .venv && uv pip install --python .venv/bin/python -e .`), run `.venv/bin/cortheon doctor`, and test `.venv/bin/cortheon showdown --url http://127.0.0.1:8080/v1`.
3. Start `.venv/bin/cortheon proxy --upstream http://127.0.0.1:8080/v1 --port 18652` and tell me the ready OpenAI endpoint (`http://127.0.0.1:18652/v1`) and Cockpit URL (`http://127.0.0.1:18652/ui`).
Use this with Ollama, llama.cpp, vLLM, LM Studio, or TensorFold:
git clone https://github.com/Maxrio9/loopcd-cortheon.git && cd loopcd-cortheon && \
(command -v uv >/dev/null && uv venv .venv && uv pip install --python .venv/bin/python -e . || { python3 -m venv .venv && .venv/bin/pip install -e .; }) && \
.venv/bin/cortheon showdown --url http://127.0.0.1:8080/v1 && \
.venv/bin/cortheon proxy --upstream http://127.0.0.1:8080/v1 --port 18652Swap --upstream for your server (http://127.0.0.1:11434/v1 for Ollama, :8080/v1 for llama.cpp/TensorFold, :1234/v1 for LM Studio). Add --model <id> if your backend requires a specific model name.
- Point your apps at
http://127.0.0.1:18652/v1using modelcortheon(auto-routes),cortheon:reason,cortheon:code,cortheon:think, orcortheon:fast, or open the live dashboard athttp://127.0.0.1:18652/ui. - Install
/cortheoninto Claude Code, Codex, Cursor, OpenCode, OMP, or Pi:.venv/bin/cortheon install-commands --harness all. - Run
.venv/bin/cortheon doctoranytime to verify your sandbox (bwrapon Linux) and backend connection. SeeGETTING_STARTED.mdfor per-harness configs and challenge prompts.
(Option A gives you Gated Cortheon and client-side stray_rescue.py; for engine-level LoopCD-Logits, use Option B on NVIDIA CUDA.)
The branch inkling2-mini-sm-aware on Maxrio9/TensorFold already includes the full f69e94bd4 LoopCD-Logits engine base plus all 5 patches from patches/tensorfold-v5-sm-aware/ pre-applied (453914542):
1. Build TensorFold for your NVIDIA CUDA GPU (Linux, Zig 0.17.0, CUDA nvcc 13.2+ / 13.4 recommended for Blackwell):
git clone -b inkling2-mini-sm-aware https://github.com/Maxrio9/TensorFold.git
cd TensorFold
zig build native -Dsm=120 -Dnvcc="$(command -v nvcc)" -Doptimize=safeSet -Dsm= to match your CUDA card: 86 (RTX 30), 89 (RTX 40), 120 (RTX 50 / RTX PRO Blackwell), 86,89,120 (multi-arch desktop), or -Dsm=121 -Dtarget=aarch64-linux-gnu.2.28 (DGX Spark). Binary builds at ./zig-out/native/bin/tensorfold-native.
2. Download weights (4.0bpw for 24–32 GB+, 3.3bpw for 16 GB) + DFlash2 drafter, and serve with LoopCD-Logits:
hf download Maxrio/Inkling-2-Mini-exl3 --revision 4.0bpw --local-dir ./inkling-mini
(cd ./inkling-mini && sha256sum --check --strict SHA256SUMS)
# Drafter: Maxrio/Inkling-2-Mini-DFlash2-FP8 (RTX 50 / RTX PRO / Spark) or incoai/Inkling-2-Mini-DFlash2 (RTX 30 / 40)
hf download Maxrio/Inkling-2-Mini-DFlash2-FP8 --local-dir ./inkling-mini/dflash2
export INKLING_THINK_CLOSE_NOTE=$'\n\nThinking budget reached; I act now.'
./zig-out/native/bin/tensorfold-native serve ./inkling-mini \
--name inkling-2-mini --drafter ./inkling-mini/dflash2 \
--kv-cache fp8 --parallel 8 --loopcd-logits 0.5 --port 8080Then start cortheon proxy --upstream http://127.0.0.1:8080/v1 --port 18652 from your loopcd-cortheon checkout. Prefer automatic GPU detection & per-card VRAM sizing (16 GB / 24 GB / 32 GB / DGX Spark)? Use Maxrio9/inkling-2-mini-exl3-recipes.
Inspecting or replaying the 5 engine patches manually on base commit f69e94bd4
Both inkling2-mini-decode-hill (f69e94bd4, LoopCD-Logits base) and inkling2-mini-sm-aware (453914542, with all 5 patches applied) are published on Maxrio9/TensorFold. To audit or apply the series by hand:
git clone -b inkling2-mini-decode-hill https://github.com/Maxrio9/TensorFold.git && cd TensorFold
git am /path/to/loopcd-cortheon/patches/tensorfold-v5-sm-aware/*.patchSee patches/README.md for patch-by-patch details.
- LoopCD-Logits. Inkling 2 Mini runs its shared recurrent core 3 times per token.
LoopCD-Logitskeeps all 3 core passes intact, runs an independent pass-1 reference coda with control/thinking delimiters shielded bitwise, and adaptively contrasts final vs. early logits (0.5). The model commits to answers instead of spinning in loops. - Gated Cortheon (
v2.8.0base). Built on upstreamashhart/Cortheon v2.8.0(SkillForge card-free JIT discovery & ACE/GEPA playbook, ReasonForge v5, CodeForge v9 polyglot TIR, RepoForge v2, sandboxed Lean 4 prover, Cortheon Evolve v2, and optional Rust orchestrator). Requests route dynamically: easy prompts stay direct, hard math goes to reason (parallel execution-verified Python/SymPy/Z3 consensus with Wave-1 early abort), coding goes to CodeForge, Lean theorems go to lean, and architecture/design questions go to think. A hardware gate reads your GPU's concurrency scaling curve so verification only spends parallel streams where they pay off on a single card. - Patch 0050 (
stray_rescue). Recovers usable tool calls or code blocks emitted outside expected parser delimiters — both inside TensorFold (TF_INKLING2_STRAY_CALLS=1) and client-side across Ollama, vLLM, SGLang, llama.cpp, and LM Studio (flash_forge/stray_rescue.py).
| Test | Baseline | LoopCD-Cortheon | Notes |
|---|---|---|---|
| 36 multi-turn agent tasks (pass) | 16/36 | 20/36 | +11.1 pp, loop traps 3 → 0 |
| Python REPL agents (median time / tokens) | 35.8 s / 7,442 | 18.1 s / 3,130 | LoopCD-Logits only (−49.5% wall / −57.9% tok) |
8 benchmarks, n=336 paired items |
198/336 (58.9%) | 245/336 (72.9%) | +14.0 pp, +55/−8, McNemar p < 0.0001 |
| LiveCodeBench hard | 12/60 (20.0%) | 27/60 (45.0%) | ~1.9–2.0× wall time |
| AIME 2026 | 23/30 (76.7%) | 28/30 (93.3%) | |
| HMMT Feb 2026 | 17/30 (56.7%) | 22/30 (73.3%) | |
| SuperGPQA | 28/60 (46.7%) | 38/60 (63.3%) | |
Open-ended synthesis (n=10) |
0/10 (4/10 at 16K) |
9/10 | 50.1 s vs 80.2 s median at 16K (−52% tokens) |
Full paired statistics, confidence intervals, raw receipts, negative ablations (including LoopCD-Hidden, kernel hill-climb ledger, last_loop KV tradeoffs, raw CodeForge budget traps, and Spark adapter+Cortheon Phase 2D receipts) live in docs/HOW_WE_GOT_HERE.md, docs/REPORT.md, docs/FAILURES_AND_LESSONS.md, docs/EXPERIMENTS_AND_DECISIONS.md, and results/ (results/history/).
We started from upstream ashhart/TensorFold + thinkingmachines/Inkling-2-Mini + raw ashhart/Cortheon. Out of the box, plain Inkling-2-Mini stalled in multi-turn loops (16/36 EXL3; 0/10 open-ended at 8K), while raw Cortheon ignored Inkling's <|end_message|> think-close tag (231/267 math caps burned), lost -20 pp on LCB v6 hard (14/60 vs 26/60), misrouted 10/10 MCQs and 8/10 IFBench prompts, and took a -30% raw decode hit from unbatched LoopCD unembed reads.
Five focused layers turned that baseline into main (see docs/HOW_WE_GOT_HERE.md for every delta and receipt):
- Think-close &
LoopCD-Logits 0.5+ Kernel Hill-Climb (Maxrio9/TensorFoldf69e94bd4):#5362think-close fix (+15 ppmath), bitwise-verified pass-1 coda contrasting (5,492/5,492FP32 match),skip_ref_head+ batched[final; ref]LM head + online softmax (161.4 → 568.0 tok/sC=1..16on4.0bpwEXL3) → EXL3 agents16/36 → 20/36(-49.5%Python REPL time), NVFP4 agents14/36 → 20/36. - SM-Aware EXL3 Kernels, CUDA Round Profiler & Patch
0050(patches/tensorfold-v5-sm-aware/): Pre-applied on branchinkling2-mini-sm-aware(453914542), rescuing6/6stray tool/code calls on both DGX Sparks (6/6bit-identical hashes). CodeForgeCF-2&ReasonForgecf3b(flash_forge/): Pruningw3_repair+Red-Teamwhile keepingcode_hc2=TruepushedLCB v6 hardfrom14/60 → 28/60 (46.7%)(p=0.00012); low-T PAL +26kconditionaldeep_escalatelifted AIME26 to28/30and HMMT26 to26/30at-64..-65.6%median tokens.- Default-
directRouter + Hardware Gate (router.py,hardware.py): Fixed MCQ/constraint misroutes (94/94 = 100%live routing,0/44false escalations) and scaled streams byScalingCurve(+14.0 ppacross336paired D2 tasks,p < 0.0001;0/10 → 9/10open-ended). - Strict
bwrapSandbox & Upstreamv2.8.0Upgrade (sandbox.py): Restrictedro_pathsallow-list (blocking~/.ssh), added universal client-sidestray_rescue.py, fixedSIGALRMworker-threadmath_verify, and rebased ontoCortheon v2.8.0.
We did not fold half-tested ideas blindly into main. Several findings already show clear signal in isolated receipts and are left open for contributors to validate end-to-end (details in docs/HOW_WE_GOT_HERE.md):
- Isolated / Not Yet Integrated Into
mainDefaults:- Self-router math under-escalation on unadapted weights (isolated DGX Spark diagnostic — not yet implemented in
router.py):ReasonForgescored12/12 (100%)onaime26and13/16 (81.2%)onhmmt_feb26when escalated on base NVFP4, yet the router left32/60base math prompts indirect_default(65.6%). Adding a Stage-0 Olympiad-math trigger is untested but high-leverage. - Adapter +
LoopCD+Gated Cortheonstacking (isolated DGX Spark NVFP4 receipts; see07_spark_adapter_cortheon_20261203):mo_prime_cortheonhit30/30 (100%)aime26in0.870×wall time vs base and cutlcb_hard(0.215×wall) andifbench(0.498×wall) by2×–4.6×; meanwhilepi-plus-primeshows the saturation boundary where single-pass already gets28/30&22/30. hc_tight_fast(num_streams=3, code_hc2=True) (isolated Desktop D3 receipt —maindefault stays4): Matched85/130vs86/130(p=1.0) at0.876×wall time and0.905×tokens.- Decode MoE pruning (
Patch 0004, default OFF) & multi-GPUv2.8.0(SkillForge+ parallelCodeForge v9): Flags (TF_INKLING2_MOE_TOPK,TF_INKLING2_MOE_BATCH_PRUNE) andv2.8.0code paths exist and pass unit tests, but remain untested end-to-end on full multi-suiteInkling-2-Miniruns.
- Self-router math under-escalation on unadapted weights (isolated DGX Spark diagnostic — not yet implemented in
- High-Leverage Inference Optimization Targets (Roadmap):
- Cut the
0.922 GBBF16unembedread inLoopCD-Logits: Two-stage top-Kshortlist orFP8/INT8quantized pass-1 referenceunembed, plus fused[final; ref]online-softmax GEMM epilogue (TF_INKLING2_PROFILE_ROUND=1). - Cross-stream KV prefix sharing across Cortheon waves: Reuse identical system + problem KV pages across the
3–4parallel streams inReasonForge/CodeForge/ThinkForgeand release pages immediately on Wave-1 early abort. DFlash2×LoopCD=0.5co-tuning &sm_121/sm_120C=2scaling: Pushing single-cardcurve.speedup_c2above1.50×(currently1.10–1.29×) unlocks parallelCodeForge v9without slowing single-GPU Python.LoopCD-Logitsonvarloop(2- vs3-pass) & selectivelast_loopKV: Combine+34%2-pass decode and50%KV savings without hurtingtwo_hoplong-context fidelity.
- Cut the
main(default) — verified LoopCD-Logits + Patch 0050 + Gated Cortheon stack upgraded onto upstreamCortheon v2.8.0(SkillForge,CodeForge v9,RepoForge v2, Lean 4 verifier,Evolve v2, Rust CLI); paired D1–D3 benchmark receipts were recorded onv2.4.0.cortheon-v2.6.0— preservedCortheon v2.6.0head-to-head comparison branch (79/130vs86/130,p = 0.09on single GPU where stricter gating routes morelcb_harditems direct).
flash_forge/&cortheon/: Gated Cortheon routing, hardware gating, stray rescue, sandboxed execution (SECURITY.md), proxy, and CLI.docs/:HOW_WE_GOT_HERE.md(origin → patches → isolated wins → inference optimization roadmap),REPORT.md,FAILURES_AND_LESSONS.md, andEXPERIMENTS_AND_DECISIONS.md(chronological log of everything tested, rejected, and kept).patches/: Unified CUDA/TensorFold SM-aware + Patch 0050 series (tensorfold-v5-sm-aware/).scripts/: Paired evaluation runners andanalyze_loopcd_cortheon.py(rebuildsdocs/REPORT.mdfrom receipts).results/: Raw JSON/JSONL receipts (desktop_d1..d4,spark_stage3_gates_probes) plus full chronological archive inresults/history/.tests/: Unit and sandbox security tests (pytest -q).
MIT License — see LICENSE.
- Concept: Combining LoopCD + Cortheon was inspired by Roberto (
@robertosantosx2on X). - Cortheon & TensorFold: Built by Ash Hart (
ashharton GitHub ·@ashxharton X) — upstreamashhart/Cortheonandashhart/TensorFold. - Patch 0050 & Spark TensorFold stack: Patch 0050 (
TF_INKLING2_STRAY_CALLS) contributed by professorpalmer (@CaryPalmerron X) alongside patches adapted from MiaAI-Lab (@MiaAI_labon X). - LoopCD: Decoding Looped Transformers Better for (Almost) Free — Liu et al. (arXiv:2610.02185).
- Model & Drafter: Inkling 2 Mini by Thinking Machines; DFlash2 by Inco AI; EXL3 quants at
Maxrio/Inkling-2-Mini-exl3.
