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

[jax] set_precision throws exception on latest jax version #206

Closed
javier-garcia-tilburg opened this issue Nov 25, 2024 · 2 comments
Closed

Comments

@javier-garcia-tilburg
Copy link

javier-garcia-tilburg commented Nov 25, 2024

Issue

Problem Description

from torchquad import set_up_backend, MonteCarlo

set_up_backend("jax", data_type="float32")

The code above throws the exception below on latest jax version. The reason is that the jax.config submodule has been removed (previously it was also deprecated)

File <project>\env\Lib\site-packages\torchquad\utils\set_precision.py:58, in set_precision(data_type, backend)
     [56](file://<project>/env/Lib/site-packages/torchquad/utils/set_precision.py:56)     torch.set_default_tensor_type(tensor_dtype)
     [57](file://<project>/env/Lib/site-packages/torchquad/utils/set_precision.py:57) elif backend == "jax":
---> [58](file://<project>/env/Lib/site-packages/torchquad/utils/set_precision.py:58)     from jax.config import config
     [60](file://<project>/env/Lib/site-packages/torchquad/utils/set_precision.py:60)     config.update("jax_enable_x64", data_type == "float64")
     [61](file://<project>/env/Lib/site-packages/torchquad/utils/set_precision.py:61)     logger.info(f"JAX data type set to {data_type}")

ModuleNotFoundError: No module named 'jax.config'

Expected Behavior

It should not throw an exception

What Needs to be Done

Replacing from jax.config import config with from jax import config

How Can It Be Tested or Reproduced

Install latest jax and torchquad and run example above. In my case I used jax-0.4.35 and torchquad 0.4.0.

@javier-garcia-tilburg javier-garcia-tilburg changed the title [Jax] set_precision throws exception on latest jax version [jax] set_precision throws exception on latest jax version Nov 25, 2024
@javier-garcia-tilburg
Copy link
Author

Related to pull request #199

Workaround is to use set_up_backend("jax") and avoid set_precision. Numerical precision can still be configured manually within jax, e.g. jax.config.update("jax_enable_x64", True).

@gomezzz
Copy link
Collaborator

gomezzz commented Nov 25, 2024

Hi @javier-garcia-tilburg ,

Thanks for pointing it out. I have merged the related PR changes and created a new minor release with this and additional smaller changes. It can already be tested via pip install torchquad==0.4.1 and should fix this hopefully. conda version should follow in a couple of days. Feel free to re-open in case of issues.

Thanks!

@gomezzz gomezzz closed this as completed Nov 25, 2024
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 a pull request may close this issue.

2 participants