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

Avoid floating point error in jnp.log2 with x64 enabled #123

Merged
merged 2 commits into from
Feb 24, 2025

Conversation

obackhouse
Copy link
Contributor

Use of jnp.log2 can cause floating point errors on x64:

>>> import jax
>>> jax.config.update("jax_enable_x64", True)
>>> import jax.numpy as jnp
>>> arr = jnp.zeros((2,) * 6, dtype=jnp.float64)
>>> jnp.log2(arr.size)
Array(6., dtype=float64)
>>> int(jnp.log2(arr.size))
5

@gamatos gamatos mentioned this pull request Feb 24, 2025
@gamatos gamatos force-pushed the avoid_log2_fp_error branch from c3d7180 to 66303fd Compare February 24, 2025 11:19
@gamatos gamatos self-requested a review February 24, 2025 11:22
@gamatos gamatos merged commit 153cd10 into CQCL:develop Feb 24, 2025
5 checks passed
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.

2 participants