Skip to content

eis-lab/VDO

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zkp-dropout

A research playground for verifiable dropout: generating and checking zero-knowledge proofs that a dropout layer was sampled and applied correctly during neural network training. The project combines Python reference code with a minimal RISC Zero zkVM workspace that proves deterministic dropout over quantized tensors.

Repository layout

  • verifiable_dropout.py: Core Python module implementing VRF-backed dropout masks, Merkle-based auditing, zkVM integration helpers, and a demo runner.
  • run_experiments_final.py: Batch experiment harness that compares local hashes against zkVM outputs across dropout probabilities and shapes.
  • debug_2.py: Diagnostic script for probing rounding/quantization rules against zkVM receipts.
  • make_plots.py: Utilities for turning experiment CSV results into publication-ready figures.
  • vdo_zkvm/: Minimal Rust workspace containing zkVM guest (methods/guest), embedding crate (methods), and host CLI for proving (dropout_cli) and verifying (dropout_verify_cli).

Python environment

Install the Python dependencies into a virtual environment (Python 3.10+ recommended):

python -m venv .venv
source .venv/bin/activate
pip install torch cryptography numpy pandas matplotlib tqdm

verifiable_dropout.py and the experiment scripts expect PyTorch and the cryptography package for Ed25519-based VRF signatures.

Building the zkVM binaries

The zkVM side is optional for modes A/B but required for mode C proofs.

cd vdo_zkvm
# Fast dev mode (no real proving)
RISC0_DEV_MODE=1 cargo test -p host --release
# Real proving
cargo test -p host --release

Successful builds produce:

  • vdo_zkvm/target/release/dropout_cli – proves dropout and emits a receipt/journal hash.
  • vdo_zkvm/target/release/dropout_verify_cli – verifies receipts and replays the journal.

Running the demo (mode C)

verifiable_dropout.py contains a self-contained demo that:

  1. Builds a simple MLP with a VerifiableDropout layer.
  2. Generates a VRF seed for the layer.
  3. Calls the zkVM host (dropout_cli) to produce a receipt.
  4. Verifies the receipt with dropout_verify_cli.
# From the repository root (after building the zkVM binaries)
export ZKVM_DROPOUT_CLI="$(pwd)/vdo_zkvm/target/release/dropout_cli"
export ZKVM_DROPOUT_VERIFY_CLI="$(pwd)/vdo_zkvm/target/release/dropout_verify_cli"
python verifiable_dropout.py

mode controls the proof style:

  • A: VRF packet only (fast, no audit).
  • B: Merkle roots of pre/post tensors with block sampling proofs.
  • C: Full zkVM receipt verifying quantized dropout output and mask.

Experiment utilities

  • run_experiments_final.py sweeps dropout probabilities and tensor shapes, invoking the zkVM binaries and writing CSV summaries. Key options include --p-values, --shapes, and --risc0-dev-mode to skip heavy proving during development.
  • debug_2.py offers lower-level reproduction of zkVM hashes with different rounding rules to match guest behavior.
  • make_plots.py consumes CSV outputs (e.g., from run_experiments_final.py) and writes PNG/PDF figures to an output directory.

Example (dev-mode, small sweep):

# Build binaries first (see above)
python run_experiments_final.py --p-values 0.1 0.2 0.5 --shapes 8x16 --risc0-dev-mode --emit-receipt
python make_plots.py --exp1-csv results/exp1.csv --outdir plots

Notes and troubleshooting

  • VerifiableDropout uses deterministic seeds derived from a VRF over (model_id, step, batch_id, nonce, layer_id), ensuring reproducible masks for both prover and verifier.
  • Quantization/rounding logic in verifiable_dropout.py mirrors the Rust guest: int32 tensors scaled by p_den/(p_den-p_num) with half-away-from-zero rounding before clamping.
  • Set RISC0_DEV_MODE=1 in the environment for faster iterations when calling dropout_cli from Python wrappers.
  • If the zkVM binaries are in a non-default location, pass zkvm_bin/verify_bin arguments to the Python helpers or set the environment variables used in the demo.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors