-
Notifications
You must be signed in to change notification settings - Fork 34
Automatic LUCJ mapping on heavy-hex #447
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
base: main
Are you sure you want to change the base?
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.
You have many references to "IBM" backends, but in principle this should work for any Qiskit backend that has heavy-hex connectivity, so please remove those references.
Does this code also work for square lattice connectivity? If not, which part of the code relies on heavy-hex? This wasn't obvious to me.
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.
Need to add copyright header (you can copy it from another file).
|
|
||
|
|
||
| def _create_two_linear_chains(num_orbitals: int) -> PyGraph: | ||
| """In zig-zag layout, there are two linear chains (with connecting 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.
Each docstring should begin with a one-line summary (see https://peps.python.org/pep-0257/#multi-line-docstrings)
| isomorphic sub-graph to the QPU/backend coupling graph). The zigzag pattern | ||
| includes both linear chains (alpha-alpha/beta-beta interactions) and | ||
| connecting qubits between the linear chains (alpha-beta interactions). | ||
| The algorithm works as follows: It starts with an interm graph (`graph_new`) |
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.
"interim" not "interm" ?
| a rustworkx. | ||
|
|
||
| PyGraph with two disconnected linear chains. Each chain contains `num_orbitals` |
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.
Bad line spacing?
| isomorphic = False | ||
| graph = _create_two_linear_chains(num_orbitals=num_orbitals) | ||
|
|
||
| graph_new = copy.deepcopy(graph) # to avoid not bound warning |
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 we use the copy method on the PyGraph, rather than deepcopy?
| if not alpha_beta_indices: | ||
| break |
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.
This check can be merged into the while loop condition, right?
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.
Need to add copyright header.
| return graph_new, alpha_beta_indices | ||
|
|
||
|
|
||
| def _make_backend_cmap_pygraph(backend: BackendV2) -> PyGraph: |
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.
Given that this function only uses backend.coupling_map.graph from the backend, I think it should be refactored so that it simply accepts that graph directly as input.
| return initial_layout[:-num_allowed_alpha_beta_indices], allowed_alpha_beta_indices | ||
|
|
||
|
|
||
| def generate_pm_and_interactions_lucj_heavy_hex( |
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.
Let's rename this function to generate_lucj_heavy_hex_pass_manager
| test_data1 = [[(num_orbitals + 1, num_orbitals + 1)], [(num_orbitals, num_orbitals)]] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("requested_alpha_beta_indices", test_data1) |
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.
Please place the data directly into the parametrize call, rather than creating a variable for it.
This PR adds a file under
ffsim.qiskit.transpiler_passesnamedlucj_heavy_hex_preset_pass_manager. The include a function namedgenerate_preset_pass_manager_lucj_heavy_hex_with_alpha_betas, which returns a Qiskit preset pass manager that can map a LUCJ circuit adhering to the heavy-hex freindly zig-zag layout. It also returns a list of allowed alpha-beta interactions which is needed for construction HW-compatible LUCJ ansatz.Tests pending.