Instructions to use transilienceai/loop-surgery with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use transilienceai/loop-surgery with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="transilienceai/loop-surgery")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("transilienceai/loop-surgery", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use transilienceai/loop-surgery with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "transilienceai/loop-surgery" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "transilienceai/loop-surgery", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/transilienceai/loop-surgery
- SGLang
How to use transilienceai/loop-surgery with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "transilienceai/loop-surgery" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "transilienceai/loop-surgery", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "transilienceai/loop-surgery" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "transilienceai/loop-surgery", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use transilienceai/loop-surgery with Docker Model Runner:
docker model run hf.co/transilienceai/loop-surgery
Download reports/GATE_RESULTS.md from transilienceai/loop-surgery: direct link, hf CLI and curl.
- Browser
- Download file 6.22 kB
-
https://huggingface.co/transilienceai/loop-surgery/resolve/main/reports/GATE_RESULTS.md
- Command line
-
hf download hf://transilienceai/loop-surgery/reports/GATE_RESULTS.md
-
curl -L -o GATE_RESULTS.md https://huggingface.co/transilienceai/loop-surgery/resolve/main/reports/GATE_RESULTS.md
Bigger-block structural gate β does a LARGER loop widen the margin? (Modal, 2026-11-23)
The last cheap proxy before any 35B spend. Runs 1β3 (HEAL_RESULTS*.md, DISTILL_RESULTS.md)
showed the loop's win over a matched control stayed ~0.002 nats across answer-only light SFT,
var-pass + 50Γ gate-LR + 8-epoch strong SFT, and reasoning-dense teacher-trace distillation β i.e.
insensitive to data and training strength. The one lever left was structural capacity:
make the looped block bigger and the loop deeper, holding everything else to the strong recipe.
- Block: middle HALF of the layers (
[7:21)= 14 of 28) instead of the central third ([9:18)= 9). - Depth: K up to 8 (var-pass sampled from {1..8}) instead of {1..5}.
- Matched control(1-pass) vs looped(var-pass), same 538 security pairs, 125 held-out Qs, 16 probes.
- bs/max_len backed off (bs2 / len1280) purely for memory at the bigger block + K8; epochs=4 keeps the per-model step count (1076) matched to strong(), so training effort is equal, not confounded.
- Cost: ~$1 (A100, 20.3 min) + ~$0.1 one OOM-crashed first attempt (control's fp32-logit spike at
bs4/len1536 + 14 trainable layers; fixed by backing off bs/len +
expandable_segments). Nothing billing.
Behaviour preserved
Refusal 0/16 both. has_think 1.0 both, ~855β863 <think> chars. Still non-refusing, still thinks.
var-pass depth was sampled evenly across 1β8 (127β144 steps each). Training loss identical
(control last 2.0513 vs looped 2.0515) β the loop added nothing even to the fit.
Loop vs control β the margin SHRANK ~5Γ
Held-out NLL (lower = better):
| metric | control@1 | looped@1 | @2 | @3 | @4 | @5 | @6 | @7 | @8 | loop-best β control |
|---|---|---|---|---|---|---|---|---|---|---|
| reasoning NLL | 2.1653 | 2.1658 | 2.1656 | 2.1656 | 2.1649 | 2.1650 | 2.1651 | 2.1653 | 2.1656 | 0.0004 |
- The win collapsed to 0.0004 nats β roughly a fifth of the ~0.002 the three prior runs all hit. The bigger/deeper loop did not widen the margin; it narrowed it toward zero.
- The gate opened LESS than ever: +0.0079 (vs +0.039 / +0.029 / +0.0235 in runs 1/2/3). The optimizer found even less use for the loop when the block was bigger.
- Deeper passes are inert: K=5β8 regress back to ~2.1656; only Kβ€4 did anything, and barely.
Why bigger made it worse (the mechanism, not noise)
The loop's contribution is gateΒ·(yK β y1). A 14-layer block = half the whole network; one pass
(y1) through it is already a very expressive transform, and the control trains those 14 layers to do
the job in one pass, so the single-pass baseline gets stronger. The extra passes then move an
already-near-converged representation very little β (yK β y1) is tiny β the gate opens less β smaller
margin. Making the loop block bigger at 1.7B does not create reasoning headroom; it just strengthens
the baseline it has to beat. Recurrent-depth wins come from the opposite regime β a small block whose
modest, composable refinements stack into effective depth β not from looping half the net.
The FOUR-run verdict
| run | lever moved | loop-best β control | gate |
|---|---|---|---|
| 1 | answer-only, light SFT | ~0.0019 | +0.039 |
| 2 | training strength (var-pass, 50Γ gate-LR, 8ep) | ~0.0024 | +0.029 |
| 3 | data richness (teacher-trace + soft-KL distill) | ~0.0022 | +0.0235 |
| 4 | structural capacity (bigger block, Kβ€8) | ~0.0004 | +0.0079 |
Four levers β data, training strength, distillation, structure β and none buys a loop margin that matters; the structural lever meant to predict the scale bet pointed the wrong way. The gate was pre-registered as: bigger loop widens the margin β 35B founded; else saved thousands. It shrank the margin. By its own logic the 35B light-heal loopify bet is NOT founded.
What is actually proven vs. not
- PROVEN and fully de-risked: zero-init-gate loop surgery is bit-exact at init, trains end-to-end, stays non-refusing, keeps visible thinking, gives a clean monotone pass-dial, and is robust. The mechanism works. (That was never the question in doubt after run 1.)
- NOT shown, now with 4 negatives: that loopifying our pretrained base + a light heal buys a reasoning win worth custom-serving a new arch β at any cheap lever, and the structural proxy for scale argues against it.
- The one axis none of the 4 runs touched: the training objective never rewards the loop for improving across passes β all four optimize only final next-token NLL, which a strong single pass already reaches. The loop is never taught to be used. Inkling-style wins come from models trained with the loop as a first-class part of the computation, not surgically added then lightly healed.
Decision β no more blind cheap runs; the scale bet is now unsupported
- One last cheap METHOD change (~$1β2), not a size change β deep-supervision: compute the loss at each pass depth and sum, so every extra pass is directly trained to beat the previous one (optionally a small depth-conditioned RL reward). This is the only untested lever and it attacks the actual cause (the loop is never rewarded for depth). If deep-supervision still won't open a margin at 1.7B, stop with high confidence. [recommended: it is cheap and it tests the real hypothesis]
- Bank it and stop the heal line: the mechanism is proven; 4 cheap levers say the margin isn't there under light heal; don't spend $low-thousands to confirm a null at scale. Ship base + skills (already our plan of record) and revisit only with a heavy from-scratch-style loop-training commitment.
- Commit to the 35B loopify anyway β now the weakest-supported option: a scale bet against four negative proxies, including the one designed to predict it. Only sensible staged with a hard early kill-gate, and only if there is an independent reason to believe 35B behaves unlike every small proxy.
Reproduce: cd prod && modal run custom_models/loop_proof/modal_heal.py::gate
(raw metrics + samples in heal_results_gate.json).