Skip to content

Commit 0127d28

Browse files
author
Masoud
authored
complete todo 1: make merkle root public, add lightweight CI (#5)
a set of commits: * updated readme with current and future work * feat: restructure as separate crate with distributed proving - Create distributed-zkml as separate Rust crate - Move distributed/ray modules from zkml to distributed-zkml/src - Add Merkle tree integration tests - Add AWS GPU test infrastructure - Update documentation and testing guides * Reorganize tests: move simple_distributed to tests, add tests README, add AWS test infrastructure * Make AWS resource names configurable via env vars * added applictions * Consolidate QUICK_START.md and remove NEXT_STEPS.md * Remove QUICK_START.md (consolidated into README.md) * readme cleanups * complete todo 1: make merkle root public, add lightweight CI for PRs * add mnist example files for CI tests * fix CI: use nightly rust for int_roundings feature
1 parent fc751f2 commit 0127d28

File tree

19 files changed

+534
-405
lines changed

19 files changed

+534
-405
lines changed

.github/workflows/ci.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [main, dev]
6+
push:
7+
branches: [main, dev]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
RUST_BACKTRACE: 1
12+
13+
jobs:
14+
build-and-test:
15+
name: Build & Test
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Install Rust toolchain
23+
uses: dtolnay/rust-toolchain@nightly
24+
with:
25+
components: rustfmt, clippy
26+
27+
- name: Cache cargo registry
28+
uses: actions/cache@v4
29+
with:
30+
path: |
31+
~/.cargo/registry
32+
~/.cargo/git
33+
zkml/target
34+
key: ${{ runner.os }}-cargo-${{ hashFiles('zkml/Cargo.lock') }}
35+
restore-keys: |
36+
${{ runner.os }}-cargo-
37+
38+
- name: Check formatting
39+
working-directory: zkml
40+
run: cargo fmt --check || echo "::warning::Code formatting issues found (non-blocking)"
41+
continue-on-error: true
42+
43+
- name: Build zkml library
44+
working-directory: zkml
45+
run: cargo build --lib
46+
47+
- name: Run zkml/testing tests
48+
working-directory: zkml
49+
run: |
50+
echo "Running Merkle root public values test..."
51+
cargo test --test test_merkle_root_public -- --nocapture
52+
53+
echo "Running Merkle tree tests..."
54+
cargo test --test merkle_tree_test -- --nocapture
55+
56+
echo "Running chunk execution tests..."
57+
cargo test --test chunk_execution_test -- --nocapture
58+
59+
- name: Run clippy (warnings only)
60+
working-directory: zkml
61+
run: cargo clippy --lib -- -W clippy::all || echo "::warning::Clippy warnings found (non-blocking)"
62+
continue-on-error: true
63+
64+
# Note: AWS tests are intentionally excluded from CI to save costs.
65+
# Run them manually with: cd tests/aws && python gpu_test.py
66+

README.md

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ Extension of [zkml](https://github.com/uiuc-kang-lab/zkml) for distributed provi
44

55
## Overview
66

7-
This repository extends zkml (see [ZKML: An Optimizing System for ML Inference in Zero-Knowledge Proofs](https://ddkang.github.io/papers/2024/zkml-eurosys.pdf)) with distributed proving capabilities. The zkml repository is included as a git submodule in the `zkml/` directory and modified to support Merkle tree commitments for intermediate layer outputs.
8-
9-
zkml provides: An optimizing compiler from TensorFlow to halo2 ZK-SNARK circuits for single-machine proof generation.
7+
This repository extends zkml (see [ZKML: An Optimizing System for ML Inference in Zero-Knowledge Proofs](https://ddkang.github.io/papers/2024/zkml-eurosys.pdf)) with distributed proving capabilities. The zkml repository is included as a git submodule in the `zkml/` directory and modified to support Merkle tree commitments for intermediate layer outputs required in a distributed setting. zkml provides an optimizing compiler from TensorFlow to halo2 ZK-SNARK circuits for single-machine proof generation. High-stakes AI applications in biology or robotics are more practical with trustless verification using [ZKPs (Zero Knowledge Proofs](https://toc.csail.mit.edu/node/218), [SNARKs (Succient Non-interactive Arguments of Knowledge), and zk-SNARKs](https://cs251.stanford.edu/lectures/lecture15.pdf).
108

119
distributed-zkml adds:
1210
- Layer-wise partitioning: Split ML models into chunks for parallel proving across multiple GPUs
@@ -127,26 +125,12 @@ python3 tests/simple_distributed.py \
127125
pytest tests/
128126
```
129127

130-
#### Run Specific Test File
128+
#### Run specific GPU and AWS tests
131129
```bash
132130
pytest tests/aws/gpu_test.py
133-
```
134-
135-
#### Run Specific Test
136-
```bash
137131
pytest tests/aws/gpu_test.py::test_aws_credentials
138132
```
139133

140-
#### Run with Verbose Output
141-
```bash
142-
pytest tests/ -v
143-
```
144-
145-
#### Run Directly (without pytest)
146-
```bash
147-
python3 tests/aws/gpu_test.py
148-
```
149-
150134
### Rust Tests (Cargo)
151135

152136
#### Run All Tests in zkml
@@ -184,7 +168,7 @@ cd zkml
184168
cargo check --lib
185169
```
186170

187-
Note: Broken example files have been moved to `zkml/examples/broken/` to prevent compilation errors. Use `--test` flags when running tests.
171+
Broken example files are moved to `zkml/examples/broken/` to prevent compilation errors. Use `--test` flags when running tests.
188172

189173
### Test Files
190174

@@ -278,13 +262,6 @@ pip install ray torch
278262
nvidia-smi # Verify GPU is available
279263
```
280264

281-
### Running Tests
282-
283-
```bash
284-
# From distributed-zkml root
285-
python3 tests/aws/gpu_test.py
286-
```
287-
288265
### Test Suite
289266

290267
The test suite includes:
@@ -365,7 +342,7 @@ Distributed Proving Simulation: PASS
365342
#### "PyTorch CUDA not available"
366343
- Install PyTorch with CUDA: `pip install torch --index-url https://download.pytorch.org/whl/cu118`
367344

368-
## Next Steps
345+
## TODO: Next Steps
369346

370347
1. **Make Merkle root public**: Add root to public values so next chunk can verify it
371348
2. **Complete proof generation**: Connect chunk execution to actual proof generation

tests/README.md renamed to tests/README_tests.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ export AWS_SESSION_TOKEN=your_token
3535
- `setup_aws_resources.sh` - Creates/gets key pair and security group
3636
- `manage_aws_instance.sh` - Launches instance, runs tests, shuts down
3737
- `find_ami.sh` - Lists available Deep Learning AMIs
38-
- `README.md` - AWS testing documentation
39-
- `QUICK_START.md` - Detailed step-by-step guide
38+
- `README.md` - AWS testing documentation (includes quick start guide)
4039
- `aws_setup_guide.md` - Comprehensive AWS setup guide
41-
- `NEXT_STEPS.md` - Post-setup instructions
4240

4341
See `aws/README.md` for detailed documentation.
4442

@@ -59,3 +57,34 @@ pytest tests/aws/gpu_test.py
5957
python3 tests/aws/gpu_test.py
6058
```
6159

60+
## Testing Merkle Root in Public Values
61+
62+
Tests to verify that Merkle root is correctly added to public values when chunk execution is enabled.
63+
64+
### Run Test Binary
65+
```bash
66+
cd zkml
67+
68+
# Test with chunk execution (layers 0-2) and Merkle root
69+
cargo run --bin test_merkle_public -- \
70+
examples/mnist/config.msgpack \
71+
examples/mnist/inp.msgpack \
72+
0 2
73+
74+
# Test with full model execution (no chunk)
75+
cargo run --bin test_merkle_public -- \
76+
examples/mnist/config.msgpack \
77+
examples/mnist/inp.msgpack
78+
```
79+
80+
### Run Test Suite
81+
```bash
82+
cd zkml
83+
cargo test --test test_merkle_root_public -- --nocapture
84+
```
85+
86+
**What it verifies:**
87+
- Merkle root is computed and added to public values when chunk execution with Merkle is enabled
88+
- Circuit verification passes with MockProver
89+
- Backward compatibility: full model execution still works
90+

tests/aws/NEXT_STEPS.md

Lines changed: 0 additions & 126 deletions
This file was deleted.

0 commit comments

Comments
 (0)