Skip to content

(fix): use static_argnums for jax jit #165

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

Merged
merged 2 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion torchquad/integration/newton_cotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ def get_jit_compiled_integrate(
self.calculate_grid, static_argnames=["N"]
)
self._jax_jit_calculate_result = jax.jit(
self.calculate_result, static_argnames=["dim", "n_per_dim"]
self.calculate_result,
static_argnums=(
1,
2,
), # dim and n_per_dim
)
jit_calculate_grid = self._jax_jit_calculate_grid
jit_calculate_result = self._jax_jit_calculate_result
Expand Down
3 changes: 2 additions & 1 deletion torchquad/tests/boole_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

def _run_boole_tests(backend, _precision):
"""Test the integrate function in integration.Boole for the given backend.
Note: For now the 10-D test is diabled due to lack of GPU memory on some computers."""
Note: For now the 10-D test is diabled due to lack of GPU memory on some computers.
"""

bl = Boole()
# 1D Tests
Expand Down
3 changes: 2 additions & 1 deletion torchquad/utils/set_up_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

def _get_default_backend():
"""Get the latest backend which was passed to set_up_backend.
If set_up_backend has never been executed, return "torch" for backwards compatibility"""
If set_up_backend has never been executed, return "torch" for backwards compatibility
"""
return os.environ.get("TORCHQUAD_DEFAULT_BACKEND", "torch")


Expand Down