Skip to content

About

Verifiable inference for native-FP LLM APIs (vLLM, CUDA Graphs): folded ZK-Basefold + FracLogUp-GKR prover, zero-dep Rust verifier, and 28 Lean 4 modules.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

FlashProve-Next

Verifiable inference for production LLM APIs. By Liang Song.

CI Release Lean 4 License

English · 简体中文 · Project Homepage · Reviewer Guide · Paper (PDF) · Specs (01–11)


Why This Exists

When you call a closed-weight LLM API, you have no cryptographic proof of what ran behind the endpoint: whether the server routed your request to a smaller model under load, quantized a bf16 checkpoint to int4, skipped layers, truncated context, or shortened a hidden system prompt to save reasoning tokens.

FlashProve-Next attaches a verifiable zero-knowledge-masked proof to an API response under two constraints:

  1. Keep production serving intact. No fixed-point surrogate model and no deterministic-integer rewrite. Inference runs in native floating point (bf16/fp8/mxfp4 with fp32 GEMM reductions), with temperature/top-$p$ sampling, FlashAttention, CUDA Graphs, continuous batching, and prefix caching. Proving runs asynchronously after streaming finishes.
  2. Protect serving secrets. The proof hides model weights, hidden system prompts, hidden chain-of-thought (CoT) text, intermediate activations, and multi-turn encrypted state. In v1.0.0, dense full-reply profiles still expose coarse geometry (layer/width tier); cross-architecture hidden-table privacy is deferred to v2.

Try It on Any Laptop CPU (No GPU, No Model Weights)

1. Rust FPN2 verifier (~10 ms per 8 MiB container)

Verify an exact 8,388,608 B zero-padded FPN2 container (fpn2-llm-std-v1, Q = 72, 64-row reference circuit) using both the zero-dependency #![forbid(unsafe_code)] Rust CLI (core/) and the detached pure-Python reference (verifier/python/, AST-tested for zero prover imports):

pip install numpy   # needed by the Python harness; Rust fpn-verify has zero dependencies
cargo build --release --manifest-path core/Cargo.toml --bin fpn-verify
python demo/run_v1_relation2_demo.py

On an unloaded Apple M1 CPU, the honest 8 MiB container verifies in ~10 ms (warm Rust CLI) and ~110 ms (Python), while all 8 negative checks (E_CIRCUIT_UNPINNED, E_CIRCUIT_PINNED, E_STMT_UNPINNED, E_STMT_PINNED, E_PADDING, E_LENGTH, gate forgery E_SUMCHECK, range forgery E_GKR_ROOT) reject identically across both verifiers and re-proving shares 0 aligned 64-byte private blocks.

2. Real Qwen3-0.6B API proof bundles (demo/run_demo.py)

Verify bundled proofs (Stage 1 FPNZK1 gzip format, ~10.1 MiB each) generated by unsliced Qwen/Qwen3-0.6B (L = 28, d = 1024, V = 151,936) on live vLLM 0.33 (CUDA_VISIBLE_DEVICES="" is enforced automatically; ~30–145 s total on Apple M1 depending on CPU load):

pip install -e ".[tokenizers]"
python -m flashprove_next.build_ext   # optional C++ Goldilocks speedup; pure NumPy works too
python demo/run_demo.py

Checks 3 honest replies (VERIFIED: hidden system prompt + hidden <think> CoT, Turn-1 multi-turn St_prev -> St_new chain, strict JSON-Schema constrained decoding) and 6 attacks (REJECTED: live int4-quantized server, missing --allow-reduced-security, altered reply token, replayed nonce, tampered St_prev, injected schema). Bundled proofs use the compact qwen3-0.6b-demo profile (4 + 2 draws); production profiles use NI-315 (210 + 105) or ExtSeed-153 (102 + 51).


Artifact, Verifier, and Lean 4 Coverage (v1.0.0)

One boundary is worth stating upfront: in v1.0.0, the zero-dependency Rust binary verifies self-contained FPN2 containers (Relations 1–6), whereas full 12-round interactive LLM replies (FPNZK2) still run through the Python verifier.

Format What It Proves Prover Verifier Lean 4 Coverage
FPN2 (binary, fixed size) Self-contained Relations 1–6: Relation 2 (8 MiB 64-row demo), Relation 4 AIR, Relations 5–6 (32×1024 tiles, incl. live vLLM 30B MoE) prover/fpn_prover/backend/ Zero-dep Rust core/ (fpn-verify, 10–24 ms) & detached Python verifier/python/ Executable verifiers for Rel 1, 3–5 (131/131 golden vectors) + conditional Fpn2EndToEnd (THEOREM.md §2.4); Rel 2 & 6 open
FPNZK2 (8 MiB transitional zero-padded JSON) Full 12-round interactive replies (Qwen3-0.6B ExtSeed-153, Qwen3-4B dev 4+2, 14/14 cheating matrix) flashprove_next/reply_zk.py → folded_engine.py (ZK-masked; simulator open) Isolated Python CPU verifier verifier/fpn_verify.py (10.8 s 0.6B / 7.2 s 4B; shares Python stack) Protocol-level RBR, sampling, mask, and blinding modules only; no executable Lean verifier yet
FPNZK1 (Stage 1 gzip) Historical v0.3.0 NI-315 (149.8 MB) & bundled laptop demo (demo/run_demo.py) Legacy flashprove_next/zk_flat.py (--backend legacy) Isolated Python CPU verifier verifier/fpn_verify.py Protocol-level RBR, sampling, mask, and blinding modules only

Comparison with FlashProve

Anthropic's FlashProve showed that closed-weight 400B MoE inference can be proved without hardware enclaves by proving exact full-layer execution of a deterministic 4-bit integer surrogate. FlashProve-Next targets a different point in the design space: keeping native floating-point production serving unchanged.

Dimension FlashProve (2026-11) FlashProve-Next
Guarantee Exact full-layer execution of a committed 4-bit integer surrogate Cost-weighted spot-check threshold ($\sigma = \rho = 0.5$): NI-315 ($\varepsilon \le 2^{-40}, Q \le 2^{64}$) or external-seed ExtSeed-153 ($\varepsilon \le 2^{-20}, Q_{\rm samp} \le 2^{30}$ with pre-recorded C_pre)
Committed model Deterministic 4-bit integer surrogate Deployed bf16/fp8/mxfp4 weights, per-operator rounding bounds, hidden prompts, and sampling key
Serving stack Greedy or fixed-seed integer execution across all layers Native FP (fp32 GEMM reductions), random temperature/top-$p$ sampling, FlashAttention, CUDA Graph, continuous batching, prefix caching
Privacy Weights only; architecture public; no hidden prompts, CoT, or multi-turn state Weights, hidden prompts, hidden CoT, activations, and multi-turn state (v1.0.0 dense reply_zk fixes coarse geometry per profile; cross-architecture hiding in v2)
Commitment lifetime Exhausts after 688,127 batches Non-depleting static RS commitment opened inside proofs (HCO, specs/09)
Proving structure Proves every layer of every token Proves a fixed cost-weighted sample (315 or 153 draws), independent of depth $L$

Core Mechanisms

  1. Non-depleting static RS commitment (HCO, specs/09). Weights, radius matrices, hidden prompts, and the sampling key are committed once into model_id with a one-time setup proof $\pi_{\rm setup}$. Later proofs open touched GEMM tiles inside the circuit with fresh blinding, so the commitment does not wear out.
  2. Single-hop local rounding contracts & lineage billing (specs/06). If a surrogate diverges from native FP on even a small fraction of honest requests, the bit "could the server produce a proof?" leaks hidden activations (paper/flashprove-next.pdf §9.4). Checking each sampled operator against a local reference from the engine's own committed inputs keeps rounding bounds at single-operator scale, while consumer-lineage billing (Rule CA) closes zero-operand layer skipping.
  3. Sort-free bucketed sampling & $\mathbb F_{p^3}$ constrained decoding (BucketSampling.lean, ConstrainedMask.lean). Replaces full-vocabulary sorting with 32-token buckets and a witness-free top-$p$ sandwich (sure/poss), and binds compiled JSON-Schema byte-DFA masks over a 151,936-token vocabulary in $O(k_2 Q_{\rm pad})$ cells via multilinear Schwartz–Zippel ($\le 2^{-186}$).
  4. Zero-Phase-2 folded backend (multi_gkr + multi_pcs + folded_engine). Replaces Stage 1's 2.36B-cell Phase-2 LogUp inverse commitments with batched ZK-masked FracLogUp-GKR (using independent $(0, d_L)/(0, d_R)$ layer-0 denominator blinders) and multi-size layer-injected rate-$1/8$ coset-4 folded ZK-Basefold.

