Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/github_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ jobs:
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
submodules: recursive
- run: rm -rf /opt/hostedtoolcache
- uses: docker/login-action@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
[submodule "alphafold3"]
path = alphafold3
url = https://github.com/KosinskiLab/alphafold3.git
branch = main
branch = ap-gapped-discontinuous-chains-v3.0.2
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,11 @@ you hit these.
- **Restrict to one model** with `structure_inference_gpu_model` (e.g. `"A100"`) → the plugin emits
`--gpus=<model>:<count>`. Accepts a single model name; leave `""` for any.
- **Exclude specific nodes** with `slurm_exclude_nodes` → passed verbatim to `sbatch --exclude`
(e.g. `"gpu50,gpu51"`). Use it for nodes whose GPU the container can't use — e.g. a CUDA compute
capability newer than the container's bundled `ptxas` (fails `ptxas too old` / `UNIMPLEMENTED`).
(e.g. `"gpu50,gpu51"`). Use it as a fallback for nodes whose GPU the container can't use — e.g.
a CUDA compute capability newer than the container's bundled `ptxas` (fails `ptxas too old` /
`UNIMPLEMENTED`). RTX PRO 6000 / Blackwell failures with old AlphaFold 3 images are fixed by
updating to AF3 v3.0.2/Tokamax; excluding those nodes is only an old-image workaround, not the
compatibility proof.
`--exclude` is allowed in `slurm_extra` whereas `--constraint`/`--gres`/`--gpus` are not, so it is
the supported way to drop a few nodes while keeping the rest of the partition.
- **`structure_inference_max_runtime`** caps per-job wall time (minutes). Wall time scales as
Expand Down
2 changes: 1 addition & 1 deletion alphafold3
Submodule alphafold3 updated 71 files
+20 −14 .github/workflows/ci.yaml
+5 −0 CMakeLists.txt
+36 −0 CONTRIBUTING.md
+1 −4 README.md
+0 −538 dev-requirements.txt
+29 −21 docker/Dockerfile
+31 −0 docs/community_tools.md
+8 −0 docs/installation.md
+47 −0 docs/known_issues.md
+439 −0 docs/model_parameters.md
+9 −9 docs/performance.md
+3 −1 fetch_databases.sh
+19 −14 pyproject.toml
+0 −538 requirements.txt
+24 −3 run_alphafold.py
+1 −1 run_alphafold_test.py
+15 −6 src/alphafold3/build_data.py
+1 −1 src/alphafold3/constants/chemical_components.py
+1 −1 src/alphafold3/constants/converters/ccd_pickle_gen.py
+9 −11 src/alphafold3/data/cpp/msa_profile_pybind.h
+0 −66 src/alphafold3/data/msa_store.py
+0 −46 src/alphafold3/data/template_store.py
+6 −4 src/alphafold3/data/tools/jackhmmer.py
+0 −139 src/alphafold3/jax/attention/attention.py
+0 −363 src/alphafold3/jax/attention/attention_base.py
+0 −62 src/alphafold3/jax/attention/attention_call_arg_specs.py
+0 −703 src/alphafold3/jax/attention/flash_attention.py
+0 −140 src/alphafold3/jax/attention/xla_attention.py
+0 −405 src/alphafold3/jax/common/array_view.py
+0 −92 src/alphafold3/jax/common/precision.py
+0 −125 src/alphafold3/jax/common/triton_utils.py
+0 −126 src/alphafold3/jax/gated_linear_unit/block.py
+0 −124 src/alphafold3/jax/gated_linear_unit/gated_linear_unit.py
+0 −130 src/alphafold3/jax/gated_linear_unit/gated_linear_unit_base.py
+0 −78 src/alphafold3/jax/gated_linear_unit/matmul_config.py
+0 −273 src/alphafold3/jax/gated_linear_unit/matmul_ext.py
+0 −75 src/alphafold3/jax/geometry/utils.py
+21 −17 src/alphafold3/model/features.py
+18 −16 src/alphafold3/model/mkdssp_pybind.cc
+9 −11 src/alphafold3/model/mkdssp_pybind.h
+8 −6 src/alphafold3/model/model.py
+6 −3 src/alphafold3/model/model_config.py
+1 −1 src/alphafold3/model/msa_pairing.py
+2 −4 src/alphafold3/model/network/diffusion_transformer.py
+6 −10 src/alphafold3/model/network/modules.py
+3 −1 src/alphafold3/model/params.py
+48 −17 src/alphafold3/model/pipeline/pipeline.py
+19 −7 src/alphafold3/model/post_processing.py
+1 −0 src/alphafold3/parsers/cpp/cif_dict.pyi
+9 −11 src/alphafold3/parsers/cpp/cif_dict_lib.h
+20 −8 src/alphafold3/parsers/cpp/cif_dict_pybind.cc
+9 −11 src/alphafold3/parsers/cpp/cif_dict_pybind.h
+9 −11 src/alphafold3/parsers/cpp/fasta_iterator_lib.h
+9 −11 src/alphafold3/parsers/cpp/fasta_iterator_pybind.h
+9 −11 src/alphafold3/parsers/cpp/msa_conversion_pybind.h
+34 −34 src/alphafold3/structure/bonds.py
+9 −11 src/alphafold3/structure/cpp/aggregation_pybind.h
+9 −11 src/alphafold3/structure/cpp/membership_pybind.h
+9 −11 src/alphafold3/structure/cpp/mmcif_altlocs.h
+9 −11 src/alphafold3/structure/cpp/mmcif_atom_site_pybind.h
+9 −11 src/alphafold3/structure/cpp/mmcif_layout.h
+9 −11 src/alphafold3/structure/cpp/mmcif_layout_pybind.h
+9 −11 src/alphafold3/structure/cpp/mmcif_struct_conn.h
+9 −11 src/alphafold3/structure/cpp/mmcif_struct_conn_pybind.h
+9 −11 src/alphafold3/structure/cpp/mmcif_utils_pybind.h
+9 −11 src/alphafold3/structure/cpp/string_array_pybind.h
+19 −18 src/alphafold3/structure/structure.py
+1 −1 src/alphafold3/structure/structure_tables.py
+1 −1 src/alphafold3/structure/table.py
+1 −1 src/alphafold3/version.py
+1,050 −0 uv.lock
11 changes: 6 additions & 5 deletions alphapulldown/folding_backend/alphafold3_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
import haiku as hk
import jax
import numpy as np
import tokamax
from alphafold3.common import base_config
from alphafold3.common import folding_input
from alphafold3.constants import chemical_components
from alphafold3.data import featurisation
from alphafold3.data import parsers as af3_parsers
from alphafold3.jax.attention import attention
from alphafold3.model import features, params, post_processing
from alphafold3.model import model
from alphafold3.model.components import utils
Expand Down Expand Up @@ -145,8 +145,8 @@ def run_inference(
self.device,
)
result = self._model(rng_key, featurised_example)
result = jax.tree_map(np.asarray, result)
result = jax.tree_map(
result = jax.tree_util.tree_map(np.asarray, result)
result = jax.tree_util.tree_map(
lambda x: x.astype(jnp.float32) if x.dtype == jnp.bfloat16 else x,
result,
)
Expand Down Expand Up @@ -742,7 +742,7 @@ def setup(
def make_model_config(
*,
model_class: type[ModelT] = MyNewModel,
flash_attention_implementation: attention.Implementation,
flash_attention_implementation: tokamax.DotProductAttentionImplementation,
num_diffusion_samples: int = 5,
num_recycles: int = 10,
return_embeddings: bool = False,
Expand Down Expand Up @@ -787,7 +787,8 @@ def make_model_config(
model_class=MyNewModel,
config=make_model_config(
flash_attention_implementation=typing.cast(
attention.Implementation, flash_attention_implementation
tokamax.DotProductAttentionImplementation,
flash_attention_implementation,
),
num_diffusion_samples=num_diffusion_samples,
num_recycles=num_recycles,
Expand Down
56 changes: 21 additions & 35 deletions docker/alphafold3.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ FROM nvidia/cuda:12.6.3-base-ubuntu24.04

ENV DEBIAN_FRONTEND=noninteractive
ENV VIRTUAL_ENV=/opt/venv
ENV UV_PROJECT_ENVIRONMENT=${VIRTUAL_ENV}
ENV UV_COMPILE_BYTECODE=1
ENV UV_LINK_MODE=copy
ENV PATH="/hmmer/bin:${VIRTUAL_ENV}/bin:${PATH}"
ENV PIP_DISABLE_PIP_VERSION_CHECK=1

Expand All @@ -10,9 +13,9 @@ ENV PIP_DISABLE_PIP_VERSION_CHECK=1
# ---------------------------------------------------------------------
RUN apt-get update && \
apt-get install -y --no-install-recommends \
python3 \
python3-venv \
python3-dev \
python3.12 \
python3.12-venv \
python3.12-dev \
gcc-12 g++-12 \
build-essential \
libc6-dev \
Expand All @@ -25,18 +28,18 @@ RUN apt-get update && \
make \
pkg-config \
zlib1g-dev \
zstd \
&& rm -rf /var/lib/apt/lists/*

# Force gcc-12 (avoid gcc-13 ICE on 24.04)
ENV CC=gcc-12
ENV CXX=g++-12

# ---------------------------------------------------------------------
# Python venv (PIN pip so pip-tools works)
# Python venv and package installer
# ---------------------------------------------------------------------
RUN python3 -m venv ${VIRTUAL_ENV} && \
pip install --no-cache-dir --upgrade "pip<25.3" setuptools wheel && \
pip install --no-cache-dir "pip-tools==7.5.2"
COPY --from=ghcr.io/astral-sh/uv:0.9.24 /uv /uvx /bin/
RUN uv venv ${VIRTUAL_ENV}

# ---------------------------------------------------------------------
# HMMER (with seq_limit patch)
Expand All @@ -46,8 +49,7 @@ RUN mkdir /hmmer_build /hmmer && \
echo "ca70d94fd0cf271bd7063423aabb116d42de533117343a9b27a65c17ff06fbf3 /hmmer_build/hmmer-3.4.tar.gz" | sha256sum -c - && \
tar -xzf /hmmer_build/hmmer-3.4.tar.gz -C /hmmer_build

RUN wget -O /hmmer_build/jackhmmer_seq_limit.patch \
https://raw.githubusercontent.com/google-deepmind/alphafold3/main/docker/jackhmmer_seq_limit.patch
COPY alphafold3/docker/jackhmmer_seq_limit.patch /hmmer_build/

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Check out submodules before copying AlphaFold3 files

In the build-alphafold3-container workflow I checked, the checkout step at .github/workflows/github_actions.yml:228 does not request submodules, while this Dockerfile now copies alphafold3/docker/jackhmmer_seq_limit.patch from the build context instead of downloading it/cloning with --recurse-submodules. On push/release builds that use that workflow, the alphafold3 gitlink is not populated, so BuildKit cannot find this source path and the container build stops before installing AF3; either the workflow needs submodules: recursive or the Dockerfile must not depend on checked-out submodule contents.

Useful? React with 👍 / 👎.


RUN cd /hmmer_build && \
patch -p0 < jackhmmer_seq_limit.patch && \
Expand All @@ -59,56 +61,41 @@ RUN cd /hmmer_build && \
rm -rf /hmmer_build

# ---------------------------------------------------------------------
# Clone AlphaPulldown with submodules
# Copy AlphaPulldown with its checked-out submodules. Building from the local
# checkout is important for PR/SIF validation: it exercises this branch's
# alphafold3 submodule pointer instead of cloning the repository default branch.
# ---------------------------------------------------------------------
RUN git clone --recurse-submodules https://github.com/KosinskiLab/AlphaPulldown.git /app/AlphaPulldown
COPY . /app/AlphaPulldown

# ---------------------------------------------------------------------
# Install AlphaFold3 (regenerate dev-requirements inside image)
# Install AlphaFold3 from its locked v3.0.2/Tokamax environment
# ---------------------------------------------------------------------
WORKDIR /app/AlphaPulldown/alphafold3

# force real PyPI, not a mirror
ARG PIP_INDEX_URL=https://pypi.org/simple
ENV PIP_INDEX_URL=${PIP_INDEX_URL} \
PIP_DEFAULT_TIMEOUT=600 \
PIP_RETRIES=10 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1

ENV PIP_CACHE_DIR=/tmp/pip-cache
ENV CMAKE_BUILD_PARALLEL_LEVEL=1
ENV CFLAGS="-O2 -pipe"
ENV CXXFLAGS="-O2 -pipe"
RUN apt-get update && apt-get install -y clang lld
ENV CC=clang
ENV CXX=clang++
ENV CMAKE_BUILD_PARALLEL_LEVEL=2


RUN rm -rf "$PIP_CACHE_DIR" && mkdir -p "$PIP_CACHE_DIR" && \
pip-compile \
--no-reuse-hashes \
--extra=dev \
--generate-hashes \
--resolver=backtracking \
--output-file=dev-requirements.txt \
pyproject.toml && \
pip install --require-hashes -r dev-requirements.txt && \
pip install git+https://github.com/openmm/pdbfixer.git && \
pip install --no-deps . && \
rm -rf "$PIP_CACHE_DIR"

RUN uv sync --frozen --all-groups --no-editable && \
uv pip install --no-cache git+https://github.com/openmm/pdbfixer.git

# ---------------------------------------------------------------------
# Build CCD database
# ---------------------------------------------------------------------
RUN build_data
RUN uv run --no-sync build_data

# ---------------------------------------------------------------------
# Install AlphaPulldown
# ---------------------------------------------------------------------
WORKDIR /app/AlphaPulldown
RUN pip install --no-cache-dir .
RUN uv pip install --no-cache .

# ---------------------------------------------------------------------
# Runtime env
Expand All @@ -128,4 +115,3 @@ from alphafold3.constants import chemical_components
from alphapulldown.folding_backend.folding_backend import FoldingBackend
print("AF3 + AlphaPulldown import OK, CCD present")
EOF

17 changes: 7 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ dependencies = [
"jupyterlab>=3.0",
"ipywidgets",
"ml-dtypes",
"chex>=0.1.86",
"immutabledict>=2.0.0",
"typing-extensions==4.14.0",
"typing-extensions>=4.15.0",
]

[project.optional-dependencies]
Expand All @@ -53,17 +52,15 @@ alphafold2 = [
"pdbfixer>=1.10",
]
alphafold3 = [
"jaxtyping==0.2.34",
"jax==0.5.3",
"jax[cuda12]==0.5.3; platform_system == 'Linux' and platform_machine == 'x86_64'",
"jax-triton==0.2.0; platform_system == 'Linux' and platform_machine == 'x86_64'",
"dm-haiku==0.0.16",
"jax==0.9.1",
"jax[cuda12]==0.9.1; platform_system == 'Linux' and platform_machine == 'x86_64'",
"modelcif>=1.6",
"numpy<2",
"numpy",
"openmm>=8.2",
"pdbfixer>=1.10",
"rdkit==2024.3.5",
"triton==3.1.0; platform_system == 'Linux' and platform_machine == 'x86_64'",
"typeguard==2.13.3",
"rdkit==2025.9.4",
"tokamax==0.0.11",
"zstandard",
]
test = [
Expand Down
5 changes: 5 additions & 0 deletions test/unit/test_alphafold3_backend_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ def _transform(fn):
haiku.transform = _transform
sys.modules["haiku"] = haiku

if "tokamax" not in sys.modules:
tokamax = types.ModuleType("tokamax")
tokamax.DotProductAttentionImplementation = str
sys.modules["tokamax"] = tokamax

terms_dir = tmp_path / "af3cpp"
terms_dir.mkdir(parents=True, exist_ok=True)
(terms_dir / "OUTPUT_TERMS_OF_USE.md").write_text("stub terms", encoding="utf-8")
Expand Down
Loading