Skip to content

Conversation

@ashsaki
Copy link

@ashsaki ashsaki commented Aug 15, 2025

This PR adds a file under ffsim.qiskit.transpiler_passes named lucj_heavy_hex_preset_pass_manager. The include a function named generate_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.

@CLAassistant
Copy link

CLAassistant commented Aug 15, 2025

CLA assistant check
All committers have signed the CLA.

@ashsaki ashsaki marked this pull request as ready for review September 22, 2025 20:41
Copy link
Collaborator

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

Copy link
Collaborator

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
Copy link
Collaborator

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`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

"interim" not "interm" ?

Comment on lines +23 to +25
a rustworkx.

PyGraph with two disconnected linear chains. Each chain contains `num_orbitals`
Copy link
Collaborator

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
Copy link
Collaborator

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?

Comment on lines +102 to +103
if not alpha_beta_indices:
break
Copy link
Collaborator

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?

Copy link
Collaborator

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:
Copy link
Collaborator

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(
Copy link
Collaborator

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

Comment on lines +41 to +44
test_data1 = [[(num_orbitals + 1, num_orbitals + 1)], [(num_orbitals, num_orbitals)]]


@pytest.mark.parametrize("requested_alpha_beta_indices", test_data1)
Copy link
Collaborator

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.

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.

3 participants