Measured Results (v1.0.0)

Every number below corresponds to a checked-in JSON receipt under benchmarks/ with runnable drivers under bench/ and benchmarks/prover/.

1. Full-Model Reply Proofs & Cheating Matrix

Benchmark Hardware Cells (Ph-2) Container GPU Prove / Total Peak RAM / VRAM CPU Verify Receipt
Qwen3-0.6B ExtSeed-153 (Q=128, unique decoding $\le 2^{-106}$) RTX 6000D 84 GB 1.47G (0) 8 MiB FPNZK2 450.2 / 569.8 s 99.7 / 55.0 GiB 10.76 s (Py) qwen3_06b_extseed153_q128
Qwen3-0.6B ExtSeed-153 (Q=100, A-PCS-fold) RTX 6000D 84 GB 1.47G (0) 8 MiB FPNZK2 461.1 / 571.0 s 100.1 / 54.3 GiB 10.73 s (Py) qwen3_06b_extseed153_v1
Qwen3-0.6B 8+4 cheating matrix (Q=100, 1 honest + 13 attacks) RTX 6000D 84 GB — 8 MiB FPNZK2 14 / 14 pass — exact reject codes qwen3_06b_cheating_matrix
Qwen3-4B 36L, 4.02B (dev 4+2, Q=100) RTX 6000D 84 GB 259M (0) 8 MiB FPNZK2 160.3 / 273.0 s 58.2 / 47.8 GiB 7.18 s (Py) qwen3_4b_mc4_mg2_v1
Qwen3-0.6B Stage 1 NI-315 (1.51 B/cell streaming, 116 hidden CoT) RTX 4070 Ti S 16 GB 5.25G (2.36G) 149.8 MB FPNZK1 3,752 / 3,878 s 21.0 / 11.3 GiB 12.02 s (Py) qwen3_06b_reply_315
Qwen3-0.6B Stage 1 setup proof $\pi_{\rm setup}$ (items i–vi) RTX 4070 Ti S 16 GB 8.67G 353.0 MB 3,623.7 s 12.2 / 4.2 GiB 59.91 s (Py) qwen3_06b_mcsetup

Notes on the table:

  • The 14/14 matrix includes fresh 28-layer PyTorch forward passes on 196 perturbed linear weights and 196 group-32 int4-quantized linear weights verified against the committed bf16 model, alongside skipped layers, truncated KV, tampered hidden prompt/reply/St_prev, missing/swapped C_pre/c_ext, non-zero padding, downgraded Q = 4, and mismatched 4 MiB vs 8 MiB FPNZK2 envelope size.
  • Both ExtSeed-153 runs hit their token cap before </think> (n_reason = 0); hidden CoT (n_reason = 116) is exercised in Stage 1 qwen3_06b_reply_315.json and demo/run_demo.py.
  • Single-stream Qwen3-0.6B ExtSeed-153 total prover time (569.8 s) is ~103× single-stream inference (5.54 s). Keeping fleet-wide proving cost within <= 100% of serving relies on probabilistic audit deterrence (p_audit <= 1%, specified in specs/02-soundness.md §10).

