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

Efficiently Implement clifford groups for single and two qubit clifford groups #6389

Closed
NoureldinYosri opened this issue Dec 20, 2023 · 1 comment
Assignees
Labels
area/clifford-group good part time project A meaty non-urgent issue with a substantial amount of work to be done. kind/feature-request Describes new functionality priority/p1 Fix is needed as soon as possible. Should be staffed. It is blocking some major flows for users triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on

Comments

@NoureldinYosri
Copy link
Collaborator

Is your feature request related to a use case or problem? Please describe.
https://github.com/quantumlib/Cirq/blob/main/cirq-core/cirq/experiments/qubit_characterizations.py practically implements single and two qubit clifford groups in order to do sampling. However the implementation is inefficient taking ~3s to sample 1000 cliffords. that's because the clifford groups are implemented directly as matricies and operations are done as matrix multiplication, inversion or mapping to/from index.

Describe the solution you'd like
update SingleQubitCliffordGate

class SingleQubitCliffordGate(CliffordGate):
to implment the single qubit clifford group.

What is the urgency from your perspective for this issue? Is it blocking important work?
P1 - I need this no later than the next release (end of quarter)

@NoureldinYosri NoureldinYosri added kind/feature-request Describes new functionality triage/discuss Needs decision / discussion, bring these up during Cirq Cynque area/clifford-group labels Dec 20, 2023
@dstrain115 dstrain115 added good part time project A meaty non-urgent issue with a substantial amount of work to be done. triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on priority/p2 Next release should contain it priority/p1 Fix is needed as soon as possible. Should be staffed. It is blocking some major flows for users and removed triage/discuss Needs decision / discussion, bring these up during Cirq Cynque priority/p2 Next release should contain it labels Dec 20, 2023
NoureldinYosri added a commit that referenced this issue Jan 8, 2024
…_characterizations for a 37% speedup (#6392)

SingleQubitCliffordGates represents the 24 gates in the single qubit clifford group. Some of the operations this class implements are expensive computation but at the same time are properties of each of the 24 operators.

turning those expensive computations into cached properties is benificial for performance but for that the objects need to be immutable.

one of the places that heavily relies on single qubit cliffords is `qubit_characterizations.py` which implemented the single qubit clifford algebra from scratch by falling on to the matrix representation and doing matrix multiplication and inversion (for computing the adjoint) this led to a bottleneck while creating circuits (e.g. for example _create_parallel_rb_circuit for 50 qubits and a 1000 gates takes $3.886s$). using SingleQubitCliffordGates instead and using `merged_with` operation which maps two cliffords onto the clifford equaivalent to their composition leads to $2.148s$, with most of those 2s spent in `Moment.__init__` which will be the target of the next PR.

I also made the 24 cliffords singleton, since there is no point in creating new object which won't have any of the cached properties.
 
part of #6389
@NoureldinYosri
Copy link
Collaborator Author

the single qubit case was done in the linked PRs. the two qubit case is not needed for now but we can revisit this decision when there is a use case

harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this issue Oct 31, 2024
…_characterizations for a 37% speedup (quantumlib#6392)

SingleQubitCliffordGates represents the 24 gates in the single qubit clifford group. Some of the operations this class implements are expensive computation but at the same time are properties of each of the 24 operators.

turning those expensive computations into cached properties is benificial for performance but for that the objects need to be immutable.

one of the places that heavily relies on single qubit cliffords is `qubit_characterizations.py` which implemented the single qubit clifford algebra from scratch by falling on to the matrix representation and doing matrix multiplication and inversion (for computing the adjoint) this led to a bottleneck while creating circuits (e.g. for example _create_parallel_rb_circuit for 50 qubits and a 1000 gates takes $3.886s$). using SingleQubitCliffordGates instead and using `merged_with` operation which maps two cliffords onto the clifford equaivalent to their composition leads to $2.148s$, with most of those 2s spent in `Moment.__init__` which will be the target of the next PR.

I also made the 24 cliffords singleton, since there is no point in creating new object which won't have any of the cached properties.
 
part of quantumlib#6389
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/clifford-group good part time project A meaty non-urgent issue with a substantial amount of work to be done. kind/feature-request Describes new functionality priority/p1 Fix is needed as soon as possible. Should be staffed. It is blocking some major flows for users 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

2 participants