diff --git a/qiskit/circuit/random/utils.py b/qiskit/circuit/random/utils.py index 3bcdbeaef4ac..5caba8ca2ae0 100644 --- a/qiskit/circuit/random/utils.py +++ b/qiskit/circuit/random/utils.py @@ -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( @@ -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 diff --git a/qiskit/transpiler/passes/optimization/collect_cliffords.py b/qiskit/transpiler/passes/optimization/collect_cliffords.py index c0e9641923cd..40acd21c6855 100644 --- a/qiskit/transpiler/passes/optimization/collect_cliffords.py +++ b/qiskit/transpiler/passes/optimization/collect_cliffords.py @@ -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): @@ -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): diff --git a/releasenotes/notes/fix-collect-clifford-83af26d98b8c69e8.yaml b/releasenotes/notes/fix-collect-clifford-83af26d98b8c69e8.yaml new file mode 100644 index 000000000000..48eac19acc9d --- /dev/null +++ b/releasenotes/notes/fix-collect-clifford-83af26d98b8c69e8.yaml @@ -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.