Circuit Synthesis (qiskit.synthesis
)#
Evolution Synthesis#
Interface for evolution synthesis algorithms. |
|
|
Product formula base class for the decomposition of non-commuting operator exponentials. |
|
The Lie-Trotter product formula. |
|
The (higher order) Suzuki-Trotter product formula. |
Exact operator evolution via matrix exponentiation and unitary synthesis. |
|
|
The QDrift Trotterization method, which selects each each term in the Trotterization randomly, with a probability proportional to its weight. |
Linear Function Synthesis#
- qiskit.synthesis.synth_cnot_count_full_pmh(state, section_size=2)[código fonte]#
Synthesize linear reversible circuits for all-to-all architecture using Patel, Markov and Hayes method.
This function is an implementation of the Patel, Markov and Hayes algorithm from [1] for optimal synthesis of linear reversible circuits for all-to-all architecture, as specified by an n x n matrix.
- Parâmetros:
- Retorno:
a CX-only circuit implementing the linear transformation.
- Tipo de retorno:
- Levanta:
QiskitError – when variable «state» isn’t of type numpy.ndarray
References
Patel, Ketan N., Igor L. Markov, and John P. Hayes, Optimal synthesis of linear reversible circuits, Quantum Information & Computation 8.3 (2008): 282-294. arXiv:quant-ph/0302002 [quant-ph]
- qiskit.synthesis.synth_cnot_depth_line_kms(mat)[código fonte]#
Synthesize linear reversible circuit for linear nearest-neighbor architectures using Kutin, Moulton, Smithline method.
Synthesis algorithm for linear reversible circuits from [1], Chapter 7. Synthesizes any linear reversible circuit of n qubits over linear nearest-neighbor architecture using CX gates with depth at most 5*n.
- Parâmetros:
mat (np.ndarray]) – A boolean invertible matrix.
- Retorno:
the synthesized quantum circuit.
- Tipo de retorno:
- Levanta:
QiskitError – if mat is not invertible.
References
Kutin, S., Moulton, D. P., Smithline, L., Computation at a distance, Chicago J. Theor. Comput. Sci., vol. 2007, (2007), arXiv:quant-ph/0701194
Linear-Phase Synthesis#
- qiskit.synthesis.synth_cz_depth_line_mr(mat)[código fonte]#
Synthesis of a CZ circuit for linear nearest neighbour (LNN) connectivity, based on Maslov and Roetteler.
Note that this method reverts the order of qubits in the circuit, and returns a circuit containing CX and phase (S, Sdg or Z) gates.
- Parâmetros:
mat (ndarray) – an upper-diagonal matrix representing the CZ circuit. mat[i][j]=1 for i<j represents a CZ(i,j) gate
- Retorno:
a circuit implementation of the CZ circuit of depth 2*n+2 for LNN connectivity.
- Tipo de retorno:
- Reference:
Dmitri Maslov, Martin Roetteler, Shorter stabilizer circuits via Bruhat decomposition and quantum circuit transformations, arXiv:1705.09176.
- qiskit.synthesis.synth_cx_cz_depth_line_my(mat_x, mat_z)[código fonte]#
Joint synthesis of a -CZ-CX- circuit for linear nearest neighbour (LNN) connectivity, with 2-qubit depth at most 5n, based on Maslov and Yang. This method computes the CZ circuit inside the CX circuit via phase gate insertions.
- Parâmetros:
- Retorno:
a circuit implementation of a CX circuit following a CZ circuit, denoted as a -CZ-CX- circuit,in two-qubit depth at most 5n, for LNN connectivity.
- Tipo de retorno:
- Reference:
Kutin, S., Moulton, D. P., Smithline, L., Computation at a distance, Chicago J. Theor. Comput. Sci., vol. 2007, (2007), arXiv:quant-ph/0701194
Dmitri Maslov, Willers Yang, CNOT circuits need little help to implement arbitrary Hadamard-free Clifford transformations they generate, arXiv:2210.16195.
Permutation Synthesis#
- qiskit.synthesis.synth_permutation_depth_lnn_kms(pattern)[código fonte]#
Synthesize a permutation circuit for a linear nearest-neighbor architecture using the Kutin, Moulton, Smithline method.
This is the permutation synthesis algorithm from https://arxiv.org/abs/quant-ph/0701194, Chapter 6. It synthesizes any permutation of n qubits over linear nearest-neighbor architecture using SWAP gates with depth at most n and size at most n(n-1)/2 (where both depth and size are measured with respect to SWAPs).
- Parâmetros:
pattern (Union[list[int], np.ndarray]) – permutation pattern, describing which qubits occupy the positions 0, 1, 2, etc. after applying the permutation. That is,
pattern[k] = m
when the permutation maps qubitm
to positionk
. As an example, the pattern[2, 4, 3, 0, 1]
means that qubit2
goes to position0
, qubit4
goes to position1
, etc.- Retorno:
the synthesized quantum circuit.
- Tipo de retorno:
- qiskit.synthesis.synth_permutation_basic(pattern)[código fonte]#
Synthesize a permutation circuit for a fully-connected architecture using sorting.
More precisely, if the input permutation is a cycle of length
m
, then this creates a quantum circuit withm-1
SWAPs (and of depthm-1
); if the input permutation consists of several disjoint cycles, then each cycle is essentially treated independently.- Parâmetros:
pattern (Union[list[int], np.ndarray]) – permutation pattern, describing which qubits occupy the positions 0, 1, 2, etc. after applying the permutation. That is,
pattern[k] = m
when the permutation maps qubitm
to positionk
. As an example, the pattern[2, 4, 3, 0, 1]
means that qubit2
goes to position0
, qubit4
goes to position1
, etc.- Retorno:
the synthesized quantum circuit.
- Tipo de retorno:
- qiskit.synthesis.synth_permutation_acg(pattern)[código fonte]#
Synthesize a permutation circuit for a fully-connected architecture using the Alon, Chung, Graham method.
This produces a quantum circuit of depth 2 (measured in the number of SWAPs).
This implementation is based on the Theorem 2 in the paper «Routing Permutations on Graphs Via Matchings» (1993), available at https://www.cs.tau.ac.il/~nogaa/PDFS/r.pdf.
- Parâmetros:
pattern (Union[list[int], np.ndarray]) – permutation pattern, describing which qubits occupy the positions 0, 1, 2, etc. after applying the permutation. That is,
pattern[k] = m
when the permutation maps qubitm
to positionk
. As an example, the pattern[2, 4, 3, 0, 1]
means that qubit2
goes to position0
, qubit4
goes to position1
, etc.- Retorno:
the synthesized quantum circuit.
- Tipo de retorno:
Clifford Synthesis#
- qiskit.synthesis.synth_clifford_full(clifford, method=None)[código fonte]#
Decompose a Clifford operator into a QuantumCircuit.
For N <= 3 qubits this is based on optimal CX cost decomposition from reference [1]. For N > 3 qubits this is done using the general non-optimal greedy compilation routine from reference [3], which typically yields better CX cost compared to the AG method in [2].
- Parâmetros:
- Retorno:
a circuit implementation of the Clifford.
- Tipo de retorno:
References
S. Bravyi, D. Maslov, Hadamard-free circuits expose the structure of the Clifford group, arXiv:2003.09412 [quant-ph]
S. Aaronson, D. Gottesman, Improved Simulation of Stabilizer Circuits, Phys. Rev. A 70, 052328 (2004). arXiv:quant-ph/0406196
Sergey Bravyi, Shaohan Hu, Dmitri Maslov, Ruslan Shaydulin, Clifford Circuit Optimization with Templates and Symbolic Pauli Gates, arXiv:2105.02291 [quant-ph]
- qiskit.synthesis.synth_clifford_ag(clifford)[código fonte]#
Decompose a Clifford operator into a QuantumCircuit based on Aaronson-Gottesman method.
- Parâmetros:
clifford (Clifford) – a clifford operator.
- Retorno:
a circuit implementation of the Clifford.
- Tipo de retorno:
- Reference:
S. Aaronson, D. Gottesman, Improved Simulation of Stabilizer Circuits, Phys. Rev. A 70, 052328 (2004). arXiv:quant-ph/0406196
- qiskit.synthesis.synth_clifford_bm(clifford)[código fonte]#
Optimal CX-cost decomposition of a Clifford operator on 2-qubits or 3-qubits into a QuantumCircuit based on Bravyi-Maslov method.
- Parâmetros:
clifford (Clifford) – a clifford operator.
- Retorno:
a circuit implementation of the Clifford.
- Tipo de retorno:
- Levanta:
QiskitError – if clifford is on more than 3 qubits.
- Reference:
S. Bravyi, D. Maslov, Hadamard-free circuits expose the structure of the Clifford group, arXiv:2003.09412 [quant-ph]
- qiskit.synthesis.synth_clifford_greedy(clifford)[código fonte]#
Decompose a Clifford operator into a QuantumCircuit based on the greedy Clifford compiler that is described in Appendix A of Bravyi, Hu, Maslov and Shaydulin.
This method typically yields better CX cost compared to the Aaronson-Gottesman method.
- Parâmetros:
clifford (Clifford) – a clifford operator.
- Retorno:
a circuit implementation of the Clifford.
- Tipo de retorno:
- Levanta:
QiskitError – if symplectic Gaussian elimination fails.
- Reference:
Sergey Bravyi, Shaohan Hu, Dmitri Maslov, Ruslan Shaydulin, Clifford Circuit Optimization with Templates and Symbolic Pauli Gates, arXiv:2105.02291 [quant-ph]
- qiskit.synthesis.synth_clifford_layers(cliff, cx_synth_func=<function _default_cx_synth_func>, cz_synth_func=<function _default_cz_synth_func>, cx_cz_synth_func=None, cz_func_reverse_qubits=False, validate=False)[código fonte]#
Synthesis of a Clifford into layers, it provides a similar decomposition to the synthesis described in Lemma 8 of Bravyi and Maslov.
For example, a 5-qubit Clifford circuit is decomposed into the following layers:
┌─────┐┌─────┐┌────────┐┌─────┐┌─────┐┌─────┐┌─────┐┌────────┐ q_0: ┤0 ├┤0 ├┤0 ├┤0 ├┤0 ├┤0 ├┤0 ├┤0 ├ │ ││ ││ ││ ││ ││ ││ ││ │ q_1: ┤1 ├┤1 ├┤1 ├┤1 ├┤1 ├┤1 ├┤1 ├┤1 ├ │ ││ ││ ││ ││ ││ ││ ││ │ q_2: ┤2 S2 ├┤2 CZ ├┤2 CX_dg ├┤2 H2 ├┤2 S1 ├┤2 CZ ├┤2 H1 ├┤2 Pauli ├ │ ││ ││ ││ ││ ││ ││ ││ │ q_3: ┤3 ├┤3 ├┤3 ├┤3 ├┤3 ├┤3 ├┤3 ├┤3 ├ │ ││ ││ ││ ││ ││ ││ ││ │ q_4: ┤4 ├┤4 ├┤4 ├┤4 ├┤4 ├┤4 ├┤4 ├┤4 ├ └─────┘└─────┘└────────┘└─────┘└─────┘└─────┘└─────┘└────────┘
This decomposition is for the default cz_synth_func and cx_synth_func functions, with other functions one may see slightly different decomposition.
- Parâmetros:
cliff (Clifford) – a clifford operator.
cx_synth_func (Callable) – a function to decompose the CX sub-circuit. It gets as input a boolean invertible matrix, and outputs a QuantumCircuit.
cz_synth_func (Callable) – a function to decompose the CZ sub-circuit. It gets as input a boolean symmetric matrix, and outputs a QuantumCircuit.
cx_cz_synth_func (Callable) – optional, a function to decompose both sub-circuits CZ and CX.
validate (Boolean) – if True, validates the synthesis process.
cz_func_reverse_qubits (Boolean) – True only if cz_synth_func is synth_cz_depth_line_mr, since this function returns a circuit that reverts the order of qubits.
- Retorno:
a circuit implementation of the Clifford.
- Tipo de retorno:
- Reference:
S. Bravyi, D. Maslov, Hadamard-free circuits expose the structure of the Clifford group, arXiv:2003.09412 [quant-ph]
- qiskit.synthesis.synth_clifford_depth_lnn(cliff)[código fonte]#
Synthesis of a Clifford into layers for linear-nearest neighbour connectivity.
The depth of the synthesized n-qubit circuit is bounded by 7*n+2, which is not optimal. It should be replaced by a better algorithm that provides depth bounded by 7*n-4 [3].
- Parâmetros:
cliff (Clifford) – a clifford operator.
- Retorno:
a circuit implementation of the Clifford.
- Tipo de retorno:
- Reference:
S. Bravyi, D. Maslov, Hadamard-free circuits expose the structure of the Clifford group, arXiv:2003.09412 [quant-ph]
Dmitri Maslov, Martin Roetteler, Shorter stabilizer circuits via Bruhat decomposition and quantum circuit transformations, arXiv:1705.09176.
Dmitri Maslov, Willers Yang, CNOT circuits need little help to implement arbitrary Hadamard-free Clifford transformations they generate, arXiv:2210.16195.
CNOTDihedral Synthesis#
- qiskit.synthesis.synth_cnotdihedral_full(elem)[código fonte]#
Decompose a CNOTDihedral element into a QuantumCircuit. For N <= 2 qubits this is based on optimal CX cost decomposition from reference [1]. For N > 2 qubits this is done using the general non-optimal compilation routine from reference [2].
- Parâmetros:
elem (CNOTDihedral) – a CNOTDihedral element.
- Retorno:
a circuit implementation of the CNOTDihedral element.
- Tipo de retorno:
References
Shelly Garion and Andrew W. Cross, Synthesis of CNOT-Dihedral circuits with optimal number of two qubit gates, Quantum 4(369), 2020
Andrew W. Cross, Easwar Magesan, Lev S. Bishop, John A. Smolin and Jay M. Gambetta, Scalable randomised benchmarking of non-Clifford gates, npj Quantum Inf 2, 16012 (2016).
- qiskit.synthesis.synth_cnotdihedral_two_qubits(elem)[código fonte]#
Decompose a CNOTDihedral element on a single qubit and two qubits into a QuantumCircuit. This decomposition has an optimal number of CX gates.
- Parâmetros:
elem (CNOTDihedral) – a CNOTDihedral element.
- Retorno:
a circuit implementation of the CNOTDihedral element.
- Tipo de retorno:
- Levanta:
QiskitError – if the element in not 1-qubit or 2-qubit CNOTDihedral.
- Reference:
Shelly Garion and Andrew W. Cross, On the structure of the CNOT-Dihedral group, arXiv:2006.12042 [quant-ph]
- qiskit.synthesis.synth_cnotdihedral_general(elem)[código fonte]#
Decompose a CNOTDihedral element into a QuantumCircuit.
Decompose a general CNOTDihedral elements. The number of CNOT gates is not necessarily optimal. For a decomposition of a 1-qubit or 2-qubit element, call synth_cnotdihedral_two_qubits.
- Parâmetros:
elem (CNOTDihedral) – a CNOTDihedral element.
- Retorno:
a circuit implementation of the CNOTDihedral element.
- Tipo de retorno:
- Levanta:
QiskitError – if the element could not be decomposed into a circuit.
- Reference:
Andrew W. Cross, Easwar Magesan, Lev S. Bishop, John A. Smolin and Jay M. Gambetta, Scalable randomised benchmarking of non-Clifford gates, npj Quantum Inf 2, 16012 (2016).
Stabilizer State Synthesis#
- qiskit.synthesis.synth_stabilizer_layers(stab, cz_synth_func=<function _default_cz_synth_func>, cz_func_reverse_qubits=False, validate=False)[código fonte]#
Synthesis of a stabilizer state into layers.
It provides a similar decomposition to the synthesis described in Lemma 8 of Bravyi and Maslov, without the initial Hadamard-free sub-circuit which do not affect the stabilizer state.
For example, a 5-qubit stabilizer state is decomposed into the following layers:
┌─────┐┌─────┐┌─────┐┌─────┐┌────────┐ q_0: ┤0 ├┤0 ├┤0 ├┤0 ├┤0 ├ │ ││ ││ ││ ││ │ q_1: ┤1 ├┤1 ├┤1 ├┤1 ├┤1 ├ │ ││ ││ ││ ││ │ q_2: ┤2 H2 ├┤2 S1 ├┤2 CZ ├┤2 H1 ├┤2 Pauli ├ │ ││ ││ ││ ││ │ q_3: ┤3 ├┤3 ├┤3 ├┤3 ├┤3 ├ │ ││ ││ ││ ││ │ q_4: ┤4 ├┤4 ├┤4 ├┤4 ├┤4 ├ └─────┘└─────┘└─────┘└─────┘└────────┘
- Parâmetros:
stab (StabilizerState) – a stabilizer state.
cz_synth_func (Callable) – a function to decompose the CZ sub-circuit. It gets as input a boolean symmetric matrix, and outputs a QuantumCircuit.
validate (Boolean) – if True, validates the synthesis process.
cz_func_reverse_qubits (Boolean) – True only if cz_synth_func is synth_cz_depth_line_mr, since this function returns a circuit that reverts the order of qubits.
- Retorno:
a circuit implementation of the stabilizer state.
- Tipo de retorno:
- Levanta:
QiskitError – if the input is not a StabilizerState.
- Reference:
S. Bravyi, D. Maslov, Hadamard-free circuits expose the structure of the Clifford group, arXiv:2003.09412 [quant-ph]
- qiskit.synthesis.synth_stabilizer_depth_lnn(stab)[código fonte]#
Synthesis of an n-qubit stabilizer state for linear-nearest neighbour connectivity, in 2-qubit depth 2*n+2 and two distinct CX layers, using CX and phase gates (S, Sdg or Z).
- Parâmetros:
stab (StabilizerState) – a stabilizer state.
- Retorno:
a circuit implementation of the stabilizer state.
- Tipo de retorno:
- Reference:
S. Bravyi, D. Maslov, Hadamard-free circuits expose the structure of the Clifford group, arXiv:2003.09412 [quant-ph]
Dmitri Maslov, Martin Roetteler, Shorter stabilizer circuits via Bruhat decomposition and quantum circuit transformations, arXiv:1705.09176.
Discrete Basis Synthesis#
|
The Solovay Kitaev discrete decomposition algorithm. |
- qiskit.synthesis.generate_basic_approximations(basis_gates, depth, filename=None)[código fonte]#
Generates a list of
GateSequence``s with the gates in ``basic_gates
.- Parâmetros:
- Retorno:
List of
GateSequences
using the gates inbasic_gates
.- Levanta:
ValueError – If
basis_gates
contains an invalid gate identifier.- Tipo de retorno:
list[GateSequence]