ZKTorch: Compiling ML Inference to Zero-Knowledge Proofs via Parallel Proof Accumulation

Bing-Jyue Chen, Lilia Tang, Daniel KangarXiv 2025 · DOI

Introduction

As machine learning (ML) models become increasingly integrated into critical decision-making processes, the industry faces a "black box" dilemma. Model owners must protect proprietary weights as trade secrets, while users and regulators require proof that models are operating correctly and fairly. Zero-Knowledge Proofs (ZKPs) offer a solution by allowing a prover to demonstrate that a specific output came from a specific model without revealing internal weights.

However, existing ZKML tools typically fall into two categories: highly flexible but prohibitively slow general-purpose SNARKs, or fast but rigid bespoke protocols that cannot keep pace with rapid ML research. ZKTorch bridges this gap using a modular, compiler-based approach and a novel parallel proof accumulation scheme.

System Architecture and Methods

ZKTorch achieves practical ZKML by decomposing complex models into optimized "basic blocks." The system architecture consists of a multi-stage pipeline that transforms standard models into verifiable proofs.

The ZKTorch end-to-end pipeline, illustrating the flow from ONNX models through the compiler and transpiler to the parallel prover.

The architecture is built on three main pillars:

  1. Optimizing Compiler & Transpiler: ZKTorch takes a standard ONNX model and optimizes it for the ZK environment. For example, it can replace a complex sequence of arithmetic layers representing a GeLU activation with a single, highly efficient table lookup. The transpiler then converts the model into a Directed Acyclic Graph (DAG) of basic blocks.
  2. Modular Basic Blocks: Instead of proving a monolithic circuit, ZKTorch utilizes 61 specialized cryptographic protocols tailored for specific operations such as matrix multiplication, ReLU, and vector addition.
  3. Parallel Proof Accumulation: This is the system's core innovation. Building on the Mira accumulation scheme, ZKTorch generalizes sequential folding into a parallel aggregation structure. This allows the system to aggregate proofs in a tree-like hierarchy, drastically reducing the time bottleneck.
A subset of the 61 basic blocks supported by ZKTorch, categorized by operation type and accumulation status.

Key Insights

The effectiveness of ZKTorch stems from the "Small Set" insight: despite the diversity of modern AI, the authors found that just 61 unique operations cover the entire MLPerf suite. By optimizing these specific blocks, they could support almost any modern model, from CNNs to Transformers.

To maintain accuracy, ZKTorch utilizes fixed-point arithmetic. Since ZKPs operate over finite fields (integers), the system employs 10-12 bits of quantization. This ensures that the model's accuracy—measured by metrics like mAP or ROUGE—remains virtually identical to the original floating-point model.

Results and Evaluation

ZKTorch was evaluated using the MLPerf Edge Inference suite v4.1, including large models like Llama2-7B and Stable Diffusion XL. The system achieved significant performance milestones:

  • Speed: A 6x speedup in proving time compared to general-purpose frameworks, proving GPT-2 inference in 599 seconds.
  • Succinctness: Proof sizes are at least 3x smaller than specialized protocols. For ResNet-50, the proof is a compact 85.41 KB.
  • Compiler Impact: The optimizing compiler alone provided up to a 4.8x reduction in proving time and a staggering 2,398x reduction in proof size for certain CNN architectures by pruning unnecessary shape operations.

Limitations and Future Work

While ZKTorch is highly optimized for multi-threaded CPUs, it does not yet leverage GPU acceleration, which could further reduce proving times for massive LLMs. Additionally, proving very large models currently requires significant memory (up to 4 TB of RAM in tests). Future work will focus on hardware acceleration and extending the transpiler to handle models with highly dynamic control flow.

Summary updated

BibTeX
@misc{chen2025zktorch,
  author = {Bing-Jyue Chen and Lilia Tang and Daniel Kang},
  title = {{ZKTorch: Compiling ML Inference to Zero-Knowledge Proofs via Parallel Proof Accumulation}},
  year = {2025},
  eprint = {2507.07031},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.07031},
}
Figure