Skip to content

Add rotation cost model #461

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

Merged
merged 10 commits into from
Nov 1, 2023
Merged

Add rotation cost model #461

merged 10 commits into from
Nov 1, 2023

Conversation

NoureldinYosri
Copy link
Contributor

@NoureldinYosri NoureldinYosri commented Oct 27, 2023

This abstraction covers both standarad models which have a cost of $A \log_2(1/\epsilon) + B$ Where $A$
and $B$ depend on the gateset, approximation protocol and hardware parameters and are obtained by fitting regression models. It also covers models with constant per rotation of cost which require a circuit that gets prepared once which gives preparation overhead.

I'm reporting the cost as an AlgorithmSummary object rather than a TComplexity object because it's more natural to report the cost of the second model in terms of Toffoli count rather than T count.

Related to #370 and is part of #269

@NoureldinYosri NoureldinYosri marked this pull request as ready for review October 27, 2023 22:43


@frozen
class LogarithmicModel(RotationCostModel):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This name makes sense here, where you can clearly see that it's an instance of RotationCostModel but I suspect if it shows up outside of the class definition it will lose this critical context. Should probably have rotation in the name 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.

ptal



@frozen
class ConstantCostWithPreparation(RotationCostModel):
Copy link
Collaborator

Choose a reason for hiding this comment

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

again, in actual use the fact that this is for rotations is lost; but we don't want it to be too long.

ConstOverheadRotationCost or something like that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ptal


Attributes:
bitsize: Number of digits of accuracy for approximating a rotation.
slope: The coefficient of $log_2{budget}$.
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is there a slope? isn't this supposed to be constant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for computing the cost of the overhead rotation

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 changed the signature to make this clearer

)


BeverlandEtAl = LogarithmicModel(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Outside of this definition, this variable will appear without the context that it's a rotation cost model

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

Copy link
Collaborator

@mpharrigan mpharrigan left a comment

Choose a reason for hiding this comment

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

👍

@mpharrigan
Copy link
Collaborator

I'm reporting the cost as an AlgorithmSummary object rather than a TComplexity object because it's more natural to report the cost of the second model in terms of Toffoli count rather than T count.

Can you speak more about this? TComplexity lets you report toffoli complexity, no?

@NoureldinYosri
Copy link
Contributor Author

@mpharrigan to use TComplexity I will have to convert the toffolis to Ts TComplexity(t=4*num_toffoli). This is why we have a lot 4*toffoli statements in the codebase which you mentioned you didn't like.

The rotations are implemented in Toffolis so I think the runtime estimate will defer between an architectures that synthesize magic T state vs magic CCZ states.

@mpharrigan
Copy link
Collaborator

oh for some reason I thought we had a toffoli/ccz field in the TComplexity dataclass. Disregard!

@mpharrigan mpharrigan merged commit cf85191 into main Nov 1, 2023
@NoureldinYosri NoureldinYosri deleted the azure_model2 branch November 1, 2023 22:35
@NoureldinYosri NoureldinYosri mentioned this pull request Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants