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

Datatype changes to np.array when jit is disabled #212

Open
rkruegs123 opened this issue Aug 27, 2022 · 0 comments
Open

Datatype changes to np.array when jit is disabled #212

rkruegs123 opened this issue Aug 27, 2022 · 0 comments

Comments

@rkruegs123
Copy link
Contributor

rkruegs123 commented Aug 27, 2022

TLDR: when you disable jit with config.update('jax_disable_jit', True), apply_fn from nvt_nose_hoover throws the following error: AttributeError: 'numpy.ndarray' object has no attribute 'at'. At some point along the way, the jax array gets converted to a numpy array. More specifically, the call to dataclasses.astuple(state) in update_chain_mass_fn (called by chain_fns.update_mass(chain, _kT) in apply_fn) converts the jax numpy arrays to normal numpy arrays.

Full story:

I have been experimenting with nvt_nose_hoover recently. However, perhaps due to its chaining method, it takes a long time to compile. To accelerate my debugging process, I wanted to turn off jit globally (as an aside, it can be a bit confusing to the user that even without any usage of jit themselves, some things are being jitted by default. This makes using normal debugging tools like pdb confusing), so I set config.update('jax_disable_jit', True). This broke the code. I did a bit of digging and figured out why -- dataclasses.astuple converts jax arrays to normal numpy arrays. I suspect this is an issue with other integrators as well.

A simple way to reproduce this result is by running a nose-hoover test case from the rigid body tests with jit disabled. Perhaps it might be wise to run all tests with jit disabled to identify where else this could be a problem.

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

No branches or pull requests

1 participant