tket
Loading...
Searching...
No Matches
Decomposition.hpp
Go to the documentation of this file.
1// Copyright Quantinuum
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include "Transform.hpp"
19
20namespace tket {
21
22namespace Transforms {
23
33
43
48
52Transform decompose_ZYZ_to_TK1();
53
57Transform decompose_ZXZ_to_TK1();
58
59// converts all single-qubit gates into Rz and Rx gates
60// Expects: any gates
61// Produces: Rz, Rx and any multi-qubit gates
62Transform decompose_ZX();
63
64// converts all single-qubit gates into Rz and Ry gates
65// Expects: any gates
66// Produces: Rz, Ry and any multi-qubit gates
67Transform decompose_ZY();
68
69// converts all single-qubit gates into Rx and Ry gates
70// Expects: any gates
71// Produces: Rx, Ry and any multi-qubit gates
72Transform decompose_XY();
73
74// converts all TK1-gates into rzrx gates
75// Expects: TK1-gates and any multi-qubit gates
76// Produces: Rz, Rx and any multi-qubit gates
77Transform decompose_tk1_to_rzrx();
78
79// replaces CXs with ZZMax
80// Expects: CX and any single-qubit gates
81// Produces: ZZMax and any single-qubit gates
82Transform decompose_CX_to_HQS2();
83
84// replaces Rz-Rx-Rz triples with Rz-PhasedX pairs
85// Expects: Rz, Rx, and any multi-qubit gates
86// Produces: Rz, PhasedX, and any multi-qubit gates
87Transform decompose_ZX_to_HQS1();
88
89// converts all CX gates into Molmer-Sorensen gates by recognising exp(-i XX *
90// angle * pi/2) and converting rest to exp(-i XX * pi/4) Expects: CX, Rx, and
91// other single-qubit gates Produces: Molmer-Sorensen, U2, and other
92// single-qubit gates
93Transform decompose_MolmerSorensen();
94
123Transform decompose_TK2(const TwoQbFidelities& fid, bool allow_swaps = true);
124Transform decompose_TK2(bool allow_swaps = true);
125
131Transform decompose_ZZPhase();
132
142Transform decompose_cliffords_std(bool tk2_to_cx = true);
143
144Transform decompose_ZX_to_cliffords();
145
146// converts all valid CX-Rz-CX strings and CX-Rx-CX strings to 2qb
147// PhaseGadgets Expects: CX, Rz, Rx and any other single-qubit gates Produces:
148// PhaseGadgets, and any other gates
149Transform decompose_PhaseGadgets();
150
160Transform decomp_boxes(
161 const std::unordered_set<OpType>& excluded_types = {},
162 const std::unordered_set<std::string>& excluded_opgroups = {},
163 const std::optional<std::unordered_set<OpType>>& included_types =
164 std::nullopt,
165 const std::optional<std::unordered_set<std::string>>& included_opgroups =
166 std::nullopt);
167
176Transform compose_phase_poly_boxes(unsigned min_size = 0);
177
178// converts all SWAP gates to given replacement circuit (not checked to
179// preserve unitary) Expects: SWAP gates, replacement circuit Produces:
180// Instances of the replacement circuit,
181Transform decompose_SWAP(const Circuit& replacement_circuit);
182
183// converts all SWAP gates to 3 CX gates
184// providing an Architecture will prefer an orientation that reduces H
185// redirection cost -X- -C-X-C- -X-C-X-
186// | = | | | = | | |
187// -X- -X-C-X- -C-X-C-
188// Expects: SWAP gates
189// Produces: CX gates
190Transform decompose_SWAP_to_CX(const Architecture& arc = Architecture());
191
192// converts all BRIDGE (distance 2 CX) gates to 4 CX gates
193// -B- -C- -C---C--- ---C---C-
194// R | | | | |
195// -I- = --- = -X-C-X-C- = -C-X-C-X-
196// D | | | | |
197// -G- -X- ---X---X- -X---X---
198// E
199// Expects: BRIDGE gates
200// Produces: CX gates
201Transform decompose_BRIDGE_to_CX();
202
203// converts -C- gates to -H-X-H- depending on direction of Architecture edges
204// | |
205// -X- -H-C-H-
206// Expects: CX gates
207// Produces CX and H gates
208Transform decompose_CX_directed(const Architecture& arc);
209
213Transform decompose_NPhasedX();
214
215// does not use ancillae
216// Expects: CCX + any other gates
217// returns CX, H, T, Tdg + any previous gates
218Transform decomp_CCX();
219
220// converts arbitrarily controlled Ry gates. It does not use ancillae, so it
221// is not very depth-efficient Expects: CRys and any other gates returns Ry,
222// CX, H, T, Tdg + whatever other gates were there before
223Transform decomp_controlled_Rys();
224
225// does not use ancillae
226// Expects: CCX, CnX, CnY, CnZ, CnRy, CnRx, CnRz, and any other gates
227// returns CX and single-qubit gate + any previous gates
229
230// For every two CnX gates, we try to reorder their control qubits
231// and adjust the direction of their decomposition (i.e. CnX = CnX.dagger)
232// to improve the chance of gate cancellation. This method will not improve
233// the decomposition when the CnX gates are scattered; but it works the best
234// when CnX gates are very close to each other.
236
237} // namespace Transforms
238
239} // namespace tket
Transform compose_phase_poly_boxes(const unsigned min_size)
Replaces all CX+Rz sub circuits by PhasePolyBox Expects: only CX + Rz + H (and measure + reset + coll...
Transform decompose_TK2(bool allow_swaps)
Transform decompose_ZX()
Transform decompose_single_qubits_TK1()
Decomposes all single-qubit unitary gates into TK1 gates.
Transform decompose_ZX_to_HQS1()
Transform decompose_multi_qubits_CX()
Decomposes all multi-qubit unitary gates into CX and single-qubit gates.
Transform decompose_cliffords_std(bool tk2_to_cx)
Decompose single-qubit Clifford gates to a standard Cliffford gate set.
Transform decompose_ZZPhase()
Synthesise ZZPhase gates from CX and Rz, as well as XX/YYPhase.
Transform decomp_boxes(const std::unordered_set< OpType > &excluded_types, const std::unordered_set< std::string > &excluded_opgroups, const std::optional< std::unordered_set< OpType > > &included_types, const std::optional< std::unordered_set< std::string > > &included_opgroups)
Recursively replaces all boxes by their decomposition using Box::to_circuit Expects: any gateset.
Transform decomp_arbitrary_controlled_gates()
Transform decompose_multi_qubits_TK2()
Decomposes all multi-qubit unitary gates into TK2 and single-qubit gates.
Transform decompose_PhaseGadgets()
Transform decompose_CX_to_HQS2()
Transform decompose_NPhasedX()
Decompose NPhasedX gates into single-qubit PhasedX gates.
Transform decomp_controlled_Rys()
Transform decompose_SWAP(const Circuit &replacement_circuit)
Transform decompose_SWAP_to_CX(const Architecture &arc)
Transform decompose_CX_directed(const Architecture &arc)
Transform decompose_ZXZ_to_TK1()
Starting with Rz, Rx and multi-qubit gates, replace all singles with TK1.
Transform decompose_XY()
Transform cnx_pairwise_decomposition()
Transform decompose_tk1_to_rzrx()
Transform decompose_ZY()
Transform decompose_BRIDGE_to_CX()
Transform decompose_ZX_to_cliffords()
Transform decompose_MolmerSorensen()
Transform decompose_ZYZ_to_TK1()
Starting with Rz, Ry and multi-qubit gates, replace all singles with TK1.
Defines tket::DeviceCharacterisation, used in NoiseAwarePlacement and in commute_SQ_gates_through_SWA...
Definition Path.cpp:22