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 Clifford operator class #3938

Merged
merged 18 commits into from
Apr 2, 2020
Merged

Conversation

chriseclectic
Copy link
Member

@chriseclectic chriseclectic commented Mar 6, 2020

Summary

  • Start of a Clifford operator class based on the StabilizerTable class for its internal data structure.

  • Adds clifford_utils file that contains helper functions for directly updating a Clifford object with standard 1 and 2 qubit Clifford basis gates.

TODO

Implement the methods of the BaseOperator API directly as vectorized table update methods on the StabilizerTable and add unit tests.

  • Implement compose
  • Implement tensor / expand
  • Implement conjugate
  • Implement transpose
  • Implement is_unitary
  • Implement to_matrix
  • Implement to_operator
  • Add tests for Clifford class
  • Add documentation to Clifford class

# Clifford array.

# Condition is
# table.T * [[0, 1], [1, 0]] * table = [[0, 1], [1, 0]]
Copy link
Member

@ShellyGarion ShellyGarion Mar 12, 2020

Choose a reason for hiding this comment

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

this actually checks that the clifford table is a symplectic matrix, so perhaps this method should be called 'is_symplectic' or 'is_clifford' (and not 'is_unitary')?

@chriseclectic chriseclectic added the on hold Can not fix yet label Mar 18, 2020
@chriseclectic chriseclectic removed the on hold Can not fix yet label Mar 29, 2020
@chriseclectic chriseclectic added this to the 0.13 milestone Mar 31, 2020
@chriseclectic chriseclectic changed the title [WIP] Add Clifford operator class Add Clifford operator class Mar 31, 2020
chriseclectic and others added 8 commits March 31, 2020 14:15
Co-Authored-By: Christopher J. Wood <cjwood@us.ibm.com>
* Added `to_circuit` method
* Added `to_gate` method
* Added `to_matrix` method
* Added `to_operator`
* 1 and two qubit clifford gates
* compose, dot, tensor, expand, conjugate, transopse, is_unitary, to_operator

Co-Authored-By: Christopher J. Wood <cjwood@us.ibm.com>
Co-Authored-By: Shelly Garion <shellygarion@users.noreply.github.com>
test_clifford_gates -> test_clifford
clifford_append_gate -> clifford_circuits
Fix n_qubits -> num_qubits
Fix tensor order bug
Fix append 2-qubit gate tests
Speed up compose
Fix qubit order issue with subsystem compose
Add check that table is valid on clifford __init__
@ShellyGarion
Copy link
Member

There are a few basic methods that were not tested:
to_dict, from_dict, to_matrix, to_instruction, from_instruction.

@chriseclectic
Copy link
Member Author

@ShellyGarion I've added some tests for the methods you mentioned

ShellyGarion
ShellyGarion previously approved these changes Apr 1, 2020
return self.to_circuit().to_gate()

@staticmethod
def from_instruction(instruction):
Copy link
Member

Choose a reason for hiding this comment

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

I'd call this from_circuit to be consistent with (future!) plans to unify things under the banner of circuits.

Copy link
Member

Choose a reason for hiding this comment

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

also there are probably other instances of this function in other parts of quantum_info. they should all just talk about converting to/from that object and circuits. One side is simulation and the other is synthesis.

Copy link
Member Author

@chriseclectic chriseclectic Apr 1, 2020

Choose a reason for hiding this comment

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

Most of the operators / states have a from instruction that I could change to from_circuit. Will have to add deprecation warnings to from_instruction for Statevector and DensityMatrix. It might be easier to change them all in a single PR after this is merged.

Copy link
Member

@ajavadia ajavadia left a comment

Choose a reason for hiding this comment

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

thanks for addressing the comments, looks good

@ajavadia ajavadia merged commit 48e3699 into Qiskit:master Apr 2, 2020
@chriseclectic chriseclectic added the Changelog: New Feature Include in the "Added" section of the changelog label Apr 2, 2020
@chriseclectic chriseclectic deleted the symplectic/clifford branch April 15, 2020 14:49
faisaldebouni pushed a commit to faisaldebouni/qiskit-terra that referenced this pull request Aug 5, 2020
* Add Clifford operator class

* Add compose, tensor, expand, and is_unitary

Co-Authored-By: Christopher J. Wood <cjwood@us.ibm.com>

* Add tests

* 1 and two qubit clifford gates
* compose, dot, tensor, expand, conjugate, transopse, is_unitary, to_operator

Co-Authored-By: Christopher J. Wood <cjwood@us.ibm.com>
Co-Authored-By: Shelly Garion <shellygarion@users.noreply.github.com>

* Add clifford conversion methods based on circuit decomposition

* Added `to_circuit` method
* Added `to_gate` method
* Added `to_matrix` method
* Added `to_operator`

* Rename files and fix bugs

test_clifford_gates -> test_clifford
clifford_append_gate -> clifford_circuits
Fix n_qubits -> num_qubits
Fix tensor order bug
Fix append 2-qubit gate tests
Speed up compose
Fix qubit order issue with subsystem compose
Add check that table is valid on clifford __init__

* Add adjoint and conjugate

* add tests for compose and dot of subsystems, and for to_circuit

* Add Clifford class docs and reno

* Linting and doc fox

* Review comments

* Add tests for to_matrix, to_instruction

* Add to_dict/from_dict tests

* Add underscore to private clifford funcs

* Rename `append_gate` to `_append_circuit`

* Rename from_instruction to from_circuit

* lint

* move decompose_clifford  to synethsis

Co-authored-by: sethmerkel <49210444+sethmerkel@users.noreply.github.com>
Co-authored-by: Shelly Garion <46566946+ShellyGarion@users.noreply.github.com>
Co-authored-by: Shelly Garion <shellygarion@users.noreply.github.com>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants