Skip to content

Commit fd39d2c

Browse files
Augustin-Zidekcopybara-github
authored andcommitted
Fix numerical instability that prevents AF3 from running without a GPU
Discovered by @wuooo339 in #273 (comment) PiperOrigin-RevId: 948202523 Change-Id: I7566974d2dbd04abdabfcaa471a01b8ca3e12f33
1 parent 0d3facb commit fd39d2c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/alphafold3/model/network/diffusion_head.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,10 @@ def apply_denoising_step(carry, noise_level):
341341
gamma = config.gamma_0 * (noise_level > config.gamma_min)
342342
t_hat = noise_level_prev * (1 + gamma)
343343

344-
noise_scale = config.noise_scale * jnp.sqrt(t_hat**2 - noise_level_prev**2)
344+
noise_scale = config.noise_scale * jnp.sqrt(
345+
# Don't take sqrt of tiny negative number (happens when running on CPU).
346+
jnp.maximum(t_hat**2 - noise_level_prev**2, 0.0)
347+
)
345348
noise = noise_scale * jax.random.normal(key_noise, positions.shape)
346349
positions_noisy = positions + noise
347350

0 commit comments

Comments
 (0)