Skip to content
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

add patch for AlphaFold v2.2.2 to fix NaN problem with jax 0.3.9 #15874

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
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ components = [
'AlphaFold-2.0.0_n-cpu.patch',
'AlphaFold-2.1.0_fix-scp-path.patch',
'AlphaFold-2.0.1_setup_rm_tfcpu.patch',
'AlphaFold-2.2.2_jax038_NaN.patch',
],
'checksums': [
'aa51dc4a1150b92310d20e63e9e4d9279b15b6a1f7e664360f52827f83256cdd', # v2.2.2.tar.gz
Expand All @@ -92,6 +93,7 @@ components = [
'dfda4dd5f9aba19fe2b6eb9a0ec583d12dcefdfee8ab8803fc57ad48d582db04', # AlphaFold-2.0.0_n-cpu.patch
'5363d403baf5ab73f4d3ddd72e19af9ff832de4b1d7ba25a5fbcc5846c1c890f', # AlphaFold-2.1.0_fix-scp-path.patch
'1a2e4e843bd9a4d15ee39e6c37cc63ba281311cc7a0a5610f0e43b52ef93faac', # AlphaFold-2.0.1_setup_rm_tfcpu.patch
'0b040ba99208cd9ad79b7d17db5720f7a447a019ac0ca786b3b019a55d1544e0', # AlphaFold-2.2.2_jax038_NaN.patch
],
'start_dir': 'alphafold-%(version)s',
'use_pip': True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ components = [
'AlphaFold-2.0.0_n-cpu.patch',
'AlphaFold-2.1.0_fix-scp-path.patch',
'AlphaFold-2.0.1_setup_rm_tfcpu.patch',
'AlphaFold-2.2.2_jax038_NaN.patch',
],
'checksums': [
'aa51dc4a1150b92310d20e63e9e4d9279b15b6a1f7e664360f52827f83256cdd', # v2.2.2.tar.gz
Expand All @@ -87,6 +88,7 @@ components = [
'dfda4dd5f9aba19fe2b6eb9a0ec583d12dcefdfee8ab8803fc57ad48d582db04', # AlphaFold-2.0.0_n-cpu.patch
'5363d403baf5ab73f4d3ddd72e19af9ff832de4b1d7ba25a5fbcc5846c1c890f', # AlphaFold-2.1.0_fix-scp-path.patch
'1a2e4e843bd9a4d15ee39e6c37cc63ba281311cc7a0a5610f0e43b52ef93faac', # AlphaFold-2.0.1_setup_rm_tfcpu.patch
'0b040ba99208cd9ad79b7d17db5720f7a447a019ac0ca786b3b019a55d1544e0', # AlphaFold-2.2.2_jax038_NaN.patch
],
'start_dir': 'alphafold-%(version)s',
'use_pip': True,
Expand Down
16 changes: 16 additions & 0 deletions easybuild/easyconfigs/a/AlphaFold/AlphaFold-2.2.2_jax038_NaN.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Thomas Hoffmann, EMBL Heidelberg, structures-it@embl.de
# Resulting pdb files contain NaNs because jax >= 0.3.8 is used.
# Fix according to https://github.com/deepmind/alphafold/issues/513 and
# https://jax.readthedocs.io/en/latest/changelog.html#jax-0-3-8-april-29-2022
diff -ru alphafold-2.2.2/alphafold/model/utils.py alphafold-2.2.2_jax38_NaN/alphafold/model/utils.py
--- alphafold-2.2.2/alphafold/model/utils.py 2022-06-13 17:49:22.000000000 +0200
+++ alphafold-2.2.2_jax38_NaN/alphafold/model/utils.py 2022-07-18 10:17:59.672423061 +0200
@@ -34,7 +34,7 @@

def batched_gather(params, indices, axis=0, batch_dims=0):
"""Implements a JAX equivalent of `tf.gather` with `axis` and `batch_dims`."""
- take_fn = lambda p, i: jnp.take(p, i, axis=axis)
+ take_fn = lambda p, i: jnp.take(p, i, axis=axis, mode="clip")
for _ in range(batch_dims):
take_fn = jax.vmap(take_fn)
return take_fn(params, indices)