Installation
This guide covers installing HETorch and its dependencies.
Prerequisites
Required
- Python: 3.9 or higher
- PyTorch: 2.0 or higher
- Operating System: Linux, macOS, or Windows
Optional
- uv: Fast Python package installer (recommended)
- graphviz: For graph visualization (optional)
Installation Methods
Method 1: Using uv (Recommended)
uv is a fast Python package installer and resolver.
# Install uv if you don't have it
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone the repository
git clone https://github.com/visualDust/HETorch
cd hetorch
# Install HETorch
uv pip install -e .
# Install with development dependencies
uv pip install -e ".[dev]"
Method 2: Using pip
# Clone the repository
git clone https://github.com/visualDust/HETorch
cd hetorch
# Install HETorch
pip install -e .
# Install with development dependencies
pip install -e ".[dev]"
Method 3: From Source (Development)
# Clone the repository
git clone https://github.com/visualDust/HETorch
cd hetorch
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install in editable mode
pip install -e ".[dev]"
Optional Dependencies
Graphviz (For Visualization)
The GraphVisualizationPass requires graphviz for rendering computation graphs.
Ubuntu/Debian:
sudo apt-get install graphviz
macOS:
brew install graphviz
Windows: Download from graphviz.org
Python package:
pip install graphviz
Development Tools
For contributing to HETorch:
# Install development dependencies
pip install -e ".[dev]"
# This includes:
# - pytest: Testing framework
# - black: Code formatter
# - ruff: Linter
# - mypy: Type checker
Verifying Installation
Basic Verification
import hetorch
print(hetorch.__version__)
Run Tests
# Run all tests
pytest tests/
# Run specific test file
pytest tests/test_compiler.py -v
# Run with coverage
pytest tests/ --cov=hetorch --cov-report=html
Run Examples
# Run basic example
python examples/basic_linear.py
# Run neural network example
python examples/phase2_neural_network.py
Expected output:
Original model output: tensor([...])
Compiled model output: tensor([...])
Max difference: 0.0001
Troubleshooting
PyTorch Not Found
If you get ModuleNotFoundError: No module named 'torch':
# Install PyTorch
pip install torch
# Or with CUDA support
pip install torch --index-url https://download.pytorch.org/whl/cu118
Import Errors
If you get import errors after installation:
# Reinstall in editable mode
pip install -e .
# Or force reinstall
pip install --force-reinstall -e .
Test Failures
If tests fail:
-
Ensure all dependencies are installed:
pip install -e ".[dev]" -
Check Python version:
python --version # Should be 3.9+ -
Clear cache and reinstall:
rm -rf build/ dist/ *.egg-info
pip install -e .
Graphviz Issues
If GraphVisualizationPass fails:
- Install system graphviz (see above)
- Install Python package:
pip install graphviz - Verify installation:
dot -V # Should print graphviz version
Development Setup
For contributing to HETorch:
# Clone repository
git clone https://github.com/visualDust/HETorch
cd hetorch
# Create virtual environment
python -m venv .venv
source .venv/bin/activate
# Install with development dependencies
pip install -e ".[dev]"
# Install pre-commit hooks (optional)
pre-commit install
# Run tests
pytest tests/
# Format code
black hetorch/ tests/ examples/
# Lint code
ruff check hetorch/ tests/ examples/
# Type check
mypy hetorch/
Uninstallation
pip uninstall hetorch
Next Steps
- Quickstart: Compile your first model in 5 minutes
- Basic Concepts: Understand core abstractions
- Compilation Workflow: Learn the compilation process