2. Frontier Calibration, Async vLLM Capture, MoE Relation 6 & Agentic State (RTX 6000D)

  • 5-model Blackwell calibration (0 honest false rejections): 0 / 1,846,272 GEMM + MoE expert blocks (863,232 GEMM + 983,040 MoE) plus 0 / 73,728 honest router tokens across Qwen3-4B, Llama-3.2-1B-Instruct, Qwen3.5-0.8B, Qwen3-30B-A3B-FP8, and gpt-oss-20b (frontier_calibrate; single-token router swap detection is 11.5%/38.0% due to zero-margin top-$k$ ties), and 0 / 1.96M non-GEMM rows across RMSNorm, GQA softmax, SWA + learned sinks, and chunk-64 WY Gated DeltaNet (non_gemm_calibrate). Earlier Ada bf16 calibration (0 / 392,928 blocks, 97.3%–100% 8-mode cheat cost, 4k–32k sparse-attention tail bounds) is in benchmarks/certified/.
  • Live vLLM 0.33 Qwen3-30B-A3B-FP8 & Qwen3-0.6B zero-plaintext Relation 6 (live_vllm_rel6_zk_v1): Ephemeral AES-256-CTR lazy chunk commitments (x_commit.py) reduce retained chunk buffers by 192× (25.9 GiB -> 135.0 MiB on 30B MoE, 0.0 MiB increase in recorded peak RSS VmHWM) and cut precommit time to 45.1 s, proving 64 real tiles (64/64 integer-faithful) in 1.49 s with 23.4 ms Rust fpn-verify (VERIFIED), 0 B plaintext activations disclosed, and all forgeries rejected. (Scope: Relation 6 opens 16.8 MB of public weight tiles and does not bind X to the GPU capture or Y to the served output; it is a component milestone rather than a closed-weight full-reply proof.)
  • Zero-sync async vLLM capture & 20-turn incremental state: Enforcing R32 numerics costs 1.2%–2.7% vLLM throughput (vllm_serving_overhead). Zero-sync async CUDA-graph taps (serve/fpn_serve/) achieve 0 extra synchronizations and 0 overflows across all 6 Qwen3-4B TIER_B cells vs numerics_r32: -1.15% (b1, c256), -3.80% (b4, c256), -7.23% (b8, c256), -4.90% (b1, c8192), -11.25% (b4, c8192), and -13.14% (b8, c8192) (async_capture_qwen3_4b). On a 20-turn growing vLLM session (Qwen3-0.6B, 18,506 tokens, 95.8% prefix hit), PageStore cuts capture volume by 10.5× and incremental St_i hashes turn 20 in 0.75–0.92 s (28–34× vs single-thread / 9.9–13.6× vs multi-thread; agentic_20turn).

3. Lean 4 Formalization (lean/, 28 Modules, 696 Axiom-Audited Declarations, Zero sorry)

Verified on Lean 4.29.1 + Mathlib via lean/check.sh with native_decide forbidden and only the three standard axioms (propext, Classical.choice, Quot.sound):

  • 19 protocol modules (219 audited declarations): round-by-round lifetime soundness composition (RoundByRound, LifetimeSoundness, ProtocolBridge), all 16 sample-count table cells, multi-column LogUp, bucketed top-$p$ sampling (BucketSampling), $\mathbb F_{p^3}$ constrained-mask binding (ConstrainedMask), causal multi-round masking (MaskJoint), and algebraic identities for MoE, MLA, linear attention, and speculative decoding.
  • 9 FPN2 modules (477 audited declarations): Mathlib-free executable byte verifiers (VerifyBytes, Fpn2Rel3–5, matching all 131/131 golden vectors + 26/26 multi-tile cases), concrete Goldilocks $\mathbb F_{p^3}$ soundness (Fpn2Soundness), constraint-to-integer proofs for 6 IR gadget families (Fpn2Gadgets), and conditional ProtocolRBRSpec instantiation at verifyBytesRel4/5 (Fpn2EndToEnd, see lean/THEOREM.md §2.4 for exact CryptoAssumptions and Delta caveats).

4. Known Boundaries & Next Work (v2)

  • Rust single-binary verification of full replies: lower reply_zk's 12 interactive commit rounds into a self-contained CircuitDesc.
  • Folded-prover host RAM & 4B+ production draws: restore ~1.5 B/cell streaming to bring 100 GiB folded RSS back toward Stage 1's 21 GiB, and run production draws on 4B and 30B+ closed-weight models.
  • Formalization & ZK proofs: complete Johnson-regime RBR for multi-size injection (A-PCS-fold; bypassed at Q >= 128), write a transcript-wide ZK simulator for the folded backend, add Lean verifiers for Relations 2 and 6, and mechanically connect Python circuit synthesis to CompiledCS.
  • Cross-architecture hiding: replace per-profile dense geometry with uniform hidden-table slots across Dense GQA, Sparse MoE, MLA, SWA, and linear attention.

