Skip to main content

tk_pg_libs/
lib.rs

1//! An umbrella crate for pg-libs, TKET's Pauli graph libraries. It re-exports
2//! core types, transformation and synthesis passes, and supporting utilities.
3//!
4//! # Quick start
5//!
6//! This example optimizes the T count and synthesizes a two qubit Clifford+T circuit.
7//!
8//! ```
9//! use tk_pg_libs::{GateData, GateType, Op, PauliGraph};
10//! use tk_pg_libs::passes::{
11//!     CanonicalFormPass, GreedySynthPass, GroupCommutingOpsPass, PGPass,
12//!     RotationMergingPass, TOptimizationPass,
13//! };
14//!
15//! let mut pg = PauliGraph::new(2);
16//! for data in [
17//!     GateData::new(GateType::RZ, vec![1]).with_params(vec![0.25]),
18//!     GateData::new(GateType::ZX, vec![0, 1]), // CX(0, 1)
19//!     GateData::new(GateType::ZX, vec![1, 0]), // CX(1, 0)
20//!     GateData::new(GateType::RZ, vec![0]).with_params(vec![0.25]),
21//! ] {
22//!     pg.add_op(Op::Gate { data });
23//! }
24//!
25//! let pg = CanonicalFormPass::new().transform(&pg);
26//! let pg = RotationMergingPass::new().transform(&pg);
27//! let pg = TOptimizationPass::new().transform(&pg);
28//! let pg = GroupCommutingOpsPass::new().transform(&pg);
29//! let pg = GreedySynthPass::new().transform(&pg);
30//! ```
31//!
32//! [`passes::TOptimizationPass`] uses no ancillas by default and requires rotation
33//! angles that are multiples of 0.25 half turns.
34//! Measurements, resets, and black boxes are not supported as input to this pass.
35
36#[doc(inline)]
37pub use tk_pg_core::{
38    BlackBoxData, ConditionalBoxData, GateData, GateType, MeasureData, Op, PGPass, Pauli,
39    PauliGraph, PauliGraphError, ResetData, RotationData, TableauData,
40};
41
42#[doc(inline)]
43pub use tk_pg_core as core;
44
45#[doc(inline)]
46pub use tk_pg_bitpacked as bitpacked;
47#[doc(inline)]
48pub use tk_pg_converter as tk_converter;
49#[doc(inline)]
50pub use tk_pg_ir_kernels as ir_kernels;
51#[doc(inline)]
52pub use tk_pg_qm_tableau as qm_tableau;
53#[doc(inline)]
54pub use tk_pg_utils as utils;
55
56/// Canonical form, optimization, synthesis and rebasing passes for `PauliGraph`.
57pub mod passes {
58    #[doc(inline)]
59    pub use tk_pg_canonical_form::CanonicalFormPass;
60    #[doc(inline)]
61    pub use tk_pg_core::PGPass;
62    #[doc(inline)]
63    pub use tk_pg_greedy_synth::{GreedySynthPass, ParallelMode};
64    #[doc(inline)]
65    pub use tk_pg_optimize::{GroupCommutingOpsPass, RotationMergingPass};
66    #[doc(inline)]
67    pub use tk_pg_rebase::RebaseTQEToZXPass;
68    #[doc(inline)]
69    pub use tk_pg_t_optimize::TOptimizationPass;
70
71    #[cfg(feature = "unstable_simd")]
72    #[doc(inline)]
73    pub use tk_pg_greedy_synth::GreedySynthSimdPass;
74
75    #[doc(inline)]
76    pub use tk_pg_canonical_form as canonical_form;
77    #[doc(inline)]
78    pub use tk_pg_greedy_synth as greedy_synth;
79    #[doc(inline)]
80    pub use tk_pg_optimize as optimise;
81    #[doc(inline)]
82    pub use tk_pg_rebase as rebase;
83    #[doc(inline)]
84    pub use tk_pg_t_optimize as t_optimize;
85}