-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Is your feature request related to a use case or problem? Please describe.
The __pow__
operator for CliffordGate
is implemented only for integer powers and has complexity
Cirq/cirq-core/cirq/ops/clifford_gate.py
Lines 399 to 411 in ec84a05
def __pow__(self, exponent) -> 'CliffordGate': | |
if exponent == -1: | |
return CliffordGate.from_clifford_tableau(self.clifford_tableau.inverse()) | |
if exponent > 0 and int(exponent) == exponent: | |
base_tableau = self.clifford_tableau.copy() | |
for _ in range(int(exponent) - 1): | |
base_tableau = base_tableau.then(self.clifford_tableau) | |
return CliffordGate.from_clifford_tableau(base_tableau) | |
if exponent < 0 and int(exponent) == exponent: | |
base_tableau = self.clifford_tableau.copy() | |
for _ in range(int(-exponent) - 1): | |
base_tableau = base_tableau.then(self.clifford_tableau) | |
return CliffordGate.from_clifford_tableau(base_tableau.inverse()) |
For SingleQubitCliffordGate
it's implemented for only integer powers where it falls to CliffordGate.__pow__
and for
Cirq/cirq-core/cirq/ops/clifford_gate.py
Lines 718 to 728 in ec84a05
def __pow__(self, exponent) -> 'SingleQubitCliffordGate': | |
# First to check if we can get the sqrt and negative sqrt Clifford. | |
if self._get_sqrt_map().get(exponent, None): | |
pow_gate = self._get_sqrt_map()[exponent].get(self, None) | |
if pow_gate: | |
return pow_gate | |
# If not, we try the Clifford Tableau based method. | |
ret_gate = super().__pow__(exponent) | |
if ret_gate is NotImplemented: | |
return NotImplemented | |
return SingleQubitCliffordGate.from_clifford_tableau(ret_gate.clifford_tableau) |
Describe the solution you'd like
For CliffordGate.__pow__
exponentiation should be done using binary exponentiation to reduce the complexity ot
For SingleQubitCliffordGate.__pow__
. The single qubit clifford gates are a group of size 24. see.
Cirq/cirq-core/cirq/ops/clifford_gate.py
Line 149 in ec84a05
def all_single_qubit_cliffords(cls) -> Sequence['cirq.SingleQubitCliffordGate']: |
support for integer powers can be done in CliffordGate.__pow__
but with exponent%24
instead of expnent
or cache the results in table and access group_powers[self][exponent%24]
. For rational exponents, When the clifford operation has a sqrt. The operation becomes well defined for exponents of the form
What is the urgency from your perspective for this issue? Is it blocking important work?
P3 - I'm not really blocked by it, it is an idea I'd like to discuss / suggestion based on principle