Comments (3)
Hi - thanks for the question! This kind of difference is expected: in general, floating point operations are only accurate to within a particular precision that depends on the width of the float representation. When you compute the "same" result in two ways, the results will not in general be bitwise-equivalent. JIT-compilation replaces your original sequence of operations with a more efficient compiled kernel, and so in general you should not expect bitwise-equivalent outputs.
You can see the approximate expected precision using finfo
:
In [1]: import numpy as np
In [2]: np.finfo(np.float64).eps
Out[2]: np.float64(2.220446049250313e-16)
The differences you're seeing are consistent with those expectations.
from jax.
Also, a side note: you might wonder why the compiler doesn't just simplify x + 0 * y
to x
: the reason for this is that for floating point math, these two expressions may return different results! For example, if you plug-in y = np.inf
or y = np.nan
, the first and second expression are not equivalent.
from jax.
I think we should probably close this as working-as-intended, and Jake's answer covers the reasoning well.
from jax.
Related Issues (20)
- custom_jvp leaks tracers if they're marked as nondiff_argnum HOT 2
- Add support nogil mode in JAX for Python 3.13
- Explicit managing the output buffer of `jax.jit` function HOT 1
- Performance Discrepancy in `jax.value_and_grad` for Different `argnums` HOT 6
- CuDNN Initialization Error with Pre-existing CUDA Environment Fails with HOT 5
- Pallas TPU reduce kernel generalization gives wrong numerical results? HOT 3
- Passing `DeviceLocalLayout` to `jax.jit` causes incorrect outputs on GPU
- Precision of jnp.linalg.solve HOT 3
- JAX segment_sum is two times slower for FP16 inputs than FP32 inputs HOT 10
- jax library error jaxlib.xla_extension.XlaRuntimeError: FAILED_PRECONDITION: DNN library initialization failed HOT 3
- arctan2 and atan2 argument names are misleading HOT 3
- Jax Einsum Implementation Error HOT 1
- jaxlib.xla_extension.XlaRuntimeError: FAILED_PRECONDITION: DNN library initialization failed. HOT 2
- Improve support for using JAX's custom LAPACK calls externally HOT 2
- `erf_inv` not supported in Pallas GPU
- Unsupported conversion from f64 to f16 in pallas despite not using fp16 HOT 1
- Pallas kernel crash at `llo::CouldLtS32` when `interpret=False` on TPU HOT 3
- Pallas Unexpected Numeric Results With `tf32` on A100 GPU HOT 1
- [Pallas GPU] `jnp.abs()` gives the wrong result HOT 1
- Rotation.concatenate does not work for two single rotations HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jax.