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

constructing cliffords from linear functions and permutation gates #10423

Merged
merged 4 commits into from
Aug 16, 2023

Conversation

alexanderivrii
Copy link
Contributor

@alexanderivrii alexanderivrii commented Jul 13, 2023

Summary

Adding Clifford.from_linear_function and Clifford.from_permutation methods, and allowing to construct a Clifford either directly from a linear function or a permutation, or from a quantum circuit containing such gates.

Details and comments

Previously, Cliffords could be constructed from linear functions (or from circuits containing linear functions), however this required to first synthesize each linear function into a circuit consisting of CX and SWAP gates and then to create a Clifford from this circuit. This is obviously slower than the direct construction: when a linear function is represented by a nxn binary invertible matrix A, then the corresponding Clifford has the symplectic matrix [[A^{t}, 0], [0, A^{-1}]].

Just for fun, here are some numbers showing the times for the old and the new constructions, summed over 10 different linear functions with the right number of qubits:

num_qubits   old time      new time
  5          0.0150          0.0020
 10          0.0614          0.0030
 50          2.1066          0.0259
100          9.0950          0.1092
250          66.7331         0.7266

Both are very fast when the number of qubits is in the small-medium range, but after that the time to synthesize a linear function becomes noticeable.

Previously, Cliffords could not be constructed from permutation gates (i.e. from PermutationGate objects), though they could be constructed from Permutation circuits, which again required to synthesize them first. Again, a direct and much easier construction is available (not to mention that permutations are special cases of linear functions).

@alexanderivrii alexanderivrii requested review from a team and ikkoham as code owners July 13, 2023 06:45
@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core
  • @ikkoham

@alexanderivrii alexanderivrii added the mod: quantum info Related to the Quantum Info module (States & Operators) label Jul 13, 2023
@alexanderivrii alexanderivrii added this to the 0.25.0 milestone Jul 13, 2023
@ShellyGarion ShellyGarion self-requested a review July 13, 2023 06:47
@coveralls
Copy link

coveralls commented Jul 13, 2023

Pull Request Test Coverage Report for Build 5846291654

  • 42 of 42 (100.0%) changed or added relevant lines in 2 files are covered.
  • 22 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.01%) to 87.246%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 93.76%
qiskit/pulse/library/waveform.py 3 93.75%
crates/qasm2/src/lex.rs 6 90.38%
crates/qasm2/src/parse.rs 12 96.67%
Totals Coverage Status
Change from base Build 5837476817: -0.01%
Covered Lines: 74322
Relevant Lines: 85187

💛 - Coveralls

@mtreinish mtreinish modified the milestones: 0.25.0, 0.45.0 Jul 13, 2023
@mtreinish mtreinish added the Changelog: New Feature Include in the "Added" section of the changelog label Jul 25, 2023
@ShellyGarion ShellyGarion self-assigned this Aug 8, 2023
Copy link
Member

@ShellyGarion ShellyGarion left a comment

Choose a reason for hiding this comment

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

This PR is well-written and will be a good contribution to Qiskit.

I only have a minor comment, in this PR it is worth to update the test from PR #10053:
https://github.com/Qiskit/qiskit-terra/blob/06416d7ee75500c50cfddc67574421cf73913f8a/test/python/circuit/library/test_linear_function.py#L489
(I checked the code and it should work now)

@alexanderivrii
Copy link
Contributor Author

Thanks @ShellyGarion, good catch! I have updated the test in 7cb3a4f.

Copy link
Contributor

@ikkoham ikkoham left a comment

Choose a reason for hiding this comment

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

LGTM. TBH, I'm a little concerned about the cyclic import, but that's due to the original design.

@ikkoham ikkoham added this pull request to the merge queue Aug 16, 2023
Merged via the queue into Qiskit:main with commit 3fcd145 Aug 16, 2023
SamD-1998 pushed a commit to SamD-1998/qiskit-terra that referenced this pull request Sep 7, 2023
…iskit#10423)

* constructing cliffords from linear functions and permutation gates

* updating test
@alexanderivrii alexanderivrii deleted the cliffords-from-linear-and-perms branch October 23, 2023 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the "Added" section of the changelog mod: quantum info Related to the Quantum Info module (States & Operators)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants