-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
clifford_decompose_bm.py
47 lines (39 loc) · 1.55 KB
/
clifford_decompose_bm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# This code is part of Qiskit.
#
# (C) Copyright IBM 2021, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
"""
Circuit synthesis for 2-qubit and 3-qubit Cliffords based on Bravyi & Maslov
decomposition.
"""
from qiskit.circuit import QuantumCircuit
from qiskit.quantum_info import Clifford
from qiskit._accelerate.synthesis.clifford import (
synth_clifford_bm as synth_clifford_bm_inner,
)
def synth_clifford_bm(clifford: Clifford) -> QuantumCircuit:
"""Optimal CX-cost decomposition of a :class:`.Clifford` operator on 2 qubits
or 3 qubits into a :class:`.QuantumCircuit` based on the Bravyi-Maslov method [1].
Args:
clifford: A Clifford operator.
Returns:
A circuit implementation of the Clifford.
Raises:
QiskitError: if Clifford is on more than 3 qubits.
References:
1. S. Bravyi, D. Maslov, *Hadamard-free circuits expose the
structure of the Clifford group*,
`arXiv:2003.09412 [quant-ph] <https://arxiv.org/abs/2003.09412>`_
"""
circuit = QuantumCircuit._from_circuit_data(
synth_clifford_bm_inner(clifford.tableau.astype(bool)), add_regs=True
)
circuit.name = str(clifford)
return circuit