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 explicit _act_on_ function for SingleQubitCliffordGate #5256

Open
BichengYing opened this issue Apr 13, 2022 · 2 comments
Open

Add explicit _act_on_ function for SingleQubitCliffordGate #5256

BichengYing opened this issue Apr 13, 2022 · 2 comments
Labels
area/gates kind/feature-request Describes new functionality triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on

Comments

@BichengYing
Copy link
Collaborator

Is your feature request related to a use case or problem? Please describe.
No.

Describe the solution you'd like
The underlying data structure of SingleQubitCliffordGate is Clifford Tableau now but we don't have explicit _act_on_ for it.
By now, the effect of SingleQubitCliffordGate applying to ActOnCliffordTableauArgs implicit works through the decomposition and act_on function of some basic gates, like X, Y, Z, H, etc. But it can be directly applied with underlying Tableau without calling decomposition.
As for ActOnStabilizerCHFormArgs, I don't know if there is a way to do it through Tableau directly. We always can make that function as NotImplemented for CH_Form and fall back to old approach.

[optional] Additional context (e.g. screenshots)
See #5069 for the context.

What is the urgency from your perspective for this issue? Is it blocking important work?
P2 - we should do it in the next couple of quarters

@BichengYing BichengYing added the kind/feature-request Describes new functionality label Apr 13, 2022
@MichaelBroughton MichaelBroughton added the triage/discuss Needs decision / discussion, bring these up during Cirq Cynque label Apr 20, 2022
@vtomole vtomole added triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on time/after-1.0 and removed triage/discuss Needs decision / discussion, bring these up during Cirq Cynque labels Apr 20, 2022
@tanujkhattar
Copy link
Collaborator

tanujkhattar commented Apr 20, 2022

Quoting Orion from Cirq Sync:

@daxfohl is doing "something" with act on args to make it cleaner and this looks related to his stuff.

@daxfohl
Copy link
Contributor

daxfohl commented Apr 20, 2022

I removed everywhere where the gates had special simulator-specific handling in their act_on implementation, basically establishing a convention that simulators were a layer on top of gates, not vice-versa. This was mostly done in #4748.

However IIUC these gates are targeted specifically to the Tableau sampler, and not be used as general-purpose gates. So it makes sense here to allow these gates to reference the Tableau directly in their act_on implementation. In fact it's a great example of when this pattern can be used, to create a special gate type specific to a simulator, without having to modify the simulator code itself.

The alternative would be to add some abstract get_custom_strategies() in act_on_stabilizer_args and append the results of that here. https://github.com/quantumlib/Cirq/blob/master/cirq-core/cirq/sim/clifford/act_on_stabilizer_args.py#L94. The default implementation would return an empty list, and the tableau implementation could return a strategy that handles SingleQubitCliffordGates.

That said, it seems like overkill and I think the act_on implementation is cleaner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/gates kind/feature-request Describes new functionality triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on
Projects
None yet
Development

No branches or pull requests

5 participants