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
Fig. 1: Structure of the protocol: the cubic part is one sumcheck over the inner index; everything specific to floating point happens once per output entry.
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 C=CR(A,B,b) : 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
TABLE I: Contributions.
step
relation
argument
z1=RN(xM)
matrix product, operand read as (i,s,l)↦xil
Theorem 1
q1=RN(∑jz1,j2+ϵ^)
row product, fused bias
Lemmas 11 and 7
r1=RN(d/q1)
unary lookup
Lemma 10
t1=RN(z1r1) , h1=RN(t1γ1+θ1)
products, broadcast views
Lemma 9
qkv=RN(h1Wa+ba)
matrix product
Theorem 1
Sh=RN(QhKhT)
16 batched products, views of qkv
Theorem 1
TABLE II: The steps of one GPT-2 block. Every tensor has its own public format, is committed once, and is read by later steps through views. Heads are padded from 12 to 16 and widths from 768 to 1024 and 3072 to 4096; the honest prover sets the padded parameters to zero, but the verifier does not enforce it ( Section VIII ).
native
Ziv test fails
site
k
entries
= CR
bin32
bin64
qkv
768
14,155,776
1.4⋅10−4
45.3%
6.4⋅10−7
qk
64
9,437,184
3.1⋅10−5
1.5%
1.0⋅10−5
av
128
4,718,592
3.5⋅10−5
2.0%
1.7⋅10−4
aproj
768
4,718,592
3.0⋅10−4
60.5%
0
fc
768
18,874,368
7.5⋅10−5
32.5%
5.3⋅10−7
TABLE III: GPT-2 matrix products (4 sequences of 128 tokens, 12 layers): fraction of outputs where the native kernel differs from CR, and where the Ziv test with the bound of Proposition 1 fails.
Fig. 2: Binary exponents of the non-zero entries of four GPT-2 operands in layer 5 (128 tokens, logarithmic vertical axis). The shaded band is a window of 48 bits below the largest exponent. Weights and LayerNorm outputs fit; GELU outputs and attention probabilities have thin tails of very small values.
perp-
Δ log-loss vs.
greedy
logits
variant
lexity
fp32 (mean ± s.e.)
= CR
= CR
fp32
45.99
—
88.7%
—
native
46.05
+0.0013±0.0031
92.1%
53.2%
native ′
46.02
+0.0006±0.0031
92.2%
52.3%
CR
46.14
+0.0032±0.0032
100%
100%
CR-w (48-bit)
46.14
+0.0032±0.0032
100%
100%
TABLE IV: GPT-2 on WikiText-2: 16 sequences of 256 tokens, 4,080 scored tokens. Log-loss in nats; the standard error of the mean log-loss itself is 0.05 . For comparison, native and native ′ choose the same greedy token at 91.9% of the positions.
inst-
prover
verifier
proof
setup
workload
ances
MACs
(s)
(s)
(MB)
(s)
block, 4 tokens
28
2.8⋅107
16.8
0.44
20
42
block, 16 tokens
28
1.14⋅108
23.4
0.72
34
40
block, 64 tokens
28
4.6⋅108
52.6
1.34
54
41
model, 16 tokens
343
1.98⋅109
371.6
9.5
449
625
TABLE V: Native prover, two cores. “Block” is layer 5; “model” is all blocks and the unembedding. Setup (once per model) commits to and certifies the parameters.
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
TABLE VI: Complete GPT-2 forward pass with the privacy construction, 16 tokens, two cores; block and chunk rows are means.
Fig. 3: Committed cells of ΠCR and constraint counts of per-operation floating-point gadgets, per generated token of GPT-2 small at context length 128, by class of matrix product (logarithmic axis).
roundoff
with
token
margin gain
random
u
choice
flipped
median
max
flips
2−24 (binary32)
40.8%
47/48
3.50
9.13
1/48
2−28
8.3%
9/48
0.24
1.27
0/48
2−32
0.96%
1/48
0.03
0.43
0/48
2−53 (binary64)
0.007%
0/48
0.01
0.34
1/48
TABLE S1: Adversarial slack of the error-bounded relation on GPT-2: 48 targets (the last position of 48 sequences of 32 tokens). The median margin between the two largest logits of the honest execution is 0.72 . “Random choices” picks the upper or lower admissible value at random and measures the background sensitivity of bf16 inference.
site
m
k
n
d
Tc
cells
lookups
MACs
verdict
qk
32
64
32
3
7
52
32
6.6⋅104
accept
av
32
32
64
3
7
52
32
6.6⋅104
accept
fc
16
768
64
4
8
57
37
7.9⋅105
accept
fc
32
768
256
4
8
57
37
6.3⋅106
accept
aproj
32
768
256
5
9
62
42
6.3⋅106
accept
mproj
16
3072
128
5
9
62
42
6.3⋅106
accept
TABLE S2: Reference prover and verifier on slices of real GPT-2 operands from layer 5 under CR-w ( GA=GB=GC=4 , TD=7 , w=12 , nc=4 ; k is padded to a power of two). Cells and lookups are per output; MACs are multiply–adds. “cells/out” is ncell of ( 9 ). The Python prover took between 0.4 and 15 seconds and the verifier between 0.1 and 1.6 seconds; these times characterize an unoptimized interpreter, not the protocol.
outputs
MACs
this work
gadgets
site
k
/token
/token
(cells)
64
90
qkv
768
27,648
2.1⋅107
1.6⋅106
1.4⋅109
1.9⋅109
qk
64
18,432
1.2⋅106
1.1⋅106
7.5⋅107
1.1⋅108
av
128
9,216
1.2⋅106
5.3⋅105
7.5⋅107
1.1⋅108
aproj
768
9,216
7.1⋅106
5.7⋅105
4.5⋅108
6.4⋅108
fc
768
36,864
2.8⋅107
2.1⋅106
1.8⋅109
2.5⋅109
TABLE S3: Cost model for all matrix products of one GPT-2 forward step (context 128): committed cells against constraints of per-operation gadgets at 64 and 90 per multiply–add.
site
k
L = R
L = BLAS
L = CR
R = CR
BLAS = CR
layer 0, fc
768
0.8
0.6
0.9
0.5
0.7
layer 0, mproj
3072
4.1
3.0
3.5
3.5
1.6
layer 5, qkv
768
2.1
0.8
1.5
1.5
1.4
layer 5, aproj
768
3.8
4.9
3.3
4.6
4.6
layer 5, fc
768
1.5
0.9
1.1
1.4
0.4
layer 5, mproj
3072
5.2
4.9
4.6
4.9
3.3
TABLE S4: Order dependence of binary32 accumulation: fraction of output entries, in units of 10−4 , on which two kernels differ after rounding to bf16 . L: strict left-to-right; R: strict right-to-left; BLAS: library order; CR: correctly rounded. One sequence of 48 tokens; between 36,864 and 147,456 entries per row, hence individual cells rest on between 5 and 23 differing entries.
symbol
meaning
value in the experiments
p
field modulus
264−232+1
w , β
bucket width, base
12 , 4096
H∙ , G∙
exponent range and buckets per format
48 , 4
Xmax
largest limb magnitude, 255⋅2w−1
522,240
TD
product limbs, GA+GB−1
7
d
(eC−eA−eB)/w
3 to 5
TABLE S5: Parameters. For k≤8192 , Emax<253 , hence Emax+(β+1)βnc/2<260<p and Emax/(β−1)<241<βnc/2=247 , which is ( 7 ); and 2kXmax2<253<p .