Closed erikrecio closed 3 months ago
Thanks for opening this issue.
When trying it out locally, I get True
for both master and v0.36.0
, the latest release. But I do get False
for version v0.35.0. We changed our system for representing arithmetic observables in v0.36.0.
Would you mind posting type(hamiltonian)
and it's contents?
def ground_state(j1, j2):
hamiltonian = 0
for i in range(nqubits):
hamiltonian += Z(i)
hamiltonian -= j1 * X(i) @ X((i+1)%nqubits)
hamiltonian -= j2 * X((i-1)%nqubits) @ Z(i) @ X((i+1)%nqubits)
print(type(hamiltonian))
print(hamiltonian)
ham_matrix = qml.matrix(hamiltonian)
_, eigvecs = jnp.linalg.eigh(ham_matrix)
return eigvecs[:,0]
Seems like the new version fixes it! The types of hamiltonians before were different (from vmap to direct calling). Now they are both <class 'pennylane.ops.op_math.sum.Sum'>. The issues I was having seem to be fixed. Thanks for the quick answer!
Also, with the latest release, you can directly create qml.X
,qml.Y
, qml.Z
and qml.I
.
Sorry. one last thing to mention, you may also want to do ham_matrix = qml.matrix(hamiltonian, wire_order=(0,1,2,3))
. The new Sum
operator gets it's wires from order of occurance.
Great, I'll take a look. Thanks!
Expected behavior
Both ground states gs[0] and g0 are the same.
Actual behavior
They are different. When calculated with a batch or directly calling the function.
Additional information
I'm not sure if it's a pennylane's problem or a jax one. I thouhgt to post it here first since the building of the matrix of the hamiltonian is all in pennylane.
Source code
Tracebacks
No response
System information
Existing GitHub issues