Repository navigation
Conversation
Merging this PR will not alter performance2 warnings
Comparing |
|
Thanks @b-biswas for this PR! I haven't appreciated that the float32 does not propagate correctly in this case. Let me know if a review would be heplful whenever |
|
@ismael-mendoza let's talk about it in the next meeting... I will write some tests meanwhile! |
|
Some tests are failing with the Interpolated images because |
|
We'll need to make sure we run some tests in 64 and have others where we run in 32 and test at a reduced precision. |
b932bb8 to
104d3e2
Compare
|
|
||
|
|
||
| def test_image_dtype_tracks_storage_with_x64_disabled(): | ||
| original_x64 = jax.config.read("jax_enable_x64") |
There was a problem hiding this comment.
This won't work. You'll need to use a separate python job for a float32 test.
|
apologies, I accidentally pushed an old branch without rebasing Biswajit's changes. Working on a fix... |
104d3e2 to
edfa4fd
Compare
| obj._array = children[0] | ||
| obj.wcs = children[1] | ||
| obj._bounds = children[2] | ||
| obj._dtype = aux_data["dtype"] |
There was a problem hiding this comment.
We should remove dtype from aux_data above if we are doing this.
| else: | ||
| image = self._jax_children[0].copy(dtype=float) | ||
| # Preserve the input dtype | ||
| image = self._jax_children[0].copy() |
There was a problem hiding this comment.
We do need to cast to float for int input images here.
There was a problem hiding this comment.
| image = self._jax_children[0].copy() | |
| if self._jax_children[0].dtype == jnp.float32: | |
| image = self._jax_children[0].copy(dtype=jnp.float32) | |
| else: | |
| image = self._jax_children[0].copy(dtype=float) |
| dk = jnp.pi / (No2 * dx) | ||
|
|
||
| # Use complex64 for float32 inputs, complex128 for float64 | ||
| if self.dtype == jnp.float32: |
There was a problem hiding this comment.
This block might ask for a type that is not available if jax doesn't have float64 enabled and the dtype of the image is int32. I think we need to add specific handling for all of the types.
There was a problem hiding this comment.
For int32 with x64 not enabled, this should raise a warning that x64 is not enabled and use float32 but perhaps we should have something more explicit here.
With int32 images, we should ideally go for float64 ffts because of the dynamic range, right?
There was a problem hiding this comment.
Ah yes good point on the dynamic range. We shouldn't raise a warning if we don't need to, but I cannot find an alias in jax to the largest width complex type available. Sigh.
There was a problem hiding this comment.
I guess it is simpler to leave it as is and let the warnings go through.
There was a problem hiding this comment.
Maybe jax would accept dtype=complex so that it uses the biggest type it has and doesn't raise a warning if it doesn't need to?
beckermr
left a comment
There was a problem hiding this comment.
I think there are a few casting cases for int images that we missed.
Another comment is that we should add a section in the docs on the specific casting rules we use globally, and make sure we actually use them. Does int32 always cast to float32 when needed? What about uint32, uint64 etc.
While trying to run JAX metadetection in
float32, I noticed that the FFT kernels were still usingfloat64internally due to JAX-Galsim. Some small data type fixes seem to solve this issue.Note: Running on
float32is significantly faster!TODO: