PHAZE is a comprehensive framework for benchmarking and evaluating zero-knowledge machine learning (zkML) systems and cryptographic primitives with support for early-exit models, multi-dataset compatibility, and verifiable inference. Built for research applications including high-energy physics at the Large Hadron Collider (LHC).
C. Sonnet the 4th: This README is autogenerated from the project using Claude Sonnet 4. The information has been vetted by PJ, but may not always be up-to-date. Feel free to open Issues/Discussions per the Contribution Guidelines below if you're facing trouble with using/running PHAZE!
- β¨ Features
- π Quick Start
- π‘ Usage
- ποΈ Architecture
- π Performance Analysis & Plotting
- π Benchmarking
- π§ͺ Testing
- π§ Configuration
- π€ Contributing
- π License
- π Acknowledgments
- π Support
- π Legacy Examples
- Dynamic RISC Zero Integration: Automatically generates and builds guest programs for any model architecture
- Multi-Dataset Support: Works with MNIST, CIFAR-10/100, Fashion-MNIST, ImageNet, and custom datasets
- Architecture-Agnostic: Supports simple dense, convolutional, transformer, and multi-exit models
- Comprehensive Benchmarking: End-to-end performance evaluation with statistical analysis
- Privacy-Preserving: Zero-knowledge proofs for model inference verification
- High-Performance: Optimized Rust bindings with parallel processing
- Research-Ready: Built for LHC applications and high-energy physics research
- CLI Tools: Command-line utilities for easy build and dataset management
- Extensive Testing: Full test coverage with integration tests
- Modular Design: Pluggable components for custom workflows
- EZKL Integration: Full PyTorch model compilation and proof generation
- RISC Zero: High-performance zkVM integration for ML inference
- Groth16, Plonky, Halo: Mock implementations for comparative benchmarking
- Unified Interface: Consistent API across different zkML backends
- Early-Exit Models: Adaptive inference with confidence-based termination
- Multi-Exit Networks: Multiple decision points for optimal latency/accuracy trade-offs
- Convolutional Models: CNN architectures for image-like data
- Transformer Models: Attention-based architectures for sequence data
- Complexity Scaling: Minimal to extreme complexity levels for performance testing
- Rabin Fingerprinting: Polynomial-based hashing for data integrity verification
- Shamir Secret Sharing: Threshold secret sharing with configurable parameters
- Field Operations: Finite field arithmetic with multiple field sizes
- Hash Functions: Rust-optimized SHA256 and Keccak256 implementations
- Performance Metrics: Setup time, proof generation, verification time, memory usage
- Scalability Testing: Performance across different input sizes and model complexities
- Framework Comparison: Side-by-side evaluation of zkML approaches
- Automated Reporting: Markdown reports with performance recommendations
- Statistical Analysis: Error bars, confidence intervals, significance testing
- Multiple Plot Types: Time complexity, memory usage, throughput, comparative analysis
- Publication Styles: NeurIPS, IEEE/ACM, presentation, and web-optimized formats
- Export Formats: High-resolution PNG, PDF, SVG for papers and presentations
- Colorblind-Friendly: Accessible color schemes and consistent styling
By default, the setup script configures PHAZE for the MNIST dataset. To use other datasets, specify the --dataset option.
git clone https://github.com/PRAkTIKal24/PHAZE.git && cd PHAZE
python setup_phaze_complete.py --development # Full setup for MNIST with dynamic RISC Zero
uv run phaze --help # Verify installationNote: The above setup includes dynamic RISC Zero integration that automatically supports all model architectures and datasets. For faster setup without RISC Zero:
python setup_phaze_complete.py --development --skip-risc-zero # Quick setup for MNIST
uv run phaze --help # Verify installationPHAZE now supports multiple datasets out of the box:
# Setup for CIFAR-10
python setup_phaze_complete.py --development --dataset cifar10
# Setup for CIFAR-100
python setup_phaze_complete.py --development --dataset cifar100
# Setup for Fashion-MNIST
python setup_phaze_complete.py --development --dataset fashion_mnist
# List all supported datasets
uv run phaze-risc-build datasetsPrerequisites: Python 3.10+, uv package manager
# Clone and install
git clone https://github.com/PRAkTIKal24/PHAZE.git
cd PHAZE
# Option 1: Complete setup with dynamic RISC Zero (recommended)
python setup_phaze_complete.py --development
# Option 2: Setup for specific dataset
python setup_phaze_complete.py --development --dataset cifar10
# Option 3: Quick setup without RISC Zero (faster, limited features)
python setup_phaze_complete.py --development --skip-risc-zero
# Verify installation
uv run phaze --help
uv run phaze-risc-build --help # RISC Zero build utilities# Full development environment with all dependencies
uv sync --group dev --group test
uv run python setup_phaze_complete.py --development
# Test installation (includes integration tests)
uv run pytestIf you get Python version errors (e.g., "Python 3.9.16 does not satisfy Python>=3.10"):
# Option 1: Use your existing Python 3.11 (if you have it via Homebrew/system)
which python3.11 # Check if you have Python 3.11 available
/opt/homebrew/bin/python3.11 setup_phaze_complete.py --development
# Option 2: Keep conda active but force uv to use correct Python
# (Don't deactivate conda if it's your only Python 3.11)
uv venv --python python3.11 # Use conda's Python 3.11
source .venv/bin/activate
# Option 3: If conda is interfering with older Python
conda deactivate # Only if you have other Python 3.11 available
uv python pin 3.11
uv venv --python 3.11
source .venv/bin/activate
# Option 4: Use uv to install Python 3.11 for you
uv python install 3.11
uv python pin 3.11
uv venv --python 3.11If you get Rust target errors on M1/M2 Macs:
# Add the required Rust target for Apple Silicon
rustup target add aarch64-apple-darwin
# If you installed Rust with x86_64 as default, you may need to switch
rustup default stable-aarch64-apple-darwin
# Or temporarily override the target for this build
export CARGO_BUILD_TARGET=aarch64-apple-darwin
# Then retry installation
python setup_phaze_complete.py --developmentPHAZE now includes a comprehensive training pipeline with flexible Python-based configuration system, replacing the previous YAML-only approach. This system provides better IDE support, type safety, and more flexible configuration management.
Complete Training & Benchmarking Pipeline:
# Default: Full pipeline in quick mode (recommended for first use)
uv run phaze
# Full pipeline with complete configuration
uv run phaze --train
# Training only (skip benchmarking and plotting)
uv run phaze --train-only
# Use custom Python configuration
uv run phaze --config my_config.py
# Override specific parameters
uv run phaze --architectures simple,conv --epochs 3
# Verbose output for debugging
uv run phaze --verboseTraining with Custom Parameters:
# Specific model architectures and complexities
uv run phaze --architectures simple,conv,transformer --complexities-train minimal,light
# Custom number of epochs (overrides config)
uv run phaze --epochs 10
# Custom output directory
uv run phaze --output my_benchmark_results/
# Combined example: specific models with custom epochs
uv run phaze --architectures simple,conv --epochs 15-Phase Pipeline:
- Model Training: Train models across architectures/complexities/seeds
- Early Exit Generation: Create early-exit variants from largest models
- zkML Benchmarking: Benchmark trained models with EZKL/RISC Zero
- Crypto Benchmarking: Test early-exit models with Rabin/Shamir algorithms
- Plot Generation: Create publication-ready performance plots
Key Benefits:
- Multi-Dataset Integration: Fast training with balanced subsets for consistent benchmarks across all supported datasets
- ONNX Export: Automatic model export for ezkl compatibility
- Multi-Seed Training: Reproducible results across multiple random seeds
- Automatic Plotting: Real benchmark data integration with plotting system
- Memory Profiling: Track memory usage during training and benchmarking
- Progress Tracking: Detailed logging of each pipeline phase
Configuration Files:
# Python configuration (recommended)
my_config.py:from phaze_config import get_config
# Start with a preset and customize
config = get_config("quick")
config.training.epochs = 2
config.model.architectures = ["simple", "conv"]
config.experiment.seeds = [42, 123]Backward Compatibility: The system maintains backward compatibility with YAML configurations:
# YAML configs still supported
uv run phaze --train --config old_config.yaml
# Auto-detection of file format
uv run phaze --train --config config.yml # YAML
uv run phaze --train --config config.py # PythonConfiguration Presets:
from phaze_config import get_config
# Available configuration presets
config = get_config("default") # Balanced training and benchmarking
config = get_config("quick") # Fast testing and development
config = get_config("minimal") # Minimal resource usage
config = get_config("ci") # CI/CD optimized settings
config = get_config("dev") # Development with verbose loggingCustom Configuration:
# Create custom configurations in Python
from phaze_config import PHAZEConfig, DatasetConfig, ModelConfig, TrainingConfig
# Define custom dataset configuration
dataset = DatasetConfig(
source="mnist",
dataset_size=2000, # Custom dataset size
batch_size=32,
normalize=True
)
# Define model architectures to train
model = ModelConfig(
architectures=["simple", "conv"], # Specific architectures
complexities=["minimal", "light"], # Complexity levels
early_exit_ratios=[0.25, 0.50, 0.75] # Early exit points
)
# Training configuration
training = TrainingConfig(
epochs=5, # More training epochs
learning_rate=0.001,
device="auto", # Auto GPU detection
verbose=True
)
# Create complete configuration
config = PHAZEConfig(
project_name="my_phaze_experiment",
dataset=dataset,
model=model,
training=training
)Output Organization:
benchmark_results/
βββ trained_models/ # Model artifacts
β βββ simple_minimal_seed42.pth
β βββ simple_minimal_seed42.onnx
β βββ simple_minimal_seed42_metadata.json
βββ plots/ # Generated plots
β βββ zkml-proof/
β βββ zkml-verify/
β βββ plotting_summary.md
βββ logs/ # Training logs
βββ complete_benchmark_results.json # Full results
Model Information: Each trained model includes comprehensive metadata:
{
"model_id": "simple_minimal_seed42",
"architecture": "simple",
"complexity": "minimal",
"parameters": 1234,
"accuracy": 0.95,
"training_time": 12.5,
"seed": 42,
"paths": {
"model": "simple_minimal_seed42.pth",
"onnx": "simple_minimal_seed42.onnx"
}
}PHAZE features a revolutionary dynamic RISC Zero integration that automatically generates and builds guest programs for any model architecture, eliminating the need for hardcoded implementations.
- Architecture Detection: Automatically analyzes your model to extract layer dimensions and structure
- Template Generation: Creates optimized Rust guest programs using dynamic templates
- One-Time Build: Builds all necessary guest programs for your dataset configuration
- Runtime Selection: Automatically selects the correct guest program during benchmarking
# List all supported datasets
uv run phaze-risc-build datasets
# Build guest programs for all model architectures (MNIST)
uv run phaze-risc-build build --dataset mnist
# Build for specific dataset
uv run phaze-risc-build build --dataset cifar10
# Scan model factory and show available architectures
uv run phaze-risc-build scan
# Clean and rebuild everything
uv run phaze-risc-build clean
uv run phaze-risc-build build --dataset your_dataset- Simple Dense: Basic feedforward networks with configurable layers
- Convolutional: CNN architectures with conv2d, pooling, and dense layers
- Transformer: Self-attention based models with configurable heads
- Multi-Exit: Early-exit models with multiple confidence-based exit points
from phaze.src.model_architectures import ModelFactory
# Create any model - RISC Zero will adapt automatically
model = ModelFactory.create_model("simple", dataset_config) # Works!
model = ModelFactory.create_model("conv", dataset_config) # Works!
model = ModelFactory.create_model("transformer", dataset_config) # Works!
model = ModelFactory.create_model("multi_exit", dataset_config) # Works!PHAZE supports multiple datasets with automatic configuration:
| Dataset | Input Shape | Classes | Description |
|---|---|---|---|
| MNIST | 28Γ28Γ1 | 10 | Handwritten digits |
| Fashion-MNIST | 28Γ28Γ1 | 10 | Fashion items |
| CIFAR-10 | 32Γ32Γ3 | 10 | Natural images |
| CIFAR-100 | 32Γ32Γ3 | 100 | Natural images (fine-grained) |
| ImageNet | 224Γ224Γ3 | 1000 | Large-scale natural images |
| Custom | Configurable | Configurable | User-defined datasets |
from phaze.src.dataset_config import DATASET_CONFIGS, DatasetConfig
# Use predefined dataset
config = DATASET_CONFIGS["cifar10"]
# Create custom dataset
custom_config = DatasetConfig(
name="my_dataset",
input_shape=(64, 64, 3),
num_classes=20,
data_loader="my_custom_loader"
)# Setup with dataset selection
python setup_phaze_complete.py --development --dataset cifar10
# Batch setup for multiple datasets
for dataset in mnist cifar10 cifar100; do
uv run phaze-risc-build build --dataset $dataset
done
# Verify dataset support
uv run phaze-risc-build datasets --verboseRun Default Pipeline with Dynamic RISC Zero
# Runs full training and benchmarking pipeline with automatic architecture detection
uv run phaze
# Run with specific dataset
uv run phaze --dataset cifar10
# Run with specific model architecture
uv run phaze --model conv --dataset cifar10Multi-Dataset Workflow
# Setup and benchmark across multiple datasets
python setup_phaze_complete.py --development --dataset cifar10
uv run phaze --dataset cifar10 --model transformer
# Switch to different dataset (guest programs auto-selected)
uv run phaze --dataset mnist --model multi_exit
# Batch benchmarking across datasets
for dataset in mnist cifar10 fashion_mnist; do
uv run phaze --dataset $dataset --model conv --output results_$dataset/
doneDynamic RISC Zero Workflow
# Build all guest programs for your dataset
uv run phaze-risc-build build --dataset cifar10
# Run any model architecture (guest programs automatically selected)
uv run phaze --model simple # Uses simple_dense guest program
uv run phaze --model conv # Uses conv_2d guest program
uv run phaze --model transformer # Uses transformer guest program
# Verify guest programs are built
uv run phaze-risc-build scan --verboseGenerate Publication-Ready Plots
# List available plot types
uv run phaze --list-plot-types
# Generate fingerprinting algorithm performance plots
uv run phaze --plot fingerprint --output plots/fingerprint/ --trials 10
# Generate zkML framework performance plots
uv run phaze --plot zkml-proof --style neurips --format png,pdf --output plots/zkml/
# Generate all available plots
uv run phaze --plot all --style publication --output plots/comprehensive/
# Comparative analysis across components
uv run phaze --plot comparative --components fingerprint,zkml-proof --output plots/comparison/
# Use existing benchmark data instead of running new benchmarks
uv run phaze --plot fingerprint --data-file benchmark_results.json --output plots/
# Different plot styles for different use cases
uv run phaze --plot zkml-proof --style presentation --output plots/presentation/ # For slides
uv run phaze --plot fingerprint --style neurips --output plots/paper/ # For papers
uv run phaze --plot all --style web --format png --output plots/web/ # For websitesPHAZE provides comprehensive plotting capabilities for analyzing benchmark results with publication-ready visualizations. The plotting system supports statistical analysis, multiple export formats, and various styling options optimized for research papers, presentations, and web display.
Available Plot Types:
- Fingerprinting Analysis: Time complexity, memory usage, throughput, and algorithm comparisons
- zkML Framework Analysis: Proof generation/verification performance, memory consumption, proof size analysis
- Statistical Analysis: Error bars, confidence intervals, distribution analysis, scaling analysis
- Comparative Analysis: Cross-component performance comparisons and framework rankings
Quick Start with Plotting:
# Generate all available plots with publication quality
uv run phaze --plot all --style neurips --output plots/paper/
# Generate specific analysis plots
uv run phaze --plot fingerprint --trials 10 --output plots/crypto/
uv run phaze --plot zkml-proof --style presentation --output plots/zkml/
# Use existing benchmark data
uv run phaze --plot fingerprint --data-file benchmark_results.json --style publicationFingerprinting Performance Plots:
# Time complexity analysis across algorithms
uv run phaze --plot fingerprint --algorithms rabin,shamir --complexities-plot light,medium,heavy
# Memory and throughput analysis
uv run phaze --plot fingerprint --trials 20 --style neurips --format png,pdfzkML Framework Performance Plots:
# Proof generation and verification analysis
uv run phaze --plot zkml-proof --frameworks ezkl,risc_zero --style publication
# Framework comparison matrix and scaling analysis
uv run phaze --plot zkml-verify --complexities-plot light,medium --trials 10Cross-Component Comparative Analysis:
# Compare performance across different PHAZE components
uv run phaze --plot comparative --components fingerprint,zkml-proof,zkml-verify
# Generate comprehensive analysis with all metrics
uv run phaze --plot all --trials 15 --style neurips --output plots/comprehensive/Built-in Statistical Features:
- Error Bars: Standard deviation, standard error, 95% confidence intervals
- Distribution Analysis: Box plots, violin plots, outlier detection
- Significance Testing: Statistical comparison between frameworks and algorithms
- Effect Size Calculation: Cohen's d for practical significance assessment
Plot Styling Options:
neurips: NeurIPS conference style with serif fonts and publication formattingpublication: IEEE/ACM paper format with high-resolution outputpresentation: Large fonts and clear visuals optimized for slidesweb: Web-friendly styling with smaller file sizes
Export Formats:
# Multiple format export
uv run phaze --plot all --format png,pdf,svg --output plots/
# High-resolution for publications
uv run phaze --plot fingerprint --style publication --format pdfAdvanced Usage Examples:
# Using the Python API for custom plotting
from phaze import PHAZEPlotSuite, PlotConfig, PlotStyle
import asyncio
async def custom_plotting():
# Create custom plot configuration
config = PlotConfig(
style=PlotStyle.NEURIPS,
dpi=300,
export_formats=['png', 'pdf'],
confidence_level=0.95
)
# Initialize plot suite
suite = PHAZEPlotSuite(config)
# Load benchmark data
with open('benchmark_results.json', 'r') as f:
data = json.load(f)
# Generate plots
results = suite.generate_plots(data, ['fingerprint', 'zkml-proof'])
# Generate report
report = suite.generate_summary_report(results, 'plotting_report.md')
print("Plots generated successfully!")
asyncio.run(custom_plotting())Plot Customization:
# Custom trials and output settings
uv run phaze --plot zkml-proof --trials 25 --output custom_plots/ --verbose
# Specific framework and complexity combinations
uv run phaze --plot zkml-proof --frameworks ezkl,risc_zero --complexities-plot medium,heavy
# Generate plots with existing data to save time
uv run phaze --plot all --data-file previous_benchmark.json --style neuripsPHAZE is built on a modular architecture with dynamic components:
PHAZE Framework
βββ Core Components
β βββ Model Factory (architecture-agnostic)
β βββ Dataset Configuration (multi-dataset)
β βββ Dynamic RISC Zero Integration
β βββ Benchmarking Suite
βββ RISC Zero Integration
β βββ Architecture Registry
β βββ Template Engine (dynamic guest programs)
β βββ Build Manager
β βββ Runtime Backend
βββ Cryptographic Primitives
β βββ Hash Functions
β βββ Commitment Schemes
β βββ Zero-Knowledge Proofs
βββ Tools & Utilities
βββ CLI Build Tools
βββ Dataset Managers
βββ Performance Analyzers
- Model Factory: Creates any architecture (simple, conv, transformer, multi-exit) with automatic parameter detection
- Dynamic RISC Zero: Generates Rust guest programs on-demand for any model architecture
- Dataset Configuration: Supports multiple datasets with automatic dimension handling
- Build System: One-time build process that works with all subsequent model architectures
- Benchmarking: Comprehensive performance evaluation with statistical analysis
PHAZE/
βββ README.md # Project documentation
βββ pyproject.toml # Python project configuration
βββ phaze_config.py # Python configuration system
βββ phaze_risc_build.py # CLI utility for RISC Zero build management
βββ setup_phaze_complete.py # Complete setup with multi-dataset support
βββ dev_setup.py # Editable install setup script
βββ uv.lock # Dependency lock file
β
βββ phaze/ # Main Python package
β βββ __init__.py # Package exports and version
β βββ phaze.py # Main CLI interface
β βββ phaze_legacy.py # Legacy benchmark CLI
β βββ src/ # Core implementation modules
β βββ model_architectures.py # Model factory and definitions
β βββ risc_zero_codegen.py # Dynamic RISC Zero integration (NEW)
β βββ dataset_config.py # Multi-dataset configuration (NEW)
β βββ zkml_integration.py # zkML framework integration
β βββ zkml_backends.py # Concrete zkML implementations
β βββ zkml_framework_interface.py # Abstract zkML interfaces
β βββ rust_zkml_backend.py # Rust-Python bindings
β βββ crypto_primitives.py # Cryptographic implementations
β βββ early_exit_models.py # Early-exit model implementations
β βββ training_config.py # Configuration loading system
β βββ training_orchestrator.py # Training pipeline coordinator
β βββ mnist_trainer.py # Fast dataset training
β βββ multi_exit_generator.py # Multi-exit model generation
β βββ enhanced_zkml_benchmark.py # Enhanced zkML benchmarking
β βββ enhanced_crypto_benchmark.py # Enhanced crypto benchmarking
β βββ mock_rust_zkml_bindings.py # Mock Rust bindings for testing
β βββ plotting/ # Plotting system
β βββ __init__.py
β βββ plotters/ # Individual plot implementations
β βββ ...
β
βββ examples/ # Example scripts and tutorials
β βββ multi_dataset_example.py # Multi-dataset benchmarking example (NEW)
β
βββ docs/ # Documentation
β βββ RISC_ZERO_DYNAMIC_INTEGRATION.md # Dynamic RISC Zero documentation (NEW)
β βββ API_REFERENCE.md # API documentation
β βββ ...
β
βββ legacy/ # Legacy benchmark system
β βββ examples/ # Legacy benchmark scripts
β β βββ run_basic_benchmark.py # Standard benchmarking example
β β βββ run_risc_zero.py # RISC Zero specific example
β βββ src/ # Legacy benchmark modules
β βββ benchmarking.py # Legacy benchmark functions
β βββ comprehensive_benchmark.py # Legacy comprehensive benchmarking
β βββ phaze_benchmark_suite.py # Legacy benchmark configurations
β
βββ rust_bindings/ # Rust extension module
β βββ Cargo.toml # Rust project configuration
β βββ src/lib.rs # Rust implementation
β βββ risc0_guest/ # RISC Zero guest program
β βββ target/ # Rust build artifacts
β
βββ tests/ # Test suite
β βββ test_*.py # Comprehensive test coverage
β βββ ... # (20+ test files)
β
βββ docs/ # Documentation
β βββ conf.py # Sphinx configuration
β βββ API_REFERENCE.md # API documentation
β βββ RISCZERO_INTEGRATION.md # RISC Zero integration guide
β βββ _build/ # Generated documentation
β
βββ .github/ # CI/CD configuration
βββ workflows/ # GitHub Actions workflows
PHAZE supports multiple neural network architectures optimized for zkML:
- Simple Early-Exit: Basic feedforward with confidence-based early termination
- Convolutional Early-Exit: CNN architecture for image data with multiple exit points
- Transformer Early-Exit: Attention-based models with adaptive computation
- Multi-Exit: Networks with multiple decision points for latency optimization
Each architecture supports complexity scaling from minimal (fastest proofs) to extreme (highest accuracy).
The framework provides a unified interface for different zero-knowledge proof systems:
| Backend | Status | Use Case | Performance |
|---|---|---|---|
| EZKL | β Full | Production ML | High setup cost, fast verification |
| RISC Zero | β Full | General computation | Balanced performance |
| Groth16 | π§ͺ Mock | Research/comparison | Fastest verification |
| Plonky | π§ͺ Mock | Research/comparison | Moderate performance |
| Halo | π§ͺ Mock | Research/comparison | No trusted setup |
PHAZE tracks comprehensive performance metrics:
- Setup Time: Model compilation and circuit generation
- Proof Generation: Time to create zero-knowledge proofs
- Verification Time: Time to verify proofs
- Memory Usage: Peak memory consumption during operations
- Success Rate: Percentage of successful operations
- Throughput: Operations per second for crypto primitives
| Framework | Setup | Proof Gen | Verification | Memory |
|---|---|---|---|---|
| EZKL (Simple) | ~2-5s | ~1-10s | ~0.1-1s | ~100-500MB |
| RISC Zero | ~1-3s | ~2-8s | ~0.1-0.8s | ~120-400MB |
| Groth16* | ~0.1-1s | ~0.1-2s | ~0.01-0.1s | ~50-200MB |
*Mock implementation - actual performance may vary
# Run all tests
uv run pytest
# Run with coverage
uv run pytest --cov=phaze
# Run specific test modules
uv run pytest tests/test_model_architectures.py -v
uv run pytest tests/test_zkml_integration.py -v
uv run pytest tests/test_benchmarking.py -v
# Run tests in parallel
uv run pytest -n autoThe test suite provides comprehensive coverage:
- Unit Tests: Individual component functionality (105 tests)
- Integration Tests: Cross-component interactions
- Benchmark Tests: Performance validation and regression testing
- Mock Tests: Simulated zkML backend behavior
Current test coverage: 75% with 105 passing tests.
# Optional environment configuration
export PHAZE_LOG_LEVEL=INFO # Logging level
export PHAZE_CACHE_DIR=/tmp/phaze # Cache directory for models/proofs
export PHAZE_RUST_LOG=debug # Rust component loggingThe project uses uv dependency groups for different use cases:
# Development dependencies
uv sync --group dev
# Testing dependencies
uv sync --group test
# Minimal CI dependencies
uv sync --group ci
# Production dependencies only
uv sync --no-devCommon Issues:
# Python version conflicts (conda/system Python interference)
# First check what Python versions you have available
which python3.11 || echo "No system Python 3.11 found"
conda info --envs # See your conda environments
# If you have Python 3.11 via conda, keep conda active and use it
uv venv --python python3.11
source .venv/bin/activate
# If conda is interfering with system Python, try uv's Python management
uv python install 3.11 # Let uv install Python 3.11
uv python pin 3.11 && uv venv --python 3.11
# Rust target issues on Apple Silicon (M1/M2 Macs)
rustup target add aarch64-apple-darwin # Add required target
rustup default stable-aarch64-apple-darwin # Switch default if needed
rustup update # Update Rust toolchain
# To start fresh with Rust (if you have target conflicts):
rustup self uninstall # Remove current Rust installation
rm -rf ~/.rustup ~/.cargo # Clean up directories
# Edit ~/.zshrc to remove cargo PATH entries, then restart terminal
# python setup_phaze_complete.py --development # Reinstall fresh
# EZKL installation problems
pip install ezkl --no-binary ezkl
# Rust compilation issues
rustup update
cd rust_bindings && cargo clean && cargo build --release
# Memory issues with large models
# Use quick_mode for initial testing
uv run python examples/run_benchmark_example.py --quick
# Import errors
# Ensure proper installation
uv sync && uv run python -c "import phaze; print('OK')"We welcome contributions! Please see our contributing guidelines:
# Fork and clone the repository
git clone https://github.com/YOUR_USERNAME/PHAZE.git
cd PHAZE
# Set up development environment with dynamic RISC Zero
uv sync --group dev --group test
python setup_phaze_complete.py --development
# Install pre-commit hooks (optional)
uv tool install pre-commit
pre-commit install
# Verify RISC Zero integration
uv run phaze-risc-build scan
uv run phaze-risc-build build --dataset mnist
# Run comprehensive tests (includes dynamic integration tests)
uv run pytestPHAZE includes several CLI tools for development and debugging:
# RISC Zero build management
uv run phaze-risc-build build --dataset cifar10 # Build guest programs
uv run phaze-risc-build scan --verbose # Scan model factory
uv run phaze-risc-build datasets # List supported datasets
uv run phaze-risc-build clean # Clean build artifacts
# Main benchmarking CLI
uv run phaze --help # Show all options
uv run phaze --model conv --dataset cifar10 # Run specific config
uv run phaze --plot all --style neurips # Generate plots
# Legacy tools (for comparison and migration)
uv run python legacy/examples/run_basic_benchmark.pyThe project uses modern Python tooling:
- Ruff: Linting and formatting (
uv run ruff check .) - pytest: Testing framework with asyncio support
- Type hints: Comprehensive type annotations
- Docstrings: Full API documentation
- Create a feature branch from
main - Make changes with tests
- Ensure all tests pass:
uv run pytest - Check code quality:
uv run ruff check . - Submit pull request with description
This project is licensed under the MIT License - see the LICENSE file for details.
- EZKL Team: Pioneering work in zero-knowledge machine learning
- RISC Zero: High-performance zkVM development
- Rust Community: Cryptographic primitives and performance optimizations
- PyTorch Team: Deep learning framework foundation
- uv/Astral: Modern Python packaging and dependency management
- GitHub Issues: Report bugs and request features
- Discussions: Ask questions and share ideas
- Documentation: Comprehensive API docs in source code
- Examples: Check the
legacy/examples/directory for legacy usage patterns
The examples/multi_dataset_example.py demonstrates the new multi-dataset capabilities:
"""
Multi-dataset benchmarking with dynamic RISC Zero integration.
"""
import asyncio
from phaze.src.dataset_config import DATASET_CONFIGS
from phaze.src.enhanced_zkml_benchmark import ZkMLBenchmarkRunner
async def run_multi_dataset_benchmark():
# Benchmark across multiple datasets
datasets = ["mnist", "cifar10", "fashion_mnist"]
for dataset_name in datasets:
print(f"\n=== Benchmarking {dataset_name.upper()} ===")
# Get dataset configuration
dataset_config = DATASET_CONFIGS[dataset_name]
# Create benchmark runner
runner = ZkMLBenchmarkRunner(dataset_config=dataset_config)
# Run benchmarks for all architectures
architectures = ["simple", "conv", "multi_exit"]
for arch in architectures:
results = await runner.run_architecture_benchmark(arch)
print(f"{arch} architecture: {results.summary}")
if __name__ == "__main__":
asyncio.run(run_multi_dataset_benchmark())See docs/RISC_ZERO_DYNAMIC_INTEGRATION.md for comprehensive documentation on the dynamic RISC Zero system, including:
- Template-based guest program generation
- Architecture registry and build management
- Multi-dataset configuration patterns
- Performance optimization techniques
For legacy usage patterns and migration guides, see the examples directory and API documentation.
PHAZE - Advancing privacy-preserving machine learning through dynamic zero-knowledge benchmarking with multi-dataset support and architecture-agnostic integration.