Open minhtriet opened 1 month ago
Hi @minhtriet,
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 :crying_cat_face: .
We’ll look into adding a warning in the documentation about this and hopefully allowing it to work with Jax in future releases.
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