Release History

Release Highlights Status
Stage 0 (v0.2.0) Paper, specs 01–10, 18 Lean 4 modules, Ada bf16 tolerance & cheat benchmarks Released
Stage 1 (v0.3.0) Streaming $\mathbb F_{p^3}$ prover (1.51 B/cell), Qwen3-0.6B setup + NI-315 proofs, laptop CPU demo, vLLM 0.33 CUDA-graph plugin, 19th Lean module Released
v1.0.0 Zero-Phase-2 folded backend (8 MiB FPNZK2, Q=128 unique decoding), zero-dep Rust fpn-core/fpn-verify + detached Python reference (specs/11, Rel 1–6), 28 Lean 4 modules (696 audited decls), RTX 6000D Qwen3-0.6B/4B/30B-A3B-FP8 receipts & 5-model calibration Current
v2 Single-binary Rust verification for 12-round replies, streaming folded host RAM, cross-architecture hidden tables, Lean Rel 2/6 Planned

Repository Layout & Verification Commands

FlashProve-Next/
├── README.md, README.zh-CN.md  # English & Chinese overviews
├── REVIEW.md                   # Reviewer guide, trusted base & claim-to-evidence map
├── CHANGELOG.md, CITATION.cff  # Release notes & citation metadata
├── core/                       # Zero-dep, no-unsafe Rust `fpn-core` + `fpn-verify` CLI (FPN2 Rel 1–6)
├── verifier/                   # Detached Python `fpn_verify_ref` (FPN2) & `fpn_verify.py` (FPNZK1/2)
├── prover/, serve/             # Folded ZK backends (`multi_gkr`/`multi_pcs`/`folded_engine`) & async vLLM capture
├── flashprove_next/            # Reply circuit builder, gadgets, sampling & FPNZK1/FPNZK2 bundle verifier
├── integrations/vllm/          # Non-invasive vLLM 0.33 loader plugin, CUDA-graph capture & prover daemon
├── demo/                       # Offline laptop CPU demos (`run_v1_relation2_demo.py`, `run_demo.py`)
├── lean/                       # Lean 4.29.1 + Mathlib formalization (28 modules, 696 audited decls, 0 sorry)
├── paper/                      # Technical report (Markdown, LaTeX, compiled PDF)
├── specs/                      # Eleven specifications (01–11) & golden test vectors
├── bench/, benchmarks/         # Runnable GPU benchmark drivers (`bench/`) & public JSON receipts (`benchmarks/`)
├── tests/                      # CPU CI suite, 4 unit shards & perturbation/mutation/wbforge audits
└── docs/                       # Bilingual project portal + PDF download
# 1. Zero-dep Rust FPN2 Relation-2 CPU demo (8 MiB, Q=72, 64-row reference circuit)
pip install numpy
cargo build --release --manifest-path core/Cargo.toml --bin fpn-verify
python demo/run_v1_relation2_demo.py

# 2. Real Qwen3-0.6B Stage-1 proof bundles & fast CPU checks
pip install -e ".[tokenizers]"
python -m flashprove_next.build_ext
python demo/run_demo.py
FPN_CI_FAST=1 python -m tests.test_fast_cpu

# 3. Verify all 28 Lean 4.29.1 modules (696 axiom-audited decls, 0 sorry, standard axioms only)
(cd lean && lake exe cache get && bash check.sh)

# 4. Rebuild Technical Report PDF (0 errors / warnings)
python3 paper/md2tex.py paper/flashprove-next.md paper/flashprove-next.tex
(cd paper && tectonic flashprove-next.tex)

# 5. Full Rust verifier tests, detached Python verifier tests, and golden vector regeneration
cargo test --manifest-path core/Cargo.toml --release
PYTHONPATH=verifier/python python -m unittest discover -s verifier/python/tests
python specs/vectors/generate.py --check

About

Verifiable inference for native-FP LLM APIs (vLLM, CUDA Graphs): folded ZK-Basefold + FracLogUp-GKR prover, zero-dep Rust verifier, and 28 Lean 4 modules.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages