Ziv Meets Sumcheck: Zero-Knowledge Proofs of Floating-Point LLM Inference
Organizations: School of Engineering, University of British Columbia (Okanagan Campus), Kelowna, BC, Canada
Abstract
Zero-knowledge proofs can show that a neural network produced a given output without revealing the network, but current systems for language models prove integer approximations of the model rather than the floating-point arithmetic that is actually deployed. Proving floating-point matrix multiplication has been regarded as hard, because rounding after every addition makes the result depend on the order of the additions. We avoid this obstacle by proving the correctly rounded product, in which every dot product is computed exactly and rounded once. This result is independent of the hardware and at least as accurate as standard kernels. We give an interactive proof for this relation whose cost is close to that of integer matrix multiplication, with roughly a thousand times fewer committed values than per-operation floating-point circuits need constraints, extend it to every layer of a transformer, and give a privacy construction for the complete argument whose zero knowledge we prove under explicit hypotheses. We implement the system and prove the full forward pass of GPT-2 small, including all twelve blocks and the output over the whole vocabulary, in 19 minutes on two processor cores; verification takes 21 seconds. The verifier rejects all 236 attacks we tested, and the model's outputs agree with high-precision inference at least as closely as standard 16-bit inference does.
Figures & tables
| contribution | content | where |
|---|---|---|
| relations | CR matrix product with fused bias; order-agnostic error bound and rounding test for native kernels; Ziv-style computation of the canonical result | Section III |
| protocol | polynomial IOP for : exponent bucketing, integer lifting, exact rounding gadget; complete and sound under explicit field-size conditions | Theorem 1 |
| block | every operation of a transformer block (canonical LayerNorm and softmax, lookups, maximum by selection), chained through views | Theorem 2 |
| privacy, full model | hiding commitment, masked sumchecks, zero sums, hidden LogUp sums, embedding and output checks; ZK under explicit, unproved hypotheses | Theorem 3 |
| evaluation | reference and native implementations on GPT-2 with real weights | Section IX |
| step | relation | argument |
|---|---|---|
| matrix product, operand read as | Theorem 1 | |
| row product, fused bias | Lemmas 11 and 7 | |
| unary lookup | Lemma 10 | |
| , | products, broadcast views | Lemma 9 |
| matrix product | Theorem 1 | |
| 16 batched products, views of | Theorem 1 |
| native | Ziv test fails | ||||
|---|---|---|---|---|---|
| site | entries | CR | bin32 | bin64 | |
| qkv | 768 | 14,155,776 | |||
| qk | 64 | 9,437,184 | |||
| av | 128 | 4,718,592 | |||
| aproj | 768 | 4,718,592 | |||
| fc | 768 | 18,874,368 | |||
| perp- | log-loss vs. | greedy | logits | |
|---|---|---|---|---|
| variant | lexity | fp32 (mean s.e.) | CR | CR |
| fp32 | — | — | ||
| native | ||||
| native ′ | ||||
| CR | ||||
| CR-w (48-bit) |
| inst- | prover | verifier | proof | setup | ||
|---|---|---|---|---|---|---|
| workload | ances | MACs | (s) | (s) | (MB) | (s) |
| block, 4 tokens | 28 | |||||
| block, 16 tokens | 28 | |||||
| block, 64 tokens | 28 | |||||
| model, 16 tokens | 343 |
| prover | proof | mask | stream | |
| phase | (s) | (MB) | slots | elements |
| embedding | 70.2 | 5.2 | 88 | 868 |
| one block | 67.4 | 59.9 | 930 | 11561 |
| final LayerNorm | 2.8 | 6.9 | 152 | 2082 |
| one vocabulary chunk | 33.9 | 16.5 | 146 | 1472 |
| complete model (21 phases) | 1121 | 846 | 12422 | 151988 |
| roundoff | with | token | margin gain | random | |
|---|---|---|---|---|---|
| choice | flipped | median | max | flips | |
| (binary32) | |||||
| (binary64) | |||||
| site | cells | lookups | MACs | verdict | |||||
|---|---|---|---|---|---|---|---|---|---|
| qk | 32 | 64 | 32 | 3 | 7 | 52 | 32 | accept | |
| av | 32 | 32 | 64 | 3 | 7 | 52 | 32 | accept | |
| fc | 16 | 768 | 64 | 4 | 8 | 57 | 37 | accept | |
| fc | 32 | 768 | 256 | 4 | 8 | 57 | 37 | accept | |
| aproj | 32 | 768 | 256 | 5 | 9 | 62 | 42 | accept | |
| mproj | 16 | 3072 | 128 | 5 | 9 | 62 | 42 | accept |
| outputs | MACs | this work | gadgets | |||
|---|---|---|---|---|---|---|
| site | /token | /token | (cells) | 64 | 90 | |
| qkv | 768 | 27,648 | ||||
| qk | 64 | 18,432 | ||||
| av | 128 | 9,216 | ||||
| aproj | 768 | 9,216 | ||||
| fc | 768 | 36,864 | ||||
| site | L R | L BLAS | L CR | R CR | BLAS CR | |
|---|---|---|---|---|---|---|
| layer 0, fc | 768 | |||||
| layer 0, mproj | 3072 | |||||
| layer 5, qkv | 768 | |||||
| layer 5, aproj | 768 | |||||
| layer 5, fc | 768 | |||||
| layer 5, mproj | 3072 |
| symbol | meaning | value in the experiments |
|---|---|---|
| field modulus | ||
| , | bucket width, base | , |
| , | exponent range and buckets per format | , |
| largest limb magnitude, | ||
| product limbs, | ||
| to |
| test | count | verdict |
|---|---|---|
| reference: honest (random, Table S2 , layer 5, ties, binade, cancellation, underflow) | 60 | acc. |
| reference: wrong output/neighbour, sign, zero; altered limb, carry, , , , , | 18 | rej. |
| reference, randomized: outputs off by 1–3 units; re-balanced limbs | 239 | rej. |
| native prover: all GPT-2 products; layer 5 at 4/16/64 tokens / 3 tamperings | 427/3 | acc./rej. |
| block: honest / tensor changed / wrong layer, consistent later / proof changed | 1/26/19/10 | acc./rej. |
| complete model: unit tests; honest (1 and 12 blocks) | 4/2 | acc. |