Workshop Framework Examplesยค
This directory contains comprehensive examples demonstrating how to use the Workshop framework for generative modeling with JAX/Flax.
๐ Quick Startยค
Prerequisitesยค
# Install Workshop with all dependencies
uv sync --all-extras
# For CPU-only execution (recommended for testing)
export JAX_PLATFORMS=cpu
Running Examplesยค
# Basic examples
python examples/generative_models/diffusion/simple_diffusion_example.py
python examples/generative_models/vae/vae_mnist.py
python examples/generative_models/gan/simple_gan.py
# Framework features demonstration
python examples/generative_models/framework_features_demo.py
๐ Directory Structureยค
examples/
โโโ README.md # This file
โโโ generative_models/ # All generative modeling examples
โ โโโ audio/ # Audio generation examples
โ โโโ config/ # Configuration examples
โ โโโ deployments/ # Model deployment examples
โ โโโ diffusion/ # Diffusion model examples
โ โ โโโ simple_diffusion_example.py # Basic diffusion implementation
โ โโโ distributed/ # Distributed training examples
โ โโโ energy/ # Energy-Based Model examples
โ โ โโโ simple_ebm_example.py # Basic EBM implementation
โ โโโ geometric/ # Geometric modeling examples
โ โ โโโ geometric_benchmark_demo.py # Benchmark suite
โ โ โโโ geometric_losses_demo.py # Specialized loss functions
โ โ โโโ geometric_models_demo.py # Model architectures
โ โ โโโ simple_point_cloud_example.py # Point cloud processing
โ โโโ image/ # Image generation examples
โ โ โโโ diffusion/ # Image diffusion models
โ โ โโโ gan/ # GAN models
โ โ โโโ vae/ # VAE models
โ โโโ multimodal/ # Multi-modal examples
โ โโโ optimization/ # Optimization examples
โ โโโ protein/ # Protein modeling examples
โ โ โโโ protein_diffusion_example.py # Comprehensive protein diffusion
โ โ โโโ protein_diffusion_tech_validation.py # Technical validation
โ โ โโโ protein_extensions_example.py # Extension mechanisms
โ โ โโโ protein_extensions_with_config.py # Config-driven modeling
โ โ โโโ protein_ligand_benchmark_demo.py # Protein-ligand interactions
โ โ โโโ protein_model_extension.py # Model extensions
โ โ โโโ protein_model_with_modality.py # Multi-modal protein modeling
โ โ โโโ protein_point_cloud_example.py # Point cloud representations
โ โโโ sampling/ # Advanced sampling techniques
โ โ โโโ blackjax_example.py # MCMC sampling with BlackJAX
โ โโโ text/ # Text generation examples
โ โโโ vae/ # VAE examples
โ โ โโโ multi_beta_vae_benchmark_demo.py # ฮฒ-VAE benchmarking
โ โโโ loss_examples.py # Comprehensive loss functions
โโโ utils/ # Utility modules
โ โโโ demo_utils.py # Shared helper functions
โโโ tests/ # Example-specific tests
๐ฏ Featured Examplesยค
Protein Modelingยค
generative_models/protein/protein_diffusion_example.pyยค
Comprehensive protein diffusion modeling example - Our flagship example showcasing both high-level API and direct model approaches for protein structure generation.
- High-level API with extensions: Demonstrates protein-specific extensions and constraints
- Direct model creation: Shows how to create and manipulate models directly
- Visualization & quality assessment: Complete pipeline from generation to analysis
- Size matching fixes: Robust handling of different structure sizes
generative_models/protein/protein_extensions_with_config.pyยค
Configuration-driven protein modeling with extension system.
generative_models/protein/protein_ligand_benchmark_demo.pyยค
Benchmark demonstrations for protein-ligand interaction modeling.
generative_models/protein/protein_point_cloud_example.pyยค
Point cloud representations for protein structure modeling.
Geometric Modelingยค
generative_models/geometric/geometric_benchmark_demo.pyยค
Comprehensive benchmark suite for geometric generative models.
generative_models/geometric/geometric_losses_demo.pyยค
Specialized loss functions for geometric data.
generative_models/geometric/geometric_models_demo.pyยค
Various geometric model architectures and applications.
generative_models/geometric/simple_point_cloud_example.pyยค
Basic point cloud generation and processing.
Advanced Samplingยค
generative_models/sampling/blackjax_example.pyยค
MCMC sampling integration - Advanced sampling techniques using BlackJAX.
- HMC (Hamiltonian Monte Carlo)
- NUTS (No-U-Turn Sampler)
- MALA (Metropolis-Adjusted Langevin Algorithm)
Energy-Based Modelsยค
generative_models/energy/simple_ebm_example.pyยค
Energy-Based Model implementation - Comprehensive example of EBMs with MCMC sampling.
- Energy function computation
- Langevin dynamics sampling
- Contrastive divergence training
- Persistent contrastive divergence with sample buffers
- Deep EBM architectures
Diffusion Modelsยค
generative_models/diffusion/simple_diffusion_example.pyยค
Basic diffusion model implementation - Simple example demonstrating diffusion model fundamentals.
- SimpleDiffusionModel creation and configuration
- Noise schedule setup (beta schedules)
- Sample generation from noise
- Visualization of generated samples
generative_models/diffusion/dit_demo.pyยค
Diffusion Transformer (DiT) demonstration - Advanced diffusion model using transformer architecture.
- DiffusionTransformer backbone architecture
- DiT model sizes (S, B, L, XL configurations)
- Conditional generation with classifier-free guidance (CFG)
- Patch-based image processing
- Performance benchmarking across model sizes
- Sample generation and visualization
VAE Modelsยค
generative_models/vae/multi_beta_vae_benchmark_demo.pyยค
Multi-scale ฮฒ-VAE benchmarking and evaluation.
Image Generationยค
The generative_models/image/ directory contains comprehensive examples for:
- Diffusion models: DDPM, LDM for various datasets
- GANs: StyleGAN, CycleGAN implementations
- VAEs: VQ-VAE, standard VAE for image generation
Text Generationยค
The generative_models/text/ directory includes:
- Transformers: Language models and fine-tuning
- Compression: VQ-VAE for text
๐ Quick Startยค
Basic Usageยค
# Run a simple diffusion example
python examples/generative_models/diffusion/simple_diffusion_example.py
# Run Energy-Based Model example
python examples/generative_models/energy/simple_ebm_example.py
# Run protein diffusion (comprehensive)
python examples/generative_models/protein/protein_diffusion_example.py
# Run BlackJAX sampling
python examples/generative_models/sampling/blackjax_example.py
# Run geometric benchmarks
python examples/generative_models/geometric/geometric_benchmark_demo.py
Prerequisitesยค
Make sure you have activated the Workshop environment:
GPU Supportยค
Most examples are optimized for GPU usage and will automatically use CUDA when available:
๐ง Example Categoriesยค
๐งฌ Protein Modelingยค
- Structure generation and prediction
- Physical constraints and validation
- Multi-modal protein representations
- Benchmarking and evaluation
- Located in:
generative_models/protein/
๐ Geometric Modelingยค
- Point cloud generation
- 3D shape modeling
- Geometric loss functions
- Benchmark suites
- Located in:
generative_models/geometric/
๐ฒ Advanced Samplingยค
- MCMC methods (HMC, NUTS, MALA)
- Custom sampling strategies
- Convergence analysis
- Located in:
generative_models/sampling/
โก Energy-Based Modelsยค
- Energy function learning
- MCMC sampling techniques
- Contrastive divergence training
- Persistent sample buffers
- Located in:
generative_models/energy/
๐ Diffusion Modelsยค
- DDPM implementations
- Custom noise schedules
- Conditional generation
- Located in:
generative_models/diffusion/
๐ผ๏ธ Image Generationยค
- Diffusion models for images
- GAN architectures
- VAE variants
- Located in:
generative_models/image/
๐ Text Generationยค
- Transformer models
- Text compression
- Language modeling
- Located in:
generative_models/text/
๐ Benchmarkingยค
- Performance evaluation
- Model comparison
- Metrics computation
- Distributed across relevant directories
๐ก Usage Tipsยค
Running Examplesยค
- Environment Setup:
- Navigate to Category:
cd examples/generative_models/protein/ # For protein examples
cd examples/generative_models/geometric/ # For geometric examples
# etc.
- Run Example:
GPU Optimizationยค
Examples automatically detect and use GPU when available. Check with:
Modifying Examplesยค
All examples are designed to be educational and modifiable:
- Configuration: Most examples have clear configuration sections at the top
- Modularity: Functions are well-separated for easy customization
- Documentation: Comprehensive docstrings explain each component
Integration with Workshopยค
Examples demonstrate integration with Workshop's core components:
- Models:
workshop.generative_models.models.* - Factory:
workshop.generative_models.factory.* - Config:
workshop.generative_models.core.configuration.* - Modalities:
workshop.generative_models.modalities.* - Extensions:
workshop.generative_models.extensions.*
๐งช Testing Examplesยค
To verify examples work correctly:
# Test imports
python -c "
from examples.generative_models.diffusion import simple_diffusion_example
from examples.generative_models.protein import protein_diffusion_example
print('โ
Basic imports work')
"
# Run specific examples
python examples/generative_models/diffusion/simple_diffusion_example.py
python examples/generative_models/protein/protein_diffusion_example.py
๐ Learn Moreยค
- Main Documentation: See the main README.md in the repository root
- API Reference: Check
docs/directory - Configuration: See
src/workshop/generative_models/core/configuration/ - Factory System: See
src/workshop/generative_models/factory/
๐ Troubleshootingยค
Common Issuesยค
- Import Errors: Make sure you've activated the environment with
source ./activate.sh - CUDA Issues: Run
python scripts/verify_gpu_setup.pyto diagnose GPU problems - Memory Issues: Try reducing batch sizes in example configurations
- Module Not Found: Ensure you're running from the workshop root directory
Getting Helpยค
- Check example docstrings for parameter explanations
- Review the main Workshop documentation
- Look at similar examples in the same category for reference patterns
- Check the imports at the top of each example for required dependencies
Note: Examples are continuously updated to demonstrate the latest Workshop features. The organized structure makes it easier to find relevant examples for your use case.