Hi everyone,
We have just published a research paper measuring what actually governs LLM inference inside ICP canisters, with the forward pass running fully in consensus, not through off-chain workers, oracles, or proof systems.
Paper: On-Chain LLM Inference Under Instruction Budgets: An Instruction-Budget Cost Model, Ternary Floor Evidence, and Session Costs Authors: Julien Aerni (Meotis Sàrl), Siméon Fluck (Kaizen Corp SA), Dustin Becker (ORIGYN Foundation) Paper + artifact (MIT code, CC BY 4.0 data): https://doi.org/10.5281/zenodo.20607598 Reproduction repo: https://github.com/Simlowker/instruction-bounded-inference-artifact
The core idea
On ICP, decode throughput is not bandwidth bound the way it is on GPUs. It is bounded by the deterministic 40B instruction budget per update call. That turns inference into a budgeted compute problem with a simple first order law:
tok/call ≈ B / (α_eff × 2P)
where α_eff is an effective cost coefficient that is a property of the software stack, not the hardware. Across 11 modern decoder models from 8 families, α_eff clusters at 1.53 (leave-one-architecture-out MAPE 7.7%).
Main results
1. A 2.9× gap from software alone. The same Qwen 2.5 0.5B Q8_0 GGUF, the same mainnet canister framework, the same 40B cap: 10 tok/call on the onicai baseline vs 29 tok/call on our fork. Identical weights, identical boundary; the difference is kernel path vectorization (SIMD dispatch of the quantized matmul inner loops). The result was independently re-validated from a clean rebuild of public sources (REPRODUCE.md, ~30 min CPU, no cycles required).
2. Matmul is 98.7% of decode cost. Everything else (normalization, attention plumbing) is ≤ 1.3–1.7%. We also prove a small theorem: per-element unstructured sparsity strictly increases cost on the measured integer paths. There is exactly one first order optimization lever, and it is the matmul kernel.
3. A ternary floor, live under consensus. We built a custom TQ2_0 (2-bit ternary) WASM SIMD kernel, absent from upstream llama.cpp, and ran purpose-trained TriLM models at the empirical floor of the decode path: α_eff ≈ 1.00 at both 560M and 3.9B. Outputs are byte-identical across a local replica, the 13-node Swiss Subnet, and a standard ICP mainnet subnet, across build generations and independent weight conversion pipelines.
4. Sessions can be budgeted analytically. Multi-call stateful sessions pay a predictable two-term IO tax (KV cache save/load), linear in cache size (R² 0.9998 on the load sweep). A 10-turn chat demo ran on the Swiss Subnet under 13-node consensus.
5. Retrieval fits the regime well. EmbeddingGemma-300M Q4_0 runs fully on-chain at ~126 input tok/call. Batched encode amortizes per-weight loads that single token decode cannot.
Why this matters for the IC
The practical recipe that falls out: choose the model for quality (today the binding constraint), choose parameter count and quantization from the instruction law, optimize the matmul kernel, and treat saved session state as part of the budget. Interestingly, the 40B budget is not even the operative deployment ceiling at current scales; wasm heap and page access limits are (the paper includes an IC0524/IC0502 characterization).
Nothing here requires trusting us. Every load-bearing number resolves to a named CSV row in the artifact, the fork gap rebuild is fully scripted.
Happy to answer questions on methodology, the Swiss Subnet runs, the ternary kernel, or anything else. Feedback and refutation attempts are very welcome; the claim-to-evidence matrix in the repo is designed exactly for that.