zkML Setup
Introduction
Setting up zkML involve creating all the required artefacts to allow the generation of zero-knowledge proofs as and when required.
zkML Setup Through the CLI
Spectral's CLI will natively handle the required zkML setup for all models submitted as part of a Challenge. However, we encourage Modelers to run the end-to-end zkML workflow on their local machines for the model(s) that they wish to submit.
Given that zkML is still relatively a nascent field in terms of its practicality, there could be a few edge cases that will render a given model to be either incompatible with zkML or otherwise practically inefficient.
Spectral handles zkML setup for all submitted models as soon as they are submitted through our CLI. This is a one-time process to enable subsequent zero-knowledge proof generation and verifications.
However, we encourage Modelers to go through the setup process for their models on their local machines to ensure model compatibility and practicality with ezkl - as highlighted in the Overview and step-by-step guide.
Overview
We have partnered with zkonduit's ezkl library to facilitate zkML proof generation and verification. At a high level, ezkl's setup for a specific model involves:
Generate and calibrate a JSON settings file through
ezkl.generate_settings()
andezk.calibrate_settings()
respectively. These settings will then be used to create a quantized Halo2 circuit to represent the underlying ML modelCompile the ONNX model through
ezkl.compile_circuit()
Fetch the Structured Reference String (SRS) required for zkML's trustless setup
Generate the proving and verifying keys (PK and VK, respectively) through
ezkl.setup()
Further technical details and a step-by-step guide can be found here.
Benchmarks
Some ezkl benchmarks related to its setup across a range of model sizes on a local laptop are:
# of parameters | Setup Time | PK size | VK size | SRS size |
10,497 | 18.756s | 43,650kB (42.6MB) | 27.8kB | 2,049kB (2.0MB) |
17,386 | 24.703s | 86,479kB (84.7MB) | 53.2kB | 4,097kB (4.0MB) |
45,817 | 43.223s | 166,399kB (162.5MB) | 101.2kB | 8,193kB (8.0MB) |
118,721 | 146.281s (02:26) | 417,986kB (408.2MB) | 193kB | 16,385kB (16.0MB) |
197,681 | 226.355s (03:46) | 835,970kB (816.4MB) | 385kB | 32,769kB (32.0MB) |
479,873 | 536.920s (08:57) | 1,671,938kB (1.59GB) | 769kB | 65,537kB (64.0MB) |
1,041,225 | 515.847s (08:36) | 5,015,810kB (4.78GB) | 2,305kB | 196,609kB (192.0MB) |
2,010,929 | 581.635s (09:42) | 6,687,746kB (6.38GB) | 3,073kB | 262,145kB (256.0MB) |
Additional Resources
Refer to our following blog posts to understand more about zkML and how Spectral aims to utilize it:
Last updated