Git Product home page Git Product logo

zen's Introduction

ZEN: Efficient Zero-Knowledge Proof for Neural Networks

Rust version

We test the code using rustc 1.47.0. Use rustup override set 1.47.0 to specify the rust version for compilation.

Prepare Data

  • Under directory ZEN/zk-ml-private-model-baseline/, run mkdir test-data and cargo run --bin gen_data to generate the mock inputs for baseline and microbenchmark purposes only. For optimization level 3, we load real quantization parameters generated from ZEN/numpyInferenceEngine/XXNet/. For example, cd to ZEN/numpyInferenceEngine/LeNet_CIFAR10 and run python3.8 LeNet_end_to_end_quant.py --model LeNet_Small. The generated quantized parameters are located at ZEN/numpyInferenceEngine/LeNet_CIFAR10/LeNet_CIFAR_pretrained/. For easily reproducing the results, we have saved a copy of parameters for all combinations of model and dataset in director ZEN/zk-ml-private-model/pretrained_model/

Commitments

REMINDER: before benchmarking, please use the corresponding num_window parameter. For different input image size, the commitment setting is different. Refer to pedersen_commit.rs and please ensure you use the correct num_window parameter for corresponding dataset.

  • Pedersen input size = window_size * num_window / 8
  • pub const PERDERSON_WINDOW_SIZE: usize = 25; // this is for 28X28X1 MNIST input
  • pub const PERDERSON_WINDOW_SIZE: usize = 100; // this is for 32X32X3 CIFAR u8 input
  • pub const PERDERSON_WINDOW_SIZE: usize = 100; // this is for 46X56X1 FACE u8 input

Microbenchmarks(under zk-ml-baseline directory)

Conv and FC layers different levels of optimization

  • cargo run --bin microbench_conv_layered_optimization_by_kernel_size --release 2>/dev/null
  • cargo run --bin microbench_fc_layered_optimization --release 2>/dev/null

SIMD (stranded encoding) under different batch size

  • cargo run --bin microbench_SIMD_by_batch_size --release 2>/dev/null

LeNet Small on CIFAR dataset different levels of optimization

  • cargo run --bin microbench_lenet_small_cifar_naive --release 2>/dev/null
  • cargo run --bin microbench_lenet_small_cifar_op1 --release 2>/dev/null
  • cargo run --bin microbench_lenet_small_cifar_op2 --release 2>/dev/null
  • cargo run --bin microbench_lenet_small_cifar_op3 --release 2>/dev/null

Naive/baseline for all combinations of models and datasets(only calculate the number of constraints)

  • cargo run --bin shallownet_naive_mnist --release 2>/dev/null
  • cargo run --bin lenet_small_naive_pedersen_cifar --release 2>/dev/null
  • cargo run --bin lenet_medium_naive_pedersen_cifar --release 2>/dev/null
  • cargo run --bin lenet_small_naive_pedersen_face --release 2>/dev/null
  • cargo run --bin lenet_medium_naive_pedersen_face --release 2>/dev/null
  • cargo run --bin lenet_large_naive_pedersen_face --release 2>/dev/null

Under zk-ml-private-model directory

Optmization level 3 for all combinations of models and datasets

  • cargo run --bin shallownet_optimized_pedersen_mnist --release 2>/dev/null
  • cargo run --bin lenet_small_optimized_pedersen_cifar --release 2>/dev/null
  • cargo run --bin lenet_medium_optimized_pedersen_cifar --release 2>/dev/null
  • cargo run --bin lenet_small_optimized_pedersen_face --release 2>/dev/null
  • cargo run --bin lenet_medium_optimized_pedersen_face --release 2>/dev/null
  • cargo run --bin lenet_large_optimized_pedersen_face --release 2>/dev/null

Under zk-ml-accuracy directory

Optmization level 3 for all combinations of models and datasets

  • cargo run --bin shallownet_accuracy --release 2>/dev/null
  • cargo run --bin lenet_small_cifar_accuracy --release 2>/dev/null
  • cargo run --bin lenet_medium_cifar_accuracy --release 2>/dev/null
  • cargo run --bin lenet_small_face_accuracy --release 2>/dev/null
  • cargo run --bin lenet_medium_face_accuracy --release 2>/dev/null
  • cargo run --bin lenet_large_face_accuracy --release 2>/dev/null

zen's People

Contributors

brucechin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.