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 gates to collect_cliffords #12750

Merged
merged 6 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions qiskit/circuit/random/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from qiskit.circuit import Reset
from qiskit.circuit.library import standard_gates
from qiskit.circuit.exceptions import CircuitError
from qiskit.quantum_info.operators.symplectic.clifford_circuits import _BASIS_1Q, _BASIS_2Q


def random_circuit(
Expand Down Expand Up @@ -312,8 +313,9 @@ def random_clifford_circuit(num_qubits, num_gates, gates="all", seed=None):
QuantumCircuit: constructed circuit
"""

gates_1q = ["i", "x", "y", "z", "h", "s", "sdg", "sx", "sxdg"]
gates_2q = ["cx", "cz", "cy", "swap", "iswap", "ecr", "dcx"]
gates_1q = list(set(_BASIS_1Q.keys()) - {"v", "w", "id", "iden", "sinv"})
gates_2q = list(_BASIS_2Q.keys())

if gates == "all":
if num_qubits == 1:
gates = gates_1q
Expand Down
21 changes: 6 additions & 15 deletions qiskit/transpiler/passes/optimization/collect_cliffords.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
)

from qiskit.quantum_info.operators import Clifford
from qiskit.quantum_info.operators.symplectic.clifford_circuits import _BASIS_1Q, _BASIS_2Q


class CollectCliffords(CollectAndCollapse):
Expand Down Expand Up @@ -69,21 +70,11 @@ def __init__(
)


clifford_gate_names = [
"x",
"y",
"z",
"h",
"s",
"sdg",
"cx",
"cy",
"cz",
"swap",
"clifford",
"linear_function",
"pauli",
]
clifford_gate_names = (
list(_BASIS_1Q.keys())
+ list(_BASIS_2Q.keys())
+ ["clifford", "linear_function", "pauli", "permutation"]
)


def _is_clifford_gate(node):
Expand Down
6 changes: 6 additions & 0 deletions releasenotes/notes/fix-collect-clifford-83af26d98b8c69e8.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
Add more Clifford gates to the :class:`.CollectCliffords()` transpiler pass.
In particular, we have added the gates :class:`ECRGate()`, :class:`DCXGate()`,
:class:`iSWAPGate()`, :class:`SXGate()` and :class:`SXdgGate()` to this transpiler pass.
Loading