You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to optimize for the coordinates of different molecules in a reaction A+B->AB. It would make sense if I fixed coordinates of A and optimize for B's only. However, it doesn't work right now.
Then jnp.array([0, 0, 0, *coord]) won't work (within a pennylane context). The error is jax.errors.TracerArrayConversionError: The numpy.ndarray conversion method __array__() was called on traced array with shape float32[2,3].
It is because at \qchem\openfermion_obs.py, we have this line geometry_dhf = qml.numpy.array(coordinates.reshape(len(symbols), 3)). At the end of the stack trace it would convert jax to a np array
Implementation
Here is my MVP to recreate the error. The issue is at line 17
As I answered in the forum thread it looks like molecular_hamiltonian unfortunately only works with autograd so you would need to go back to using PennyLane Numpy instead of Jax 😿 .
We’ll look into adding a warning in the documentation about this and hopefully allowing it to work with Jax in future releases.
Thanks @minhtriet for opening the issue. As suggested by Catalina here, could you please try using the diff_hamiltonian function which works with different frameworks? You might also look at this demo for more insight on differentiable qchem workflows.
Feature details
I want to optimize for the coordinates of different molecules in a reaction
A+B->AB
. It would make sense if I fixed coordinates ofA
and optimize forB
's only. However, it doesn't work right now.Suppose I have this JAX traced array
Then
jnp.array([0, 0, 0, *coord])
won't work (within a pennylane context). The error isjax.errors.TracerArrayConversionError: The numpy.ndarray conversion method __array__() was called on traced array with shape float32[2,3].
It is because at
\qchem\openfermion_obs.py
, we have this linegeometry_dhf = qml.numpy.array(coordinates.reshape(len(symbols), 3))
. At the end of the stack trace it would convertjax
to anp
arrayImplementation
Here is my MVP to recreate the error. The issue is at line 17
How important would you say this feature is?
2: Somewhat important. Needed this quarter.
Additional information
No response
The text was updated successfully, but these errors were encountered: