-
Notifications
You must be signed in to change notification settings - Fork 114
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
Circuit ansatze should be dagger functors #155
Conversation
Thanks a lot for this PR @kinianlo ! Your approach would work for circuits, but could be expanded to extend this behaviour to all functors (not just ansatze). I'd recommend this be implemented by adding your logic in a This would yield the same behaviour for ansatze, and across functors applied to daggered boxes. |
@nikhilkhatri Thank you for the suggestion! I I’ve tried to implement that but there is a problem at its current state: |
@kinianlo I think it makes sense to add a Something as simple as the following should work:
|
Copied and pasted👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this, looks good now.
It would be nice to have
CircuitAnsatz
acting as a dagger functor, that isCurrently this is not true. For instance:
Note that the symbols of
circ2
are completely different to those incirc1
. The ansatz simply takes the dagger as part of the symbol names.This behaviour means that the use of
RemoveCupsRewriter
would lead to circuits that are outright different to those without the use of the rewriter. This should be undesirable as the role ofRemoveCupsRewriter
should be merely to improve computational efficiency, while keeping outputs untouched.The proposed fix
In the
_ar
method of the base classCircuitAnsat
, a check is added to see if the box is daggered. If so, the un-daggered box is passed to the ansatz whose output would be then daggered.