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
90 static const PassPtr pp([]() {
92 PostConditions postcon = {{}, {}, Guarantee::Preserve};
93 PredicatePtrMap precons;
94 // record pass config
95 nlohmann::json j;
96 j["name"] = "RemoveRedundancies";
97 return std::make_shared<StandardPass>(precons, t, postcon, j);
98 }());
99 return pp;
100}
101
103 static const PassPtr pp([]() {
105 PostConditions postcon = {{}, {}, Guarantee::Preserve};
106 PredicatePtrMap precons;
107 // record pass config
108 nlohmann::json j;
109 j["name"] = "CommuteThroughMultis";
110 return std::make_shared<StandardPass>(precons, t, postcon, j);
111 }());
112 return pp;
113}
114
116 static const PassPtr pp([]() {
118 PredicateClassGuarantees g_postcons = {
120 PostConditions postcon = {{}, g_postcons, Guarantee::Preserve};
121 PredicatePtrMap precons;
122 // record pass config
123 nlohmann::json j;
124 j["name"] = "DecomposeArbitrarilyControlledGates";
125 return std::make_shared<StandardPass>(precons, t, postcon, j);
126 }());
127 return pp;
128}
129
131 static const PassPtr pp([]() {
133 /* Spits out CX + any single qb gates */
134 OpTypeSet ots = {OpType::CX};
135 op_signature_t noargs = {};
137 ots.insert(all_projective_types().begin(), all_projective_types().end());
138 for (const std::pair<const OpType, OpTypeInfo> &ott : optypeinfo()) {
139 if (!ott.second.signature || *ott.second.signature == singleq ||
140 *ott.second.signature == noargs)
141 ots.insert(ott.first);
142 }
143 PredicatePtrMap precons;
144 PredicatePtr outp_gates = std::make_shared<GateSetPredicate>(ots);
145 PredicatePtr twoqbpred = std::make_shared<MaxTwoQubitGatesPredicate>();
146 PredicatePtrMap spec_postcons = {
149 PredicateClassGuarantees g_postcons;
150 PostConditions postcon{spec_postcons, g_postcons, Guarantee::Preserve};
151 // record pass config
152 nlohmann::json j;
153 j["name"] = "DecomposeMultiQubitsCX";
154 return std::make_shared<StandardPass>(precons, t, postcon, j);
155 }());
156 return pp;
157}
158
160 static const PassPtr pp([]() {
162 /* Spits out TK1 + any multi qb gates */
163 OpTypeSet ots = {OpType::TK1};
165 ots.insert(all_projective_types().begin(), all_projective_types().end());
166 for (const std::pair<const OpType, OpTypeInfo> &ott : optypeinfo()) {
167 if (!ott.second.signature || *ott.second.signature != singleq)
168 ots.insert(ott.first);
169 }
170 PredicatePtrMap precons;
171 PredicatePtr outp_gates = std::make_shared<GateSetPredicate>(ots);
172 PredicatePtrMap spec_postcons = {
174 PredicateClassGuarantees g_postcons;
175 PostConditions postcon{spec_postcons, g_postcons, Guarantee::Preserve};
176 // record pass config
177 nlohmann::json j;
178 j["name"] = "DecomposeSingleQubitsTK1";
179 return std::make_shared<StandardPass>(precons, t, postcon, j);
180 }());
181 return pp;
182}
183
184PassPtr ComposePhasePolyBoxes(const unsigned min_size) {
193 Transform t =
196
197 PredicatePtr noclas = std::make_shared<NoClassicalControlPredicate>();
198
200
201 PredicatePtr no_wire_swap = std::make_shared<NoWireSwapsPredicate>();
202
203 PredicatePtrMap s_postcons{
205 CompilationUnit::make_type_pair(no_wire_swap)};
206 PostConditions postcon{s_postcons, {}, Guarantee::Preserve};
207
208 nlohmann::json j;
209 j["name"] = "ComposePhasePolyBoxes";
210 j["min_size"] = min_size;
211
212 return std::make_shared<StandardPass>(precons, t, postcon, j);
213}
214
216 const std::unordered_set<OpType> &excluded_types,
217 const std::unordered_set<std::string> &excluded_opgroups,
218 const std::optional<std::unordered_set<OpType>> &included_types,
219 const std::optional<std::unordered_set<std::string>> &included_opgroups) {
221 excluded_types, excluded_opgroups, included_types, included_opgroups);
222 PredicatePtrMap s_ps;
234 PredicateClassGuarantees g_postcons = {
236 };
237 PostConditions postcon{s_ps, g_postcons, Guarantee::Preserve};
238 // record pass config
239 nlohmann::json j;
240 j["name"] = "DecomposeBoxes";
241 j["excluded_types"] = excluded_types;
242 j["excluded_opgroups"] = excluded_opgroups;
243 if (included_types) j["included_types"] = *included_types;
244 if (included_opgroups) j["included_opgroups"] = *included_opgroups;
245 return std::make_shared<StandardPass>(s_ps, t, postcon, j);
246}
247
249 static const PassPtr pp([]() {
251 PredicatePtrMap s_ps;
252 PredicateClassGuarantees g_postcons{
254 PostConditions postcon{s_ps, g_postcons, Guarantee::Preserve};
255 // record pass config
256 nlohmann::json j;
257 j["name"] = "SquashTK1";
258 return std::make_shared<StandardPass>(s_ps, t, postcon, j);
259 }());
260 return pp;
261}
262
264 static const PassPtr pp([]() {
266 PredicatePtrMap s_ps;
267 PredicateClassGuarantees g_postcons{
270 PostConditions postcon{s_ps, g_postcons, Guarantee::Preserve};
271 nlohmann::json j;
272 j["name"] = "DecomposeBridges";
273 return std::make_shared<StandardPass>(s_ps, t, postcon, j);
274 }());
275 return pp;
276}
277
279 static const PassPtr pp([]() {
280 Transform t =
281 Transform([](Circuit &circ, std::shared_ptr<unit_bimaps_t> maps) {
282 if (circ.is_simple()) return false;
283 unit_map_t qmap = circ.flatten_registers();
284 update_maps(maps, qmap, qmap);
285 return true;
286 });
287 PredicatePtrMap s_ps;
288 PredicatePtr simple = std::make_shared<DefaultRegisterPredicate>();
290 PredicateClassGuarantees g_postcons{
293 PostConditions postcon{spec_postcons, g_postcons, Guarantee::Preserve};
294 // record pass config
295 nlohmann::json j;
296 j["name"] = "FlattenRegisters";
297 return std::make_shared<StandardPass>(s_ps, t, postcon, j);
298 }());
299 return pp;
300}
301
303 static const PassPtr pp([]() {
304 Transform t = Transform([](Circuit &circ) {
305 VertexList barriers;
306 BGL_FORALL_VERTICES(v, circ.dag, DAG) {
308 barriers.push_back(v);
309 }
310 }
311 circ.remove_vertices(
313 return !barriers.empty();
314 });
315 const PredicatePtrMap no_precons;
316 const PredicatePtr no_barriers = std::make_shared<NoBarriersPredicate>();
317 PredicatePtrMap no_barriers_con{
319 PredicateClassGuarantees preserve_all;
320 PostConditions postcons{no_barriers_con, preserve_all, Guarantee::Preserve};
321 nlohmann::json j;
322 j["name"] = "RemoveBarriers";
323 return std::make_shared<StandardPass>(no_precons, t, postcons, j);
324 }());
325 return pp;
326}
327
328const PassPtr &DelayMeasures(const bool allow_partial) {
329 auto f = [](bool allow_partial) {
330 Transform t = Transforms::delay_measures(allow_partial);
331
332 PredicatePtrMap precon;
333 PostConditions postcon;
334
335 if (!allow_partial) {
336 PredicatePtr delaymeaspred =
337 std::make_shared<CommutableMeasuresPredicate>();
338 precon = {CompilationUnit::make_type_pair(delaymeaspred)};
339
340 PredicatePtr midmeaspred = std::make_shared<NoMidMeasurePredicate>();
341 PredicatePtrMap spec_postcons = {
343 postcon = {spec_postcons, {}, Guarantee::Preserve};
344 }
345
346 nlohmann::json j;
347 j["name"] = "DelayMeasures";
348 j["allow_partial"] = allow_partial;
349 return std::make_shared<StandardPass>(precon, t, postcon, j);
350 };
351 static const PassPtr delay(f(false));
352 static const PassPtr try_delay(f(true));
353 return allow_partial ? try_delay : delay;
354}
355
357 static const PassPtr pp([]() {
359 PredicatePtrMap no_precons;
360 PostConditions postcon = {{}, {}, Guarantee::Preserve};
361 nlohmann::json j;
362 j["name"] = "RemoveDiscarded";
363 return std::make_shared<StandardPass>(no_precons, t, postcon, j);
364 }());
365 return pp;
366}
367
369 static const PassPtr pp([]() {
371 PredicatePtrMap no_precons;
372
373 // GateSetPredicate not preserved because classical gates may be
374 // introduced.
375 PredicateClassGuarantees g_postcons = {
377
378 PostConditions postcon = {{}, g_postcons, Guarantee::Preserve};
379 nlohmann::json j;
380 j["name"] = "SimplifyMeasured";
381 return std::make_shared<StandardPass>(no_precons, t, postcon, j);
382 }());
383 return pp;
384}
385
387 static const PassPtr pp([]() {
389 PredicatePtrMap no_precons;
390
391 // GateSetPredicate not preserved because single-qubit gates may be added
392 PredicateClassGuarantees g_postcons = {
394
395 PredicatePtr normalisedpred = std::make_shared<NormalisedTK2Predicate>();
396 PredicatePtrMap spec_postcons = {
397 CompilationUnit::make_type_pair(normalisedpred)};
398 PostConditions postcon = {spec_postcons, g_postcons, Guarantee::Preserve};
399 nlohmann::json j;
400 j["name"] = "NormaliseTK2";
401 return std::make_shared<StandardPass>(no_precons, t, postcon, j);
402 }());
403 return pp;
404}
405
407 static const PassPtr pp([]() {
409 // GateSetPredicate not preserved because ZZPhase gates may be converted to
410 // Rz gates
411 PredicateClassGuarantees g_postcons = {
413 PostConditions postcon = {{}, g_postcons, Guarantee::Preserve};
414 PredicatePtrMap precons;
415 // record pass config
416 nlohmann::json j;
417 j["name"] = "ZZPhaseToRz";
418 return std::make_shared<StandardPass>(precons, t, postcon, j);
419 }());
420 return pp;
421}
422
424 static const PassPtr pp([]() {
426 PredicatePtrMap s_ps;
427 PredicateClassGuarantees g_postcons{
429 PostConditions postcon{s_ps, g_postcons, Guarantee::Preserve};
430 nlohmann::json j;
431 j["name"] = "SquashRzPhasedX";
432 return std::make_shared<StandardPass>(s_ps, t, postcon, j);
433 }());
434 return pp;
435}
436
438 static const PassPtr pp([]() {
440 PredicatePtrMap s_ps;
441 PredicateClassGuarantees g_postcons{
443 PostConditions postcon{s_ps, g_postcons, Guarantee::Preserve};
444 nlohmann::json j;
445 j["name"] = "CnXPairwiseDecomposition";
446 return std::make_shared<StandardPass>(s_ps, t, postcon, j);
447 }());
448 return pp;
449}
450
452 static const PassPtr pp([]() {
453 Transform t = Transform([](Circuit &circ) {
454 bool has_implicit_wire_swaps = circ.has_implicit_wireswaps();
456 return has_implicit_wire_swaps;
457 });
458 PredicatePtrMap precons;
459 PredicatePtr no_wire_swap = std::make_shared<NoWireSwapsPredicate>();
460 PredicatePtrMap specific_postcons = {
461 CompilationUnit::make_type_pair(no_wire_swap)};
462 PredicateClassGuarantees generic_postcons;
463 Guarantee default_postcon = Guarantee::Preserve;
464 PostConditions postcons{
465 specific_postcons, generic_postcons, default_postcon};
466 PredicateClassGuarantees g_postcons = {
469 nlohmann::json j;
470 j["name"] = "RemoveImplicitQubitPermutation";
471 return std::make_shared<StandardPass>(precons, t, postcons, j);
472 }());
473 return pp;
474}
475
476const PassPtr &ZXGraphlikeOptimisation(bool allow_swaps) {
477 auto create_pass_ptr = []<bool allow_wire_swaps>() -> PassPtr {
478 Transform t = Transform([](Circuit &circ) {
479 std::optional<std::string> name = circ.get_name();
480 zx::ZXDiagram diag = circuit_to_zx(circ).first;
484 Circuit c = zx_to_circuit(diag);
485 qubit_vector_t orig_qs = circ.all_qubits();
486 qubit_vector_t c_qs = c.all_qubits();
487 qubit_map_t qmap;
488 for (unsigned i = 0; i < orig_qs.size(); ++i)
489 qmap.insert({c_qs.at(i), orig_qs.at(i)});
490 c.rename_units<Qubit, Qubit>(qmap);
491 if constexpr (!allow_wire_swaps) {
493 }
494 circ = c;
495 if (name.has_value()) {
496 circ.set_name(*name);
497 }
498 return true;
499 });
504 PredicatePtrMap precons = {
506 std::make_shared<GateSetPredicate>(in_optypes)),
508 std::make_shared<NoClassicalBitsPredicate>())};
509 PredicatePtrMap specific_postcons;
510 Guarantee default_postcon = Guarantee::Preserve;
511 PredicateClassGuarantees generic_postcons = {
515 PostConditions postcons{
516 specific_postcons, generic_postcons, default_postcon};
517 nlohmann::json j;
518 j["name"] = "ZXGraphlikeOptimisation";
519 return std::make_shared<StandardPass>(precons, t, postcons, j);
520 };
521
522 static const PassPtr pp{create_pass_ptr.operator()<true>()};
523 if (allow_swaps) {
524 return pp;
525 }
526
527 static const PassPtr pp_no_implicit_swaps{
528 create_pass_ptr.operator()<false>()};
529 return pp_no_implicit_swaps;
530}
531
533 static const PassPtr pp([]() {
534 Transform t = Transform([](Circuit &circ) {
535 VertexList phases;
536 BGL_FORALL_VERTICES(v, circ.dag, DAG) {
537 Op_ptr op = circ.get_Op_ptr_from_Vertex(v);
538 OpType optype = op->get_type();
539 while (optype == OpType::Conditional) {
540 op = static_cast<const Conditional &>(*op).get_op();
541 optype = op->get_type();
542 }
543 if (optype == OpType::Phase) {
544 phases.push_back(v);
545 }
546 }
547 circ.remove_vertices(
549 return !phases.empty();
550 });
551 const PredicatePtrMap no_precons;
552 PostConditions postcons = {{}, {}, Guarantee::Preserve};
553 nlohmann::json j;
554 j["name"] = "RemovePhaseOps";
555 return std::make_shared<StandardPass>(no_precons, t, postcons, j);
556 }());
557 return pp;
558}
559
560} // 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:1643
void set_name(const std::string _name)
Set the name of the circuit.
Definition Circuit.hpp:1597
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:1590
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.
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 & 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.
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()