How to prove a model with ZisK
To prove a model ran, you write the model as a program and let ZisK prove the program. The idea is that simple; the craft is in five decisions. We'll walk through them with three models of growing size: Andrej Karpathy's stories260K and stories15M, and Qwen3-4B.
Guest: the program ZisK runs and proves; here, the model. Witness: the full record of everything the guest did, which the proof is built from. Precompile: an operation ZisK proves with a dedicated, much cheaper circuit, such as a hash or a dot product.
A language model, in one paragraph
A language model reads text as tokens, small pieces of words. stories15M knows 32,000 of them. For each token it runs the same stack of layers, 6 for stories15M and 36 for Qwen3-4B. Each layer looks back over the story so far (attention), then transforms what it found (a feed-forward step). At the end, it scores every token it knows and picks the best one. That token joins the text, and it goes again.
1. Write the model as a program
ZisK runs ordinary RISC-V programs, the kind a Rust compiler produces, and proves every instruction. So the model is just its forward pass in Rust, following Karpathy's reference code step by step. There's no circuit to design for each model: a new model is new code.
The guest also decides when to stop. Ours writes until a token ends a sentence (with . ! or ?), or the reply reaches 48 tokens, and always picks the highest-scoring token, so the same input always gives the same output.
2. Pin the weights
If the proof doesn't fix the weights, a prover could quietly run a different model. There are two ways to fix them.
- Build them into the program. For stories260K, the weights are part of the guest, so the program's key pins them for free. That stops working fast: a ZisK program's ROM holds at most 65,536 entries, and stories15M's weights didn't fit.
- Hash them inside the proof. For stories15M, the weights are a 30,390,944-byte input file. The guest reads it in place and computes its SHA-256 on every proof, then publishes it.
Hashing 30 MB on every proof costs real time, and the hash you pick matters a lot. ZisK has a precompile for each of these three; we measured them on the same proof:
Proofs per hour, by hash function
Poseidon2 is often the default in proof systems, because other proofs can check it cheaply. For a big blob of bytes it was the slowest by far. We use SHA-256.
3. Keep the math real
A common way to make models cheaper to prove is to change them: shrink the numbers to 8 or 4 bits, or replace hard functions with
lookup tables. Then the proof is about a different model. We keep the model's own arithmetic. The weights are in BF16, a 16-bit format
models often ship in, and every multiplication against the weights goes through ZisK's dot_bf16 precompile:
Because every product is added exactly and rounded only once, the answer doesn't depend on the order of the additions. Everything else (normalising, attention, the activation function) is plain 32-bit math, proven step by step.
BF16 isn't bit-identical to Karpathy's 32-bit original, so we measured the gap. Both read the same 59-token story, and at every position we compared the next-token scores:
Same next token as the 32-bit original
4. Carry the memory between proofs
A model remembers what it has read: for each earlier token it keeps a few hundred numbers, the KV cache. Re-proving the whole conversation every turn would be wasteful, so each proof takes the cache as an input, fingerprints it, and publishes the fingerprint of the new one. The checker makes sure each proof starts from the memory the previous one ended with. The proofs link up:
0000 → 5585df3f → 54285585 → 31ba5428 → da5231ba → 807dda52 → 556bThese are real fingerprints from a three-sentence story. Change one word of sentence 1 and its "after" changes, so sentence 2's proof no longer starts where sentence 1's ended.
Memory isn't free. Each new token looks back over all the earlier ones, so later sentences cost more: our three took 157, 235 and 360 seconds to prove.
5. When the model is too big for one proof
Qwen3-4B has 4 billion parameters and 36 layers, in BF16. That's about 8 GB of weights, far more than one guest can take, so a request is split along the model's own structure:
One job looks up your tokens, one job runs each of the 36 layers, and five jobs each score a fifth of the 151,936-token vocabulary and report their best. The best of the five is the next token. Every job fingerprints the numbers it receives and hands on, so the pieces have to fit together exactly. Some jobs are still too big for one proof: layer 1's matrix work is split further, into 240 slices.
Qwen3-4B, layer 1: 240 slices
Where it stands: the whole model runs end to end inside ZisK, the embedding and the first two slices of layer 1 are proven, and the rest is next. On short inputs, our reference harness matches Hugging Face's model exactly; on long ones, the chosen tokens still match but some scores drift. Finding why is part of the work.
The three examples
| stories260K | stories15M | Qwen3-4B | |
|---|---|---|---|
| Weights pinned by | building them in | hashing them each proof | hashing, per job |
| One proof covers | one token | one token to a sentence | part of one layer |
| Status | proven end to end | proven end to end | runs end to end; first proofs done |