Repository navigation
AF3: --fast_kernels with fused triangle kernels; AlphaFold 3 v3.0.4 - #646
Merged
Merged
Conversation
Move the submodule to KosinskiLab/alphafold3 73f260e (branch
exp/af3-fused-triangle), where the fused triangle kernels moved under
alphafold3/jax/fused_triangle and the config fields are named like
flash_attention_implementation:
fused_triangle_multiplication=True -> triangle_multiplication_implementation='pallas'
fused_triangle_attention='auto' -> triangle_attention_implementation='auto'
network.fused_triangle.fpf_pallas_serve.card_policy/select
-> jax.fused_triangle.dispatch.device_policy/select_implementation
The per-device choices are unchanged. Dispatch now names the original
body 'default' (was 'stock', reason 'not_requested' instead of 'off'),
so the per-seed record keys its operations triangle_multiplication_cN /
triangle_attention_cN with an 'implementation' field. The fork no longer
exposes the kit's source commit; its SOURCE.md records it, and the
record keeps the dispatch policy version.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the AlphaFold 3 decision out of prediction/fast_kernels.py into
prediction/af3_fused_triangles.py, so fast_kernels.py is AF2-only again,
byte-identical to main, and its resolve(mode) API is unchanged. The new
module reuses fast_kernels.normalise_mode and exposes:
resolve(mode, device) -> FusedTriangleChoice (enabled, reason, mode,
settings; global_config_update())
OFF the choice for --fast_kernels=off
device_settings(device) GlobalConfig fields for the device (was _af3_settings)
smoke_test(settings) (was _af3_smoke_test)
metadata(global_config, choice, *, num_tokens) (was af3_metadata)
ModelRunner keeps the resolved FusedTriangleChoice (fused_triangles)
instead of a re-normalised mode string and a reason. Decisions, the
GlobalConfig fields set and the record's fields are unchanged.
The AF3 tests move from test_fast_kernels.py (back to main's) to
test_af3_fused_triangles.py, and the backend's own checks are separate
tests instead of additions to the MSA and setup tests. The light-import
test covers the new module: the AF3 backend imports it, and it imports
neither JAX nor the fork until a kernel mode is resolved.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
smoke_test compiled and ran the two fused triangle layers on JAX's default device, while device_settings had read the limits of the device the model runs on. It now takes that device and runs inside jax.default_device(device), so the check and the model see the same GPU. An --fast_kernels=auto fallback now records its reason as "--fast_kernels=auto: ...", like AlphaFold 2's, instead of the bare problem, so inference_kernels.json says which mode fell back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The per-seed inference_kernels.json update was inline in the seed loop: a corrupt existing file, or a fork without the dispatch module, raised out of predict_structure after the model had run, and its time was counted in "Model inference for seed N took". It is now _record_inference_kernels, mirroring AlphaFold 2's: it runs after structure extraction, replaces an unreadable file with a warning, and logs and skips any other failure. Entries are keyed seed-N, AF3's own spelling in output names, instead of seed_N. make_model_config read the fused-triangle decision from the enclosing scope, assigned only later in setup(); the GlobalConfig update is now passed in explicitly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
--fast_kernels was listed twice, as AF2_EXTRA_FLAGS and inside AF3_FLAGS, under a comment that still said AlphaFold 2 only. Both backends now take it from one FAST_KERNEL_FLAGS set, whose comment says which kernels each backend uses and why AlphaLink has none. The flags each backend accepts are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ents Rewrite docs/af3_fused_triangles.md in sections like docs/mmseqs2_rna.md: turning the kernels on, what runs on which GPU, memory limits, how they were measured, the output record, troubleshooting, and source and licence. Define the terms the old text assumed (Pallas, the attention core, Anthropic's Pallas flash-attention core vs tokamax's), drop "this branch", and state the measurement: Gate 0 and the full-model campaign on A100, A40, RTX 3090, L40S, H100 and RTX Pro 6000 Blackwell with JAX 0.9.1 / tokamax 0.0.11; Pallas attention on compute capability 8.0/9.0/12.0, the tokamax core on 8.6/8.9, multiplication on all of them, nothing on 10.0 (B200) or newer. The record section follows the renamed fields and seed-N keys. Troubleshooting says that scripts importing the AF3 backend should call jax.devices() first. Link the page from the README's AlphaFold3 flags, and move the link in backend_installation.md from the top into the AlphaFold3 backend notes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The submodule points at KosinskiLab/alphafold3 exp/af3-fused-triangle-v3.0.4 (ab98e22): upstream v3.0.4 merged into the fork without conflicts (de1577e), with the fused-triangle commits replayed on top. The fork's fused-triangle test passes 90/90 on it, on jax 0.9.1 and on jax 0.10.2 / tokamax 0.0.12 (CPU, Pallas interpret mode), and make_model_config() matches the golden model_config.json. v3.0.4 moves AF3 to jax 0.10.2 and tokamax 0.0.12, so the alphafold3 extra, the image's version stamp and the README follow. The image installs AF3 from the submodule's uv.lock, which v3.0.4 already updates. Experimental: needs a rebuilt AF3 image and the GPU campaign rerun on it before any PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
run_multimer_jobs takes its flags from run_structure_prediction but built its own argument list and never passed --fast_kernels on, for either backend, and dropped --jax_compilation_cache_dir on the AlphaFold 2 path. Both are now forwarded to AlphaFold 2 and AlphaFold 3. AlphaLink and UniFold reject them, so they stay out of those commands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Merged
1 task done
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
--fast_kernels off|on|autonow covers the AlphaFold 3 backend. It switches on the fork's opt-in fused triangle kernels (KosinskiLab/alphafold3#4). The default staysoff, which runs exactly the previous code. AlphaFold 2's behaviour and API are unchanged.alphapulldown/prediction/af3_fused_triangles.py:resolve(mode, device)checks the GPU before any weights load: an NVIDIA card with compute capability ≥ 8.0, a known tile table and memory budget, and a smoke compile-and-run of both fused blocks on that GPU.onraises an error with the missing requirement;autofalls back with a log line.fast_kernels.py(AF2) is byte-identical tomain; the two backends share onlynormalise_mode.inference_kernels.json, keyedseed-N. It records the requested mode, what each operation ran and the reason. Writing it never fails a finished prediction.FAST_KERNEL_FLAGSis shared by AF2 and AF3; AlphaLink still rejects the flag.docs/af3_fused_triangles.md, linked from the README and the AF3 installation section.main, which now carries upstream v3.0.4 (Update fork to AlphaFold 3 v3.0.4 alphafold3#3) and the fused kernels (Opt-in fused triangle kernels (Pallas) for inference alphafold3#4). Thealphafold3extra pins jax 0.10.2 / tokamax 0.0.12, matching the submodule'suv.lock, which the image installs. The Dockerfile version stamp and README follow.Bug fix, separate commit:
run_multimer_jobs.pynever forwarded--fast_kernels. It takes its flags fromrun_structure_prediction, but builds its own argument list, which never passed--fast_kernelson for either backend and dropped--jax_compilation_cache_dirfor AlphaFold 2. Both are now forwarded to AF2 and AF3; AlphaLink and UniFold still reject them.Validation
Unit suite (serial): 726 passed, 10 skipped. That includes the new
test_af3_fused_triangles.pyand the metadata-helper tests, one of them with a corrupt existing file. The AF2fast_kernelstests are unchanged.AF3 image, CPU smoke:
device_settingsper card;smoke_testfor both attention variants in Pallas interpret mode;resolvefallback and failure;metadataagainst the real GlobalConfig; importing the backend.GPU campaign (AF3 image, DeepMind weights; every job its own SLURM job). Warm speed-up, fused vs stock on the same card:
--fast_kernels=offis bit-identical to the previous fork on all 6 cards (deterministic XLA);onis deterministic.Before any release: the GPU campaign is re-run on the AF3 image that CI builds from this branch (jax 0.10.2). The numbers above were measured on jax 0.9.1, and so far the v3.0.4 stack has been tested on CPU only: the fork's 90 fused tests, the golden config, and this unit suite.
Companion PR: the workflow accepts the flag for AF3 (KosinskiLab/AlphaPulldownSnakemake#SMPR).
🤖 Generated with Claude Code