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

feat: Improve TASO cost function and rewrite strategies #154

Merged
merged 7 commits into from
Oct 3, 2023

Conversation

lmondada
Copy link
Contributor

@lmondada lmondada commented Oct 3, 2023

Sorry, this ended up being much bigger than expected. If you have any suggestions to simplify it, I'll gladly take them.

I have added a rewrite strategy that considers not only two-qubit gate count, but also breaks ties with total gate count. I think this should make the optimisation landscape less flat overall.

I've also taken the opportunity to make the optimisation cost function a data of the rewrite strategy, so that it no longer has to be passed separately to TASO.

@lmondada lmondada requested a review from aborgna-q October 3, 2023 07:44
Copy link
Collaborator

@aborgna-q aborgna-q left a comment

Choose a reason for hiding this comment

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

Awesome.

I think this'll let me remove the hard-coded node cost function in #149 that's used for splitting the circuit.

///
/// The minor cost to break ties between equal CX counts is the number of
/// quantum gates.
pub type NonIncreasingCXCountStrategy =
Copy link
Collaborator

Choose a reason for hiding this comment

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

The name is a bit detached from the actual definition. Any non-inc strategy with static cost functions will type with this alias.
The default_cx call is the one that introduces the actual CX semantics.
Do you need the alias?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No you're right. I'll remove it.

/// The cost function must return a value of type `Self::OpCost`. All op costs
/// are summed up to obtain a total cost that is then compared using the
/// threshold function.
pub trait ExhaustiveThresholdStrategy {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Move this higher up.

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!

@lmondada lmondada merged commit 0dcf5e0 into main Oct 3, 2023
7 checks passed
@lmondada lmondada deleted the feat/more-strategies branch October 3, 2023 13:33
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