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

Add LightSABRE to default_compilation_pass #400

Merged
merged 43 commits into from
Nov 8, 2024
Merged

Conversation

sjdilkes
Copy link
Contributor

@sjdilkes sjdilkes commented Oct 10, 2024

Replace CXMappingPass and Placement with a CustomPass that calls sabre routing as defined by SabreLayoutPassManager.

Checklist

  • I have performed a self-review of my code.
  • I have commented hard-to-understand parts of my code.
  • I have made corresponding changes to the public API documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have updated the changelog with any user-facing changes.

@sjdilkes sjdilkes marked this pull request as ready for review November 7, 2024 15:13
@sjdilkes sjdilkes requested a review from cqc-melf as a code owner November 7, 2024 15:13
@@ -988,46 +988,6 @@ def lift_perm(p: dict[int, int]) -> np.ndarray:
return pm


@pytest.mark.skipif(skip_remote_tests, reason=REASON)
def test_compilation_correctness(brisbane_backend: IBMQBackend) -> None:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

LightSabre Pass does not return any information regarding the implicit qubit permutation. If a circuit has Measure operations, as we'd expect for hardware, then this is not an issue, as all post-processing is completed based on output bits from Measures, which are still measuring the same states.

This test confirmed that the compilation, including SWAP operations, did not change the unitary, action, up to permutations, for a backend with some architecture. In practice we do not expect users to want to do unitary simulation with qubit swapping, so I think we can reasonably remove this test.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this potentially an issues for other cases? Should this be documented somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added this test back in, but edited it to only check the routing is correct

@CalMacCQ
Copy link
Contributor

CalMacCQ commented Nov 7, 2024

Small comment about docs.

Maybe we should update this section given that the default compilation pass is changing?
https://docs.quantinuum.com/tket/extensions/pytket-qiskit/#default-compilation

Source file.

@sjdilkes
Copy link
Contributor Author

sjdilkes commented Nov 7, 2024

Small comment about docs.

Maybe we should update this section given that the default compilation pass is changing? https://docs.quantinuum.com/tket/extensions/pytket-qiskit/#default-compilation

Source file.

Good point - I've updated the source file. Please could you advice if there's anything else I need to do?

Copy link
Collaborator

@cqc-melf cqc-melf left a comment

Choose a reason for hiding this comment

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

Looks good, few questions.

"""
Converts a pytket Architecture object to a Qiskit CouplingMap object.

:param architecture: Architecture to be converted
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add some more details about the return value here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

:param architecture: Architecture LightSABRE routes circuits to match
:param optimization_level: Corresponds to qiskit optmization levels
:param seed: LightSABRE routing is stochastic, with this parameter setting the seed
:param attempts: Number of generated random solutions to pick from.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add some more details about the return value here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -988,46 +988,6 @@ def lift_perm(p: dict[int, int]) -> np.ndarray:
return pm


@pytest.mark.skipif(skip_remote_tests, reason=REASON)
def test_compilation_correctness(brisbane_backend: IBMQBackend) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this potentially an issues for other cases? Should this be documented somewhere?

@sjdilkes sjdilkes requested a review from cqc-melf November 8, 2024 09:10
@CalMacCQ
Copy link
Contributor

CalMacCQ commented Nov 8, 2024

Good point - I've updated the source file. Please could you advice if there's anything else I need to do?

Local build of the docs looks good, no further edits needed.

tests/backend_test.py Outdated Show resolved Hide resolved
@sjdilkes sjdilkes requested a review from cqc-melf November 8, 2024 16:13
@cqc-melf
Copy link
Collaborator

cqc-melf commented Nov 8, 2024

The tests fail because of #414

I would suggest to merge this now as it is. Any objections?

@cqc-melf cqc-melf merged commit 1e8bd80 into main Nov 8, 2024
3 of 6 checks passed
@sjdilkes sjdilkes deleted the LightSABRE-CustomPass branch November 8, 2024 16:59
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