tket
Loading...
Searching...
No Matches
PassLibrary.cpp
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
16
17#include <memory>
18#include <optional>
19
32#include "tket/ZX/Rewrite.hpp"
33
34namespace tket {
35
36template <typename T>
37static PassPtr gate_translation_pass(
38 const T &transform, OpTypeSet after_set, bool respect_connectivity,
39 const std::string &name) {
40 after_set.insert(OpType::Measure);
41 after_set.insert(OpType::Collapse);
42 after_set.insert(OpType::Reset);
43 after_set.insert(OpType::Phase);
44 PredicatePtrMap precons;
45 std::type_index ti = typeid(ConnectivityPredicate);
46 PredicatePtr out_gateset = std::make_shared<GateSetPredicate>(after_set);
47 PredicatePtr max2qb = std::make_shared<MaxTwoQubitGatesPredicate>();
48 PredicatePtrMap postcon_spec = {
51 PredicateClassGuarantees g_postcons;
52 if (!respect_connectivity)
53 g_postcons.insert({ti, Guarantee::Clear}); // synthesis passes do not in
54 // general preserve connectivity
55 PostConditions postcon{postcon_spec, g_postcons, Guarantee::Preserve};
56 // record pass config
57 nlohmann::json j;
58 j["name"] = name;
59 PassPtr ptr = std::make_shared<StandardPass>(precons, transform, postcon, j);
60 return ptr;
61}
62
64 static const PassPtr pp(gate_translation_pass(
66 "SynthesiseTK"));
67 return pp;
68}
70 static const PassPtr pp(gate_translation_pass(
72 "SynthesiseTket"));
73 return pp;
74}
76 static const PassPtr pp(gate_translation_pass(
78 "RebaseTket"));
79 return pp;
80}
81
83 static const PassPtr pp(gate_translation_pass(
85 "RebaseUFR"));
86 return pp;
87}
88
89const PassPtr &RxFromSX() {
90 static const PassPtr pp([]() {
91 Transform t{[](Circuit &circ) {
92 VertexVec verts_sx;
93 VertexVec verts_sxdg;
94 BGL_FORALL_VERTICES(v, circ.dag, DAG) {
95 OpType optype = circ.get_Op_ptr_from_Vertex(v)->get_type();
96 if (optype == OpType::SX) {
97 verts_sx.push_back(v);
98 } else if (optype == OpType::SXdg) {
99 verts_sxdg.push_back(v);
100 }
101 }
102 if (verts_sx.empty() && verts_sxdg.empty()) {
103 return false;
104 }
105 Circuit c_sx(1);
106 c_sx.add_op<unsigned>(OpType::Rx, 0.5, {0});
107 Circuit c_sxdg(1);
108 c_sxdg.add_op<unsigned>(OpType::Rx, -0.5, {0});
109 VertexList bin;
110 for (const Vertex &v : verts_sx) {
111 circ.substitute(c_sx, v, Circuit::VertexDeletion::No);
112 circ.add_phase(0.25);
113 bin.push_back(v);
114 }
115 for (const Vertex &v : verts_sxdg) {
116 circ.substitute(c_sxdg, v, Circuit::VertexDeletion::No);
117 circ.add_phase(-0.25);
118 bin.push_back(v);
119 }
120 circ.remove_vertices(
122 return true;
123 }};
124 PredicatePtrMap s_ps;
125 PredicateClassGuarantees g_postcons{
127 PostConditions postcon{s_ps, g_postcons, Guarantee::Preserve};
128 PredicatePtrMap precons;
129 // record pass config
130 nlohmann::json j;
131 j["name"] = "RxFromSX";
132 return std::make_shared<StandardPass>(precons, t, postcon, j);
133 }());
134 return pp;
135}
136
138 static const PassPtr pp([]() {
140 PostConditions postcon = {{}, {}, Guarantee::Preserve};
141 PredicatePtrMap precons;
142 // record pass config
143 nlohmann::json j;
144 j["name"] = "RemoveRedundancies";
145 return std::make_shared<StandardPass>(precons, t, postcon, j);
146 }());
147 return pp;
148}
149
151 static const PassPtr pp([]() {
153 PostConditions postcon = {{}, {}, Guarantee::Preserve};
154 PredicatePtrMap precons;
155 // record pass config
156 nlohmann::json j;
157 j["name"] = "CommuteThroughMultis";
158 return std::make_shared<StandardPass>(precons, t, postcon, j);
159 }());
160 return pp;
161}
162
164 static const PassPtr pp([]() {
166 PredicateClassGuarantees g_postcons = {
168 PostConditions postcon = {{}, g_postcons, Guarantee::Preserve};
169 PredicatePtrMap precons;
170 // record pass config
171 nlohmann::json j;
172 j["name"] = "DecomposeArbitrarilyControlledGates";
173 return std::make_shared<StandardPass>(precons, t, postcon, j);
174 }());
175 return pp;
176}
177
179 static const PassPtr pp([]() {
181 /* Spits out CX + any single qb gates */
182 OpTypeSet ots = {OpType::CX};
183 op_signature_t noargs = {};
185 ots.insert(all_projective_types().begin(), all_projective_types().end());
186 for (const std::pair<const OpType, OpTypeInfo> &ott : optypeinfo()) {
187 if (!ott.second.signature || *ott.second.signature == singleq ||
188 *ott.second.signature == noargs)
189 ots.insert(ott.first);
190 }
191 PredicatePtrMap precons;
192 PredicatePtr outp_gates = std::make_shared<GateSetPredicate>(ots);
193 PredicatePtr twoqbpred = std::make_shared<MaxTwoQubitGatesPredicate>();
194 PredicatePtrMap spec_postcons = {
197 PredicateClassGuarantees g_postcons;
198 PostConditions postcon{spec_postcons, g_postcons, Guarantee::Preserve};
199 // record pass config
200 nlohmann::json j;
201 j["name"] = "DecomposeMultiQubitsCX";
202 return std::make_shared<StandardPass>(precons, t, postcon, j);
203 }());
204 return pp;
205}
206
208 static const PassPtr pp([]() {
210 /* Spits out TK1 + any multi qb gates */
211 OpTypeSet ots = {OpType::TK1};
213 ots.insert(all_projective_types().begin(), all_projective_types().end());
214 for (const std::pair<const OpType, OpTypeInfo> &ott : optypeinfo()) {
215 if (!ott.second.signature || *ott.second.signature != singleq)
216 ots.insert(ott.first);
217 }
218 PredicatePtrMap precons;
219 PredicatePtr outp_gates = std::make_shared<GateSetPredicate>(ots);
220 PredicatePtrMap spec_postcons = {
222 PredicateClassGuarantees g_postcons;
223 PostConditions postcon{spec_postcons, g_postcons, Guarantee::Preserve};
224 // record pass config
225 nlohmann::json j;
226 j["name"] = "DecomposeSingleQubitsTK1";
227 return std::make_shared<StandardPass>(precons, t, postcon, j);
228 }());
229 return pp;
230}
231
232PassPtr ComposePhasePolyBoxes(const unsigned min_size) {
241 Transform t =
244
245 PredicatePtr noclas = std::make_shared<NoClassicalControlPredicate>();
246
248
249 PredicatePtr no_wire_swap = std::make_shared<NoWireSwapsPredicate>();
250
251 PredicatePtrMap s_postcons{
253 CompilationUnit::make_type_pair(no_wire_swap)};
254 PostConditions postcon{s_postcons, {}, Guarantee::Preserve};
255
256 nlohmann::json j;
257 j["name"] = "ComposePhasePolyBoxes";
258 j["min_size"] = min_size;
259
260 return std::make_shared<StandardPass>(precons, t, postcon, j);
261}
262
264 const std::unordered_set<OpType> &excluded_types,
265 const std::unordered_set<std::string> &excluded_opgroups,
266 const std::optional<std::unordered_set<OpType>> &included_types,
267 const std::optional<std::unordered_set<std::string>> &included_opgroups) {
269 excluded_types, excluded_opgroups, included_types, included_opgroups);
270 PredicatePtrMap s_ps;
282 PredicateClassGuarantees g_postcons = {
284 };
285 PostConditions postcon{s_ps, g_postcons, Guarantee::Preserve};
286 // record pass config
287 nlohmann::json j;
288 j["name"] = "DecomposeBoxes";
289 j["excluded_types"] = excluded_types;
290 j["excluded_opgroups"] = excluded_opgroups;
291 if (included_types) j["included_types"] = *included_types;
292 if (included_opgroups) j["included_opgroups"] = *included_opgroups;
293 return std::make_shared<StandardPass>(s_ps, t, postcon, j);
294}
295
297 static const PassPtr pp([]() {
299 PredicatePtrMap s_ps;
300 PredicateClassGuarantees g_postcons{
302 PostConditions postcon{s_ps, g_postcons, Guarantee::Preserve};
303 // record pass config
304 nlohmann::json j;
305 j["name"] = "SquashTK1";
306 return std::make_shared<StandardPass>(s_ps, t, postcon, j);
307 }());
308 return pp;
309}
310
312 static const PassPtr pp([]() {
314 PredicatePtrMap s_ps;
315 PredicateClassGuarantees g_postcons{
318 PostConditions postcon{s_ps, g_postcons, Guarantee::Preserve};
319 nlohmann::json j;
320 j["name"] = "DecomposeBridges";
321 return std::make_shared<StandardPass>(s_ps, t, postcon, j);
322 }());
323 return pp;
324}
325
327 static const PassPtr pp([]() {
328 Transform t =
329 Transform([](Circuit &circ, std::shared_ptr<unit_bimaps_t> maps) {
330 if (circ.is_simple()) return false;
331 unit_map_t qmap = circ.flatten_registers();
332 update_maps(maps, qmap, qmap);
333 return true;
334 });
335 PredicatePtrMap s_ps;
336 PredicatePtr simple = std::make_shared<DefaultRegisterPredicate>();
338 PredicateClassGuarantees g_postcons{
341 PostConditions postcon{spec_postcons, g_postcons, Guarantee::Preserve};
342 // record pass config
343 nlohmann::json j;
344 j["name"] = "FlattenRegisters";
345 return std::make_shared<StandardPass>(s_ps, t, postcon, j);
346 }());
347 return pp;
348}
349
351 static const PassPtr pp([]() {
352 Transform t = Transform([](Circuit &circ) {
353 VertexList barriers;
354 BGL_FORALL_VERTICES(v, circ.dag, DAG) {
356 barriers.push_back(v);
357 }
358 }
359 circ.remove_vertices(
361 return !barriers.empty();
362 });
363 const PredicatePtrMap no_precons;
364 const PredicatePtr no_barriers = std::make_shared<NoBarriersPredicate>();
365 PredicatePtrMap no_barriers_con{
367 PredicateClassGuarantees preserve_all;
368 PostConditions postcons{no_barriers_con, preserve_all, Guarantee::Preserve};
369 nlohmann::json j;
370 j["name"] = "RemoveBarriers";
371 return std::make_shared<StandardPass>(no_precons, t, postcons, j);
372 }());
373 return pp;
374}
375
376const PassPtr &DelayMeasures(const bool allow_partial) {
377 auto f = [](bool allow_partial) {
378 Transform t = Transforms::delay_measures(allow_partial);
379
380 PredicatePtrMap precon;
381 PostConditions postcon;
382
383 if (!allow_partial) {
384 PredicatePtr delaymeaspred =
385 std::make_shared<CommutableMeasuresPredicate>();
386 precon = {CompilationUnit::make_type_pair(delaymeaspred)};
387
388 PredicatePtr midmeaspred = std::make_shared<NoMidMeasurePredicate>();
389 PredicatePtrMap spec_postcons = {
391 postcon = {spec_postcons, {}, Guarantee::Preserve};
392 }
393
394 nlohmann::json j;
395 j["name"] = "DelayMeasures";
396 j["allow_partial"] = allow_partial;
397 return std::make_shared<StandardPass>(precon, t, postcon, j);
398 };
399 static const PassPtr delay(f(false));
400 static const PassPtr try_delay(f(true));
401 return allow_partial ? try_delay : delay;
402}
403
405 static const PassPtr pp([]() {
407 PredicatePtrMap no_precons;
408 PostConditions postcon = {{}, {}, Guarantee::Preserve};
409 nlohmann::json j;
410 j["name"] = "RemoveDiscarded";
411 return std::make_shared<StandardPass>(no_precons, t, postcon, j);
412 }());
413 return pp;
414}
415
417 static const PassPtr pp([]() {
419 PredicatePtrMap no_precons;
420
421 // GateSetPredicate not preserved because classical gates may be
422 // introduced.
423 PredicateClassGuarantees g_postcons = {
425
426 PostConditions postcon = {{}, g_postcons, Guarantee::Preserve};
427 nlohmann::json j;
428 j["name"] = "SimplifyMeasured";
429 return std::make_shared<StandardPass>(no_precons, t, postcon, j);
430 }());
431 return pp;
432}
433
435 static const PassPtr pp([]() {
437 PredicatePtrMap no_precons;
438
439 // GateSetPredicate not preserved because single-qubit gates may be added
440 PredicateClassGuarantees g_postcons = {
442
443 PredicatePtr normalisedpred = std::make_shared<NormalisedTK2Predicate>();
444 PredicatePtrMap spec_postcons = {
445 CompilationUnit::make_type_pair(normalisedpred)};
446 PostConditions postcon = {spec_postcons, g_postcons, Guarantee::Preserve};
447 nlohmann::json j;
448 j["name"] = "NormaliseTK2";
449 return std::make_shared<StandardPass>(no_precons, t, postcon, j);
450 }());
451 return pp;
452}
453
455 static const PassPtr pp([]() {
457 // GateSetPredicate not preserved because ZZPhase gates may be converted to
458 // Rz gates
459 PredicateClassGuarantees g_postcons = {
461 PostConditions postcon = {{}, g_postcons, Guarantee::Preserve};
462 PredicatePtrMap precons;
463 // record pass config
464 nlohmann::json j;
465 j["name"] = "ZZPhaseToRz";
466 return std::make_shared<StandardPass>(precons, t, postcon, j);
467 }());
468 return pp;
469}
470
472 static const PassPtr pp([]() {
474 PredicatePtrMap s_ps;
475 PredicateClassGuarantees g_postcons{
477 PostConditions postcon{s_ps, g_postcons, Guarantee::Preserve};
478 nlohmann::json j;
479 j["name"] = "SquashRzPhasedX";
480 return std::make_shared<StandardPass>(s_ps, t, postcon, j);
481 }());
482 return pp;
483}
484
486 static const PassPtr pp([]() {
488 PredicatePtrMap s_ps;
489 PredicateClassGuarantees g_postcons{
491 PostConditions postcon{s_ps, g_postcons, Guarantee::Preserve};
492 nlohmann::json j;
493 j["name"] = "CnXPairwiseDecomposition";
494 return std::make_shared<StandardPass>(s_ps, t, postcon, j);
495 }());
496 return pp;
497}
498
500 static const PassPtr pp([]() {
501 Transform t = Transform([](Circuit &circ) {
502 bool has_implicit_wire_swaps = circ.has_implicit_wireswaps();
504 return has_implicit_wire_swaps;
505 });
506 PredicatePtrMap precons;
507 PredicatePtr no_wire_swap = std::make_shared<NoWireSwapsPredicate>();
508 PredicatePtrMap specific_postcons = {
509 CompilationUnit::make_type_pair(no_wire_swap)};
510 PredicateClassGuarantees generic_postcons;
511 Guarantee default_postcon = Guarantee::Preserve;
512 PostConditions postcons{
513 specific_postcons, generic_postcons, default_postcon};
514 PredicateClassGuarantees g_postcons = {
517 nlohmann::json j;
518 j["name"] = "RemoveImplicitQubitPermutation";
519 return std::make_shared<StandardPass>(precons, t, postcons, j);
520 }());
521 return pp;
522}
523
524const PassPtr &ZXGraphlikeOptimisation(bool allow_swaps) {
525 auto create_pass_ptr = []<bool allow_wire_swaps>() -> PassPtr {
526 Transform t = Transform([](Circuit &circ) {
527 std::optional<std::string> name = circ.get_name();
528 zx::ZXDiagram diag = circuit_to_zx(circ).first;
532 Circuit c = zx_to_circuit(diag);
533 qubit_vector_t orig_qs = circ.all_qubits();
534 qubit_vector_t c_qs = c.all_qubits();
535 qubit_map_t qmap;
536 for (unsigned i = 0; i < orig_qs.size(); ++i)
537 qmap.insert({c_qs.at(i), orig_qs.at(i)});
538 c.rename_units<Qubit, Qubit>(qmap);
539 if constexpr (!allow_wire_swaps) {
541 }
542 circ = c;
543 if (name.has_value()) {
544 circ.set_name(*name);
545 }
546 return true;
547 });
552 PredicatePtrMap precons = {
554 std::make_shared<GateSetPredicate>(in_optypes)),
556 std::make_shared<NoClassicalBitsPredicate>())};
557 PredicatePtrMap specific_postcons;
558 Guarantee default_postcon = Guarantee::Preserve;
559 PredicateClassGuarantees generic_postcons = {
563 PostConditions postcons{
564 specific_postcons, generic_postcons, default_postcon};
565 nlohmann::json j;
566 j["name"] = "ZXGraphlikeOptimisation";
567 return std::make_shared<StandardPass>(precons, t, postcons, j);
568 };
569
570 static const PassPtr pp{create_pass_ptr.operator()<true>()};
571 if (allow_swaps) {
572 return pp;
573 }
574
575 static const PassPtr pp_no_implicit_swaps{
576 create_pass_ptr.operator()<false>()};
577 return pp_no_implicit_swaps;
578}
579
581 static const PassPtr pp([]() {
582 Transform t = Transform([](Circuit &circ) {
583 VertexList phases;
584 BGL_FORALL_VERTICES(v, circ.dag, DAG) {
585 Op_ptr op = circ.get_Op_ptr_from_Vertex(v);
586 OpType optype = op->get_type();
587 while (optype == OpType::Conditional) {
588 op = static_cast<const Conditional &>(*op).get_op();
589 optype = op->get_type();
590 }
591 if (optype == OpType::Phase) {
592 phases.push_back(v);
593 }
594 }
595 circ.remove_vertices(
597 return !phases.empty();
598 });
599 const PredicatePtrMap no_precons;
600 PostConditions postcons = {{}, {}, Guarantee::Preserve};
601 nlohmann::json j;
602 j["name"] = "RemovePhaseOps";
603 return std::make_shared<StandardPass>(no_precons, t, postcons, j);
604 }());
605 return pp;
606}
607
608} // namespace tket
A circuit.
Definition Circuit.hpp:212
bool rename_units(const std::map< UnitA, UnitB > &qm)
Rename all the units according to the given mapping.
Definition Circuit.hpp:1645
void set_name(const std::string _name)
Set the name of the circuit.
Definition Circuit.hpp:1599
const Op_ptr get_Op_ptr_from_Vertex(const Vertex &vert) const
qubit_vector_t all_qubits() const
bool has_implicit_wireswaps() const
Whether the circuit contains implicit wireswaps.
bool is_simple() const
unit_map_t flatten_registers()
Convert all quantum and classical bits to use default registers.
void remove_vertices(const VertexSet &surplus, GraphRewiring graph_rewiring, VertexDeletion vertex_deletion)
std::optional< std::string > get_name() const
Get the name of the circuit.
Definition Circuit.hpp:1592
Vertex add_op(const Op_ptr &op, const std::vector< ID > &args, std::optional< std::string > opgroup=std::nullopt)
Append an operation to the circuit.
Definition Circuit.hpp:1703
void replace_all_implicit_wire_swaps()
replaces all implicit wire swaps with SWAP gates
OpType get_OpType_from_Vertex(const Vertex &vert) const
static TypePredicatePair make_type_pair(const PredicatePtr &ptr)
Decorates another op, adding a QASM-style classical condition.
Op_ptr get_op() const
Asserts that all operations are in the specified set of types.
Asserts that any measurements occur at the end of the circuit.
Location holding a qubit.
Definition UnitID.hpp:154
A transformation of a circuit that preserves its semantics.
Definition Transform.hpp:27
static Rewrite reduce_graphlike_form()
Given a diagram in graphlike form, applies local complementations and pivoting to remove as many inte...
static Rewrite to_graphlike_form()
Given a diagram with ZX generators, yields a diagram with only ZSpiders, connected by at most one Had...
const RewriteFun apply
The actual rewrite to be applied.
Definition Rewrite.hpp:51
static Rewrite to_MBQC_diag()
Given a diagram in graphlike form, will rebase to MBQC generators, ensure that output qubits are PX(0...
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 rebase_tket()
Definition Rebase.cpp:216
Transform remove_redundancies()
Transform commute_through_multis()
Transform decompose_single_qubits_TK1()
Decomposes all single-qubit unitary gates into TK1 gates.
Transform decompose_multi_qubits_CX()
Decomposes all multi-qubit unitary gates into CX and single-qubit gates.
Transform ZZPhase_to_Rz()
Converts any ZZPhase with angle in (-1, 1) to two pi Rz gates.
Transform remove_discarded_ops()
Remove all operations that have no OpType::Output or OpType::ClOutput in their causal future.
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 delay_measures(bool allow_partial)
Commute all measurement gates to the end of the circuit.
Transform synthesise_tket()
Synthesise a circuit consisting of CX and TK1 gates only.
Transform squash_1qb_to_Rz_PhasedX(bool always_squash_symbols)
Squash single qubit gates into PhasedX and Rz gates.
Transform synthesise_tk()
Synthesise a circuit consisting of TK2 and TK1 gates only.
Transform rebase_UFR()
Definition Rebase.cpp:253
Transform cnx_pairwise_decomposition()
Transform decompose_BRIDGE_to_CX()
Transform normalise_TK2()
Normalises all TK2 gates so that NormalisedTK2Predicate is satisfied.
Transform squash_1qb_to_tk1()
Squash all single-qubit gates to TK1.
Transform simplify_measured()
Commute classical maps through measurements.
Defines tket::DeviceCharacterisation, used in NoiseAwarePlacement and in commute_SQ_gates_through_SWA...
Definition Path.cpp:22
const PassPtr & ZXGraphlikeOptimisation(bool allow_swaps)
Attempt to optimise the circuit by simplifying in ZX calculus and extracting a circuit back out.
boost::graph_traits< DAG >::vertex_descriptor Vertex
Definition DAGDefs.hpp:70
OpType
Named operation types.
Definition OpType.hpp:29
@ Measure
Measure a qubit, producing a classical output.
@ Output
Quantum output node of the circuit.
@ Collapse
Measure a qubit producing no output.
@ Input
Quantum input node of the circuit.
@ SWAP
Swap two qubits.
@ Barrier
No-op that must be preserved by compilation.
@ Reset
Reset a qubit to the zero state.
@ noop
Identity.
@ CX
Controlled OpType::X.
@ CZ
Controlled OpType::Z.
@ Conditional
See Conditional.
std::unordered_set< OpType > OpTypeSet
Set of operation types.
std::shared_ptr< BasePass > PassPtr
std::list< Vertex > VertexList
Definition DAGDefs.hpp:74
const PassPtr & SquashTK1()
Squash sequences of single-qubit gates to TK1 gates.
const PassPtr & RebaseTket()
std::pair< ZXDiagram, BoundaryVertMap > circuit_to_zx(const Circuit &circ)
Construct a zx diagram from a given circuit.
std::map< Qubit, Qubit > qubit_map_t
Definition UnitID.hpp:316
const PassPtr & RemoveImplicitQubitPermutation()
Remove any implicit qubit permutation by appending SWAP gates.
@ Quantum
A wire carrying quantum information, corresponding to some allocated Qubit.
PassPtr ComposePhasePolyBoxes(const unsigned min_size)
converts a circuit containing all possible gates to a circuit containing only phase poly boxes + H ga...
const OpTypeSet & all_projective_types()
Set of all measurement and reset gates.
const PassPtr & SynthesiseTK()
const PassPtr & RemoveRedundancies()
const PassPtr & NormaliseTK2()
Normalises all TK2 gates.
const PassPtr & RemovePhaseOps()
Remove all OpType::Phase (including conditionals) from the circuit.
std::shared_ptr< const Op > Op_ptr
Definition OpPtr.hpp:24
const PassPtr & RemoveBarriers()
Remove all& OpType::Barrier from the circuit.
const PassPtr & SquashRzPhasedX()
Squash single qubit gates into PhasedX and Rz gates.
const PassPtr & CnXPairwiseDecomposition()
Decompose CnX gates to 2-qubit gates and single qubit gates.
const PassPtr & ZZPhaseToRz()
Converts ZZPhase with angle 1 or -1 to two Rz(1) gates.
PassPtr DecomposeBoxes(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.
const PassPtr & DecomposeMultiQubitsCX()
std::map< std::type_index, Guarantee > PredicateClassGuarantees
std::map< UnitID, UnitID > unit_map_t
Definition UnitID.hpp:312
const PassPtr & RemoveDiscarded()
Remove all operations that have no OpType::Output or OpType::ClOutput in their causal future.
const PassPtr & RxFromSX()
Replace all SX in the circuit with Rx(1/2) and all SXdg with Rx(-1/2).
const PassPtr & SimplifyMeasured()
Replace all measured classical maps that are followed by Measure operations whose quantum output is d...
const PassPtr & CommuteThroughMultis()
const PassPtr & SynthesiseTket()
const PassPtr & RebaseUFR()
std::vector< EdgeType > op_signature_t
Definition EdgeType.hpp:61
std::map< std::type_index, PredicatePtr > PredicatePtrMap
const PassPtr & DecomposeBridges()
std::shared_ptr< Predicate > PredicatePtr
const PassPtr & DecomposeArbitrarilyControlledGates()
std::vector< Qubit > qubit_vector_t
Definition UnitID.hpp:315
const PassPtr & DelayMeasures(const bool allow_partial)
Commutes measurements to the end of the circuit.
std::vector< Vertex > VertexVec
Definition DAGDefs.hpp:73
boost::adjacency_list< boost::listS, boost::listS, boost::bidirectionalS, boost::property< boost::vertex_index_t, std::size_t, VertexProperties >, EdgeProperties > DAG
Graph representing a circuit, with operations as nodes.
Definition DAGDefs.hpp:68
const PassPtr & DecomposeSingleQubitsTK1()
Circuit zx_to_circuit(const ZXDiagram &d)
Takes a unitary ZX diagram in MBQC form with the promise that a gflow exists.
bool update_maps(std::shared_ptr< unit_bimaps_t > maps, const std::map< UnitA, UnitB > &um_initial, const std::map< UnitA, UnitB > &um_final)
Update a pair of "initial" and "final" correspondences.
Definition UnitID.hpp:361
const std::map< OpType, OpTypeInfo > & optypeinfo()
Information including name and shape of each operation type.
const PassPtr & FlattenRegisters()