Automatic LUCJ mapping on heavy-hex#447
Automatic LUCJ mapping on heavy-hex#447ashsaki wants to merge 6 commits intoqiskit-community:mainfrom
Conversation
kevinsung
left a comment
There was a problem hiding this comment.
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.
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.
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.
"interim" not "interm" ?
| a rustworkx. | ||
|
|
||
| PyGraph with two disconnected linear chains. Each chain contains `num_orbitals` |
| 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.
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.
This check can be merged into the while loop condition, right?
There was a problem hiding this comment.
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.
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.
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.
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.