Skip to content

Guard against division by zero in JAX where clauses.#2138

Merged
copybara-service[bot] merged 1 commit into
mainfrom
test_905282614
Apr 29, 2026
Merged

Guard against division by zero in JAX where clauses.#2138
copybara-service[bot] merged 1 commit into
mainfrom
test_905282614

Conversation

@copybara-service

Copy link
Copy Markdown

Guard against division by zero in JAX where clauses.

This change adds checks to prevent division by zero in calculations involving impurity properties where Z_eff=1.0 (no impurities), particularly within jnp.where expressions. Since JAX evaluates both branches of jnp.where, denominators must be non-zero even in the branch that is logically not taken, to avoid JAX sharp edges.

@copybara-service
copybara-service Bot force-pushed the test_905282614 branch 2 times, most recently from 902c921 to 0291eae Compare April 29, 2026 17:38
This change adds checks to prevent division by zero in calculations involving impurity properties where Z_eff=1.0 (no impurities), particularly within jnp.where expressions. Since JAX evaluates both branches of jnp.where, denominators must be non-zero even in the branch that is logically not taken, to avoid JAX sharp edges.

PiperOrigin-RevId: 907672167
@copybara-service
copybara-service Bot merged commit cc46db9 into main Apr 29, 2026
@copybara-service
copybara-service Bot deleted the test_905282614 branch April 29, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant