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

Change QAOA observable to problem Hamiltonian #260

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Misty-W
Copy link
Collaborator

@Misty-W Misty-W commented Feb 26, 2025

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 for binary encoding the problem Hamiltonian is given by:

$$H_{i,j} = diag(vec(D^T))$$

where, for a 10-qubit circuit as in the UCC benchmarks,

$$H_{i,j} = diag (1, −1, −1, −1, −1, 1, −1, −1, −1, −1, 1, −1, −1, −1, −1, 1, −1, −1, −1, 1)$$

$H_{ij}$ is then input into Qiskit's built-in Operator to facilitate computing the observable.

@Misty-W Misty-W requested a review from natestemen February 26, 2025 18:31
Copy link
Member

@natestemen natestemen left a 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.

@Misty-W
Copy link
Collaborator Author

Misty-W commented Feb 26, 2025

Can you help me understand how this observable is chosen?

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.
Although the authors use MAXCUT to illustrate the binary encoding and "one-hot" encoding methods, the authors mention that they applied both methods to solving a Barabasi-Albert weighted graph and report the results.

Copy link
Member

@natestemen natestemen left a 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
Copy link
Member

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.

obs_str = "Z" * compiled.num_qubits
observable = Operator.from_label(obs_str)
if circuit_name == "qaoa":
observable = Operator(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This observable only represents an operator acting on 4 qubits, but the circuit we are running is 10 qubits. Do we just assume the operator acts as identity on the other 6 qubits?

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

Successfully merging this pull request may close these issues.

Custom observable for QAOA
3 participants