Implementation:Axolotl ai cloud Axolotl Setup Script
| Knowledge Sources | |
|---|---|
| Domains | Build_System, Packaging |
| Last Updated | 2026-02-07 00:00 GMT |
Overview
Legacy setuptools script that dynamically resolves Axolotl dependencies based on the detected PyTorch version and platform, managing compatibility across torch 2.4-2.9+ with appropriate xformers and vllm versions.
Description
The setup.py implements Axolotl's complex dependency resolution logic in the parse_requirements function. It reads requirements.txt, detects the installed PyTorch version, and dynamically selects compatible versions of xformers, vllm, fbgemm-gpu, and other CUDA-dependent packages. The resolution matrix covers PyTorch versions from 2.4 through 2.9+ with specific version pins for each minor/patch combination. On macOS, it strips incompatible packages (bitsandbytes, triton, mamba-ssm, xformers, liger-kernel). The extras_require map defines optional dependency groups: flash-attn, ring-flash-attn, deepspeed, mamba-ssm, auto-gptq, mlflow, galore, apollo, optimizers, ray, vllm, llmcompressor, fbgemm-gpu, and opentelemetry. The get_package_version function reads the version from the VERSION file.
Usage
This script is called by pip/setuptools during package installation. It works alongside pyproject.toml to handle the dynamic dependency resolution that cannot be expressed in static TOML configuration. It should be maintained when new PyTorch versions are released to ensure correct dependency pins.
Code Reference
Source Location
Signature
def parse_requirements(extras_require_map: dict) -> tuple[list, list, dict]:
"""Parse requirements.txt and resolve version-specific dependencies.
Args:
extras_require_map: Mutable dict of optional dependency groups.
Returns:
Tuple of (install_requires, dependency_links, extras_require).
"""
def get_package_version() -> str:
"""Read package version from VERSION file."""
# Module-level execution:
extras_require = { "flash-attn": [...], "deepspeed": [...], ... }
install_requires, dependency_links, extras_require_build = parse_requirements(extras_require)
setup(
version=get_package_version(),
package_dir={"": "src"},
packages=find_packages("src"),
install_requires=install_requires,
extras_require=extras_require_build,
)
Import
# Not imported directly. Executed by pip:
pip install -e .
# Or:
python setup.py develop
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| requirements.txt | File | Yes | Base package requirements |
| VERSION | File | Yes | Package version string |
| Installed torch version | Runtime detection | No | Auto-detected; falls back to 2.8.0 |
| Platform | Runtime detection | No | macOS detection for skipping incompatible packages |
Outputs
| Name | Type | Description |
|---|---|---|
| install_requires | list[str] | Resolved core dependencies with version pins |
| dependency_links | list[str] | PyPI index URLs for CUDA wheels |
| extras_require | dict[str, list] | Optional dependency groups with version-resolved pins |
Usage Examples
Standard Installation
# Install with PyTorch auto-detection
pip install -e .
# Install with specific extras
pip install -e ".[flash-attn,deepspeed]"
# Install with vllm support (requires compatible torch)
pip install -e ".[vllm]"