-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
clifford_decompose_greedy.py
57 lines (46 loc) · 2.08 KB
/
clifford_decompose_greedy.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
48
49
50
51
52
53
54
55
56
57
# 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 the Clifford class.
"""
# ---------------------------------------------------------------------
# Synthesis based on Bravyi et. al. greedy clifford compiler
# ---------------------------------------------------------------------
from qiskit.circuit import QuantumCircuit
from qiskit.quantum_info import Clifford
from qiskit._accelerate.synthesis.clifford import (
synth_clifford_greedy as synth_clifford_greedy_inner,
)
def synth_clifford_greedy(clifford: Clifford) -> QuantumCircuit:
"""Decompose a :class:`.Clifford` operator into a :class:`.QuantumCircuit` based
on the greedy Clifford compiler that is described in Appendix A of
Bravyi, Hu, Maslov and Shaydulin [1].
This method typically yields better CX cost compared to the Aaronson-Gottesman method.
Note that this function only implements the greedy Clifford compiler from Appendix A
of [1], and not the templates and symbolic Pauli gates optimizations
that are mentioned in the same paper.
Args:
clifford: A Clifford operator.
Returns:
A circuit implementation of the Clifford.
Raises:
QiskitError: if symplectic Gaussian elimination fails.
References:
1. Sergey Bravyi, Shaohan Hu, Dmitri Maslov, Ruslan Shaydulin,
*Clifford Circuit Optimization with Templates and Symbolic Pauli Gates*,
`arXiv:2105.02291 [quant-ph] <https://arxiv.org/abs/2105.02291>`_
"""
circuit = QuantumCircuit._from_circuit_data(
synth_clifford_greedy_inner(clifford.tableau.astype(bool)), add_regs=True
)
circuit.name = str(clifford)
return circuit