Conda Package Management
This guide explains how PyMomentum conda packages are managed and published to conda-forge.
Overview
PyMomentum is available on conda-forge, making it accessible through conda, mamba, pixi, and other conda-compatible package managers. The package is automatically built and published for multiple platforms (Linux, macOS, Windows) with support for both CPU and CUDA-accelerated variants.
Key Resources:
- Package Browser: prefix.dev/channels/conda-forge/packages/pymomentum
- Recipe Repository: conda-forge/momentum-feedstock
- Anaconda Repository: anaconda.org/conda-forge/momentum
How It Works
1. Release Process
When a new version is released:
- Git Tag: Repository maintainers manually create and push a tag matching
v*pattern (e.g.,v0.2.0) to the main repository- Tags are typically created weekly or more frequently when requested
- Automated PR: conda-forge's bot detects the new tag and creates a PR in the momentum-feedstock repository
- Build & Test: CI builds packages for all supported platforms and runs tests
- Merge: After approval, the PR is merged and packages are published to conda-forge
- Availability: Users can install via
conda install -c conda-forge pymomentumwithin hours
2. Feedstock Structure
The momentum-feedstock contains:
recipe/meta.yaml: Package metadata, dependencies, build configurationsrecipe/build.sh: Unix build script (Linux/macOS)recipe/bld.bat: Windows build script.ci_support/: Platform-specific build configurations (PyTorch, CUDA versions, etc.)- Auto-generated by conda-smithy when running
conda smithy rerenderlocally or commenting "@conda-forge-admin, please rerender" on PRs
- Auto-generated by conda-smithy when running
3. Version and Dependency Management
PyTorch and CUDA Pinning
conda-forge uses global pinning to ensure compatible versions across the ecosystem:
- PyTorch versions: Managed in conda-forge-pinning-feedstock
- CUDA versions: Also globally pinned to avoid "dependency islands"
- PyMomentum: Automatically builds against all pinned PyTorch/CUDA combinations
Example: If conda-forge supports PyTorch 2.8 with CUDA 12.9 and 12.6, momentum-feedstock automatically builds:
pymomentum-0.2.0-cuda129_py312_*(PyTorch 2.8 + CUDA 12.9 + Python 3.12)pymomentum-0.2.0-cuda126_py312_*(PyTorch 2.8 + CUDA 12.6 + Python 3.12)pymomentum-0.2.0-cpu_py312_*(PyTorch 2.8 CPU + Python 3.12)- ... and more combinations for different Python versions and platforms
Adding Support for Older Dependencies
If you need an older CUDA or PyTorch version not currently supported:
- Read conda-forge documentation on pinning and build matrices to understand how to configure version combinations
- Update
recipe/conda_build_config.yaml(if needed) to specify version constraints - Run rerender: The
.ci_support/files are automatically generated by conda-smithy - Submit PR to momentum-feedstock
- Example PR: Supporting CUDA 12.6
Since momentum-feedstock is open source, community contributions are welcome!
Updating the Feedstock
When to Update
You typically need to update the feedstock when:
- New release: Automated bot creates PR (usually no manual intervention needed)
- Build fixes: Fixing build failures on specific platforms
- Dependency updates: Adding support for new PyTorch/CUDA versions
- Platform support: Adding new OS or architecture support
Making Changes
- Fork the momentum-feedstock repository
- Update recipe: Modify
recipe/meta.yamlor build scripts - Test locally (optional but recommended):
# Install conda-build
conda install conda-build
# Build locally
conda build recipe/ - Create PR: Submit to momentum-feedstock
- CI Review: conda-forge CI automatically tests all platforms
- Merge: After approval, packages are published
Troubleshooting
Finding Package Details
Inspect installed files and metadata for any package version using conda-metadata-app.
Or locally:
# Show package info
conda info pymomentum
# List installed files
conda list pymomentum --show-channel-urls
Installing Specific Versions
# Install specific version
conda install -c conda-forge pymomentum=0.1.77
# Install specific version with CUDA constraint
conda install -c conda-forge "pymomentum=0.1.77=cuda129*"
# Install specific Python version
conda install -c conda-forge "pymomentum=0.1.77=*py312*"
Build Failures
If conda builds fail:
- Check CI logs in the feedstock PR
- Test locally with
conda build recipe/ - Check dependency availability: Ensure PyTorch/CUDA versions exist on conda-forge
- Review recent changes: Check if upstream momentum changes broke the build
Dependency Conflicts
If users report dependency conflicts:
- Verify pinning: Check conda-forge-pinning-feedstock
- Update constraints: Relax version constraints in
recipe/meta.yamlif too strict - Test resolution: Use
conda-treeorpixi treeto visualize dependency graphs
Alternative: Building from Source
If conda packages don't meet your requirements (e.g., custom PyTorch build, unreleased CUDA version), you can:
- Clone momentum:
git clone https://github.com/facebookresearch/momentum - Setup environment:
pixi installor create custom conda environment - Build:
pip install .(see Getting Started)
This gives you full control over dependency versions at the cost of manual maintenance.
Contributing
We welcome contributions to improve conda packaging! Areas where help is appreciated:
- Platform support: Adding ARM64 Linux, new OS versions
- Dependency backports: Supporting older PyTorch/CUDA for legacy systems
- Build optimizations: Reducing package size, improving build times
- Documentation: Clarifying build procedures, troubleshooting guides
Submit PRs to momentum-feedstock or open issues for discussion.