-
Notifications
You must be signed in to change notification settings - Fork 1
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
Change QAOA observable to problem Hamiltonian #260
Change QAOA observable to problem Hamiltonian #260
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you help me understand how this observable is chosen?
Starting from the circuit we are running: qaoa_barabasi_albert which comes from benchpress. I don't know much about this circuit, but I assume it is trying to solve some problem related to the Barabási-Albert model. Naively, I wouldn't expect this QAOA circuit to have the same Hamiltonian as a QAOA circuit solving a MAXCUT problem. My knowledge of QAOA is quite limited, so I may be missing something.
It's unfortunate that there isn't more documentation on this circuit in benchpress.
Since I was unable to find the problem Hamiltonian or any other observable used in Benchpress, I looked in the literature for QAOA approaches to solving Barabasi-Albert weighted graphs and found the paper I linked in this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay, thanks for the explanation, that helps me understand much more (and more than the reading I was doing). I wonder if we should reach out to the benchpress team to get some info on how the qaoa circuits are generated and ask what Hamiltonian they are using.
I have at one blocking comment, and one question.
@@ -235,8 +235,37 @@ def simulate_expvals( | |||
|
|||
else: | |||
density_matrix = simulate_density_matrix(compiled_circuit) | |||
obs_str = "Z" * compiled.num_qubits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable obs_str
still needs to be set in order to be recorded in the results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I wonder why it didn't raise an error when I ran it. Let me check again...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both issues are fixed-
- I set
obs_str
to"H_p"
(problem Hamiltonian) because the sum of Pauli strings is way too long to display. - The missing
obs_str
didn't throw an error because the 'if' statement should have readif circuit_name == "qaoa_barabasi_albert"
notif circuit_name == "qaoa"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using H_p
doesn't seem ideal, but a good compromise. We should record the observable string somewhere for easy reference.
Good find with that bug!
Use `qiskit.quantum_info.SparsePauliOp` to construct problem Hamiltonian for QAOA observable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I was initially a little worried about using SparsePauliOp
instead of an instance of Operator
(since that what density_matrix.expectation_value
expects), but it turns out that they are both derived from LinearOp
, so all checks out.
How does this impact results?
Fixes #255.
A natural choice of observable for the QAOA circuits is the problem Hamiltonian, instead of the default "ZZZZ..." observable.
In https://arxiv.org/pdf/2009.01095, we see that the problem Hamiltonian for a weighted graph with binary encoding is:
where the matrix$H_{i,j}$ is a diagonal matrix modeling the interaction between vertices $i$ and $j$ , and $w_{i,j}$ is the weight of the edge between vertices i and j as well as the resulting unitary evolution.
For$k = 2$ , which corresponds to one qubit per vertex of the graph, the local Hamiltonian is
which can be written