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.
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).
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 tqdmverifiable_dropout.py and the experiment scripts expect PyTorch and the cryptography package for Ed25519-based VRF signatures.
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 --releaseSuccessful 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.
verifiable_dropout.py contains a self-contained demo that:
- Builds a simple MLP with a
VerifiableDropoutlayer. - Generates a VRF seed for the layer.
- Calls the zkVM host (
dropout_cli) to produce a receipt. - 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.pymode 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.
run_experiments_final.pysweeps dropout probabilities and tensor shapes, invoking the zkVM binaries and writing CSV summaries. Key options include--p-values,--shapes, and--risc0-dev-modeto skip heavy proving during development.debug_2.pyoffers lower-level reproduction of zkVM hashes with different rounding rules to match guest behavior.make_plots.pyconsumes CSV outputs (e.g., fromrun_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 plotsVerifiableDropoutuses 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.pymirrors the Rust guest: int32 tensors scaled byp_den/(p_den-p_num)with half-away-from-zero rounding before clamping. - Set
RISC0_DEV_MODE=1in the environment for faster iterations when callingdropout_clifrom Python wrappers. - If the zkVM binaries are in a non-default location, pass
zkvm_bin/verify_binarguments to the Python helpers or set the environment variables used in the demo.