Repository navigation
--fast_kernels: ColabFold's fused kernels for AF2-Multimer (~2x); fix padded AF2 scores - #645
Merged
Merged
Conversation
… kernels) --fast_kernels off|on|auto (AF2 only, default off) switches on the fused kernels of the colabfold-kernels package through the alphafold fork's new hooks (alphafold.model.fused_kernels): flash attention, fused LayerNorm and triangle multiplication's fused projection. About 2x faster AF2-Multimer on NVIDIA GPUs of compute capability 8.0+. alphapulldown/prediction/fast_kernels.py checks every requirement before a model is built, so other clusters get a clear answer instead of a failure mid-prediction: the package, the fork hooks, an NVIDIA GPU of cc >= 8.0, and one small kernel actually compiled and run. "on" raises with the missing requirement; "auto" falls back to the stock code with a log line. Only multimer configs are touched (monomers run fp32, the kernels are bf16). Each prediction directory gets inference_kernels.json, read back from the runner's own config, so fast and stock results can be told apart. pyproject gains the fast-kernels extra; the AF2 image installs the package. The alphafold submodule points at the fork branch exp/af2-fused-kernels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PyYAML reads an unquoted on/off in the Snakemake config as a boolean, which reaches the command line as True/False. The flag is now a string normalised by fast_kernels.normalise_mode; anything else still fails at backend setup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mers keep stock code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With --desired_num_res (and so in every AlphaPulldownSnakemake AF2-multimer batch with batch_size > 1, which pads each fold to the batch's largest), pLDDT, PAE, pTM, ipTM and the ranking confidence were computed over the padded length. A 599-residue dimer padded to 700 reported ipTM = pTM = 0.9993 instead of 0.927 / 0.940, mean pLDDT 86.9 instead of 95.7, and kept a 700x700 PAE in its pickle and JSON. The structures were unaffected. recalculate_confidence only trimmed when the PAE head's raw logits were present; AlphaFold's RunModel replaces them with the computed PAE array, so it returned early every time. It now also handles that case: pTM and ipTM are recomputed from aligned_confidence_probs over the real residues with AlphaFold's own predicted_tm_score (softmax(log p) = p, bin edges rebuilt from the bin count and max_predicted_aligned_error), chain IDs come from the unpadded features, and pLDDT, PAE and the probabilities are trimmed. Unpadded predictions are left unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 task done
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Merged
5 tasks done
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ad317b4 merges a20e833, which this branch pointed at; the tree is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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|auto(AlphaFold 2 only, defaultoff): about 2× faster AlphaFold-Multimer inference on NVIDIA GPUs of compute capability 8.0+. It uses ColabFold's maintained fused Pallas kernels (colabfold-kernels, MIT) through the new hooks in the alphafold fork (KosinskiLab/alphafold#13).alphapulldown/prediction/fast_kernels.py). AlphaPulldown runs on many clusters, so the check covers:onraises with the missing requirement;autofalls back to the standard code with a log line.inference_kernels.json(fused_kernels,compute_capability), read back from each runner's own config, so fast and stock results can be told apart in ranking and analysis.pip install "alphapulldown[fast-kernels]"; the AF2 image installs the package.--no-depsworks where that's a problem.true/falseare read ason/off. PyYAML turns a bareonin the Snakemake config into a boolean.alphafoldis at the merged fork,ad317b4(Optional fused Pallas kernels from colabfold-kernels (off by default) alphafold#13). Its tree is identical to the testeda20e833.Bug fix, separate commit
4519a56a: padded AF2 predictions reported scores over the padding.--desired_num_res, pLDDT, PAE, pTM, ipTM and the ranking confidence were computed over the padded length. A 599-residue dimer padded to 700 reported ipTM = pTM = 0.9993 (true 0.927 / 0.940) and mean pLDDT 86.9 (true 95.7), and kept a 700×700 PAE. The structures were fine.batch_size > 1(since 2.8.0), so every smaller fold in such a batch got these scores.recalculate_confidenceonly trimmed when the PAE head's raw logits were present.RunModelreplaces them with the computed PAE array, so it returned early every time.aligned_confidence_probsover the real residues, using AlphaFold's ownpredicted_tm_score. Chain IDs come from the unpadded features; pLDDT, PAE and the probabilities are trimmed. Unpadded predictions are unchanged.Validation
Unit suite (serial): 698 passed, 10 skipped, including new tests for the flag, the requirement checks and the padded scores. One of them uses AlphaFold's real
confidence.pyto show that recomputed padded scores equal the unpadded truth to 1e-6.test_package_layoutfailures also occur on unmodifiedmainwhen run serially.Speed vs AlphaPulldown stock (model_1_multimer_v3, 3 recycles, compile excluded, geometric mean over 164–2,546 tokens):
That's 1.0–1.18× faster than ColabFold 1.6.3's own
--use-fast-kernels, which is 1.8–2.4× on the same inputs. H200 is queued; I'll add it.Accuracy: 12 heterodimers released after AF2-Multimer's training cutoff, DockQ against experimental structures, on H100, A40 and Blackwell MIG; stock seeds 0+1, kernels seeds 0 (+1 on H100/A40).
Kernels off is bit-identical to
mainunder deterministic XLA (A40).--fast_kernels=autothroughrun_structure_prediction:onwith a monomer keeps all 5 monomer models on the standard code.Padded scores, A40, deterministic XLA:
run_structure_prediction_batch,--desired_num_res=599, 357- and 599-token folds): each fold's scores are over its own residues.Companion: KosinskiLab/AlphaPulldownSnakemake#58 (the workflow accepts the flag).
🤖 Generated with Claude Code