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 optimisation_level 3 using GreedyPauliSimp #546

Merged
merged 12 commits into from
Nov 21, 2024
Merged

Conversation

sjdilkes
Copy link
Contributor

@sjdilkes sjdilkes commented Nov 21, 2024

Adds a new optimisation level "3" that uses GreedyPauliSimp targeting zzphase to optimise circuits. This calls RemoveBarriers, which is part of the motivation for adding it as a new level of optimisation. This mimics the changes to pytket-qiskit.

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 21, 2024 12:08
@sjdilkes sjdilkes requested a review from yao-cqc as a code owner November 21, 2024 12:08
passlist.extend(
[
RemoveBarriers(),
AutoRebase({OpType.CX, OpType.Rz, OpType.H}),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should allow more gates that GreedyPauliSimp can handle so the rebase can run faster. Also easier for the Pauli graph conversion.

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

Comment on lines +741 to +742
thread_timeout=timeout,
trials=10,
Copy link
Contributor

Choose a reason for hiding this comment

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

When GreedyPauliSimp returns false, will the user know the cause, so they can, for example, try increasing the timeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They won't & I can't think of a good way of sharing this information in the code. Might just have to make it clear in the documentation?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Can we print out some information in the C++ code? If you think that's possible, we should create an issue for this.

else:
passlist.extend(
[
RemoveBarriers(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also issue a warning if the circuit contains barriers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, added to the new overloaded get_compiled_circuit method

@@ -655,14 +657,16 @@ def rebase_pass(self) -> BasePass:
allow_swaps=self.compilation_config.allow_implicit_swaps,
)

def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass:
def default_compilation_pass(
Copy link
Contributor

Choose a reason for hiding this comment

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

should also document the timeout parameter

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

@@ -655,14 +657,16 @@ def rebase_pass(self) -> BasePass:
allow_swaps=self.compilation_config.allow_implicit_swaps,
)

def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass:
def default_compilation_pass(
self, optimisation_level: int = 2, timeout: int = 300
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems the user cannot set a timeout when calling get_compiled_circuit. Any thoughts on this?

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 get_compiled_circuit and get_compiled_circuits to QuantinuumBackend with a timeout parameter

@sjdilkes sjdilkes requested a review from yao-cqc November 21, 2024 13:43
@sjdilkes sjdilkes merged commit c4b71b3 into main Nov 21, 2024
12 checks passed
@sjdilkes sjdilkes deleted the add-optimisation-level-3 branch November 21, 2024 14:58
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.

2 participants