-
Notifications
You must be signed in to change notification settings - Fork 298
fix(install): support aarch64 hosts with any compute capability #2587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
andre-fu
wants to merge
3
commits into
PrimeIntellect-ai:main
Choose a base branch
from
andre-fu:fix/aarch64-flash-attn-install
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+56
−10
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,44 @@ | ||
| #!/bin/bash | ||
| # arm64 post-install fixups for Docker builds. | ||
| set -e | ||
| # arm64 post-install fixups: rebuild flash-attn from source for the target GPU. | ||
| # | ||
| # Why this exists: pyproject.toml sets FLASH_ATTENTION_SKIP_CUDA_BUILD=TRUE to keep | ||
| # `uv sync` fast; on x86_64 it pins a prebuilt wheel to fill in the binary, but no | ||
| # such wheel exists for aarch64. Without this script, `import flash_attn` fails on | ||
| # aarch64 with `ModuleNotFoundError: No module named 'flash_attn_2_cuda'`. | ||
| # | ||
| # Defaults preserve the existing Docker behavior (sm_100 / GB200). On a host with | ||
| # `nvidia-smi` available, the compute capability is auto-detected from the local | ||
| # GPU. Override via env vars if needed: | ||
| # TORCH_CUDA_ARCH_LIST e.g. 9.0 (Hopper), 10.0 (Blackwell) | ||
| # VENV_PATH path to the venv (default: $(pwd)/.venv) | ||
| # MAX_JOBS parallel nvcc jobs (default: 4) | ||
| set -euo pipefail | ||
|
|
||
| echo "=== building flash-attn from source (sm_100 / GB200) ===" | ||
| # Run from /tmp so uv doesn't read pyproject.toml's [tool.uv.extra-build-variables] | ||
| # which sets FLASH_ATTENTION_SKIP_CUDA_BUILD=TRUE and prevents CUDA kernel compilation. | ||
| export TORCH_CUDA_ARCH_LIST="10.0" | ||
| export MAX_JOBS=4 | ||
| if [ -z "${TORCH_CUDA_ARCH_LIST:-}" ]; then | ||
| # Try to detect from the local GPU. Tolerate any failure mode (binary missing, | ||
| # driver not loaded, Docker buildx without --gpus) and fall back to GB200. | ||
| TORCH_CUDA_ARCH_LIST="$(nvidia-smi --query-gpu=compute_cap --format=csv,noheader 2>/dev/null | head -1 | tr -d ' ' || true)" | ||
| : "${TORCH_CUDA_ARCH_LIST:=10.0}" | ||
| fi | ||
| export TORCH_CUDA_ARCH_LIST | ||
|
|
||
| VENV_PATH="${VENV_PATH:-$(pwd)/.venv}" | ||
| if [ ! -x "$VENV_PATH/bin/python" ]; then | ||
| echo "ERROR: no python at $VENV_PATH/bin/python. Run from the project root or set VENV_PATH." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| export MAX_JOBS="${MAX_JOBS:-4}" | ||
| export FLASH_ATTENTION_FORCE_BUILD=TRUE | ||
| export FLASH_ATTENTION_SKIP_CUDA_BUILD=FALSE | ||
| (cd /tmp && uv pip install --python /app/.venv/bin/python \ | ||
| "flash-attn==2.8.3" --no-build-isolation --no-binary flash-attn --no-cache) | ||
|
|
||
| echo "=== building flash-attn from source (TORCH_CUDA_ARCH_LIST=$TORCH_CUDA_ARCH_LIST, MAX_JOBS=$MAX_JOBS) ===" | ||
| echo " target venv: $VENV_PATH" | ||
| # Run from /tmp so uv ignores the project's [tool.uv.extra-build-variables], | ||
| # which sets FLASH_ATTENTION_SKIP_CUDA_BUILD=TRUE and would prevent kernel compilation. | ||
| (cd /tmp && uv pip install --python "$VENV_PATH/bin/python" \ | ||
| "flash-attn==2.8.3" --no-build-isolation --no-binary flash-attn --no-cache --reinstall-package flash-attn) | ||
|
|
||
| echo "=== reinstalling flash-attn-cute (flash-attn overwrites it with a stub) ===" | ||
| uv pip install --reinstall --no-deps \ | ||
| uv pip install --python "$VENV_PATH/bin/python" --reinstall --no-deps \ | ||
| "flash-attn-4 @ git+https://github.com/Dao-AILab/flash-attention.git@96bd151#subdirectory=flash_attn/cute" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.