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

Why the expect value of Hamiltonian is different from qiskit? #299

Closed
YangD5014 opened this issue Jul 6, 2023 · 5 comments
Closed

Why the expect value of Hamiltonian is different from qiskit? #299

YangD5014 opened this issue Jul 6, 2023 · 5 comments

Comments

@YangD5014
Copy link

When I have a tequila circuit transformed from openqasm, I do try the circuit(no uncertain parameters) as ansatz,and I get the expectation value of Hamiltonian,but get far different value compared to qiskit.
Please correct me if I do misuse the tequila API.

@kottmanj
Copy link
Collaborator

kottmanj commented Jul 6, 2023

Hi, can you post a small example on what exactly you're doing, that might help.

@YangD5014
Copy link
Author

https://github.com/YangD5014/Tequlia_issue/blob/main/tequila_issue.ipynb
Really thank you for instantly reply!

@kottmanj
Copy link
Collaborator

kottmanj commented Jul 6, 2023

thanks for the example. Next reply will take a bit longer ;-)

@kottmanj
Copy link
Collaborator

kottmanj commented Jul 6, 2023

I think I found the problem: it is not the qasm import, this works fine.

Qiskit is using the following oder in the second quantized Hamiltonian: first N/2 qubits are the spin-up orbitals, second N/2 qubits are the spin-down orbitals.
So for the H2 we have:
qubit 0: orbital0 spin-up
qubit 1: orbital1 spin-up
qubit 2: orbital0 spin-down
quits 3: orbital1 spin-down

Tequila is using the same ordering as openfermion: Even qubits are spin-up, odd qubits are spin-down.
So for the H2 we have:
qubit 0: orbital0 spin-up
qubit 1: orbital0 spin-down
qubit 2: orbital1 spin-up
quits 3: orbital1 spin-down

Good news is: You can use the ordering that qiskit uses also in Tequila

mol = tq.Molecule(geometry=..., basis_set=..., transformation="ReorderedJordanWigner")

same goes with "ReorderedBravyiKitaev" etc (the upper-cases are just for readability)

@YangD5014
Copy link
Author

It is so clear! And it is indeed working,thank you!

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

2 participants