TKET

Also known as: pytket

On this page 7

TKET is an open-source, platform-independent quantum compiler developed by Quantinuum (originally Cambridge Quantum) that optimizes quantum circuits and adapts them to the constraints of specific hardware. In quantum software, it is accessed mainly through pytket, a Python package whose core is written in C++ for speed, and it is released under the Apache 2.0 license.

Unlike SDKs built around one vendor, TKET was designed as a retargetable compiler: the same circuit can be compiled for trapped-ion, superconducting or simulator backends through extension modules, which makes it a common choice for cross-platform work in quantum computing.

How the TKET compiler processes a circuit

TKET represents a program as a directed acyclic graph of operations and transforms it through a sequence of compilation passes. Each pass either rewrites the circuit to reduce cost, decomposes high-level constructs, or enforces a hardware constraint. Passes are composable objects, so users can chain them with sequence and repeat combinators or simply call a backend method that applies a default compilation pipeline.

A typical pipeline runs in four stages, summarized in the following table.

StageWhat happensExample passes
DecompositionHigh-level boxes become explicit gatesDecomposeBoxes
OptimizationGate count and depth are reducedFullPeepholeOptimise, KAKDecomposition, CliffordSimp
Placement and routingLogical qubits are mapped to physical qubits, SWAP gates addedPlacementPass, RoutingPass
RebaseGates are translated into the native gate setAutoRebase or device-specific rebases
Stages of a typical TKET compilation

After compilation, the backend validity check confirms that the circuit respects connectivity, native gates and other device predicates before it is submitted. This predicate system is a distinctive feature: every backend declares its requirements explicitly, and TKET can report which predicate a circuit violates.

Optimization techniques inside TKET

TKET combines local peephole rewrites with more global, structure-aware methods. Peephole passes cancel adjacent inverse gates, merge rotations and resynthesize two-qubit blocks using the KAK (Cartan) decomposition, which expresses any two-qubit unitary with at most three entangling gates.

For chemistry and optimization circuits, TKET offers Pauli gadget synthesis. Ansatz circuits such as unitary coupled cluster consist of many exponentials of Pauli strings, and TKET can represent them as PauliExpBox objects, then simultaneously diagonalize commuting sets to cut the number of CNOT gates. Clifford simplification and ZX-calculus-based rewriting provide further reductions on suitable circuits.

The table below compares the main optimization families and when they help most.

TechniqueBest suited forTypical gain
Peephole optimizationGeneral circuitsRemoves redundant gates, modest depth reduction
KAK resynthesisDense two-qubit blocksCaps blocks at three entangling gates
Pauli gadget synthesisChemistry and QAOA ansatz circuitsLarge CNOT reductions in favorable cases
Clifford simplificationClifford-heavy subcircuitsShorter Clifford sections
Noise-aware placementDevices with uneven error ratesUses better qubits and couplers
TKET optimization families

Gains depend heavily on circuit structure. No single pass is best for every workload, so heavy optimization can increase compile time without improving results on already compact circuits.

Backends and the pytket extension ecosystem

The pytket extension modules connect the compiler to hardware and simulators. Each extension defines a backend class with its own gate set, connectivity graph and job submission logic, so moving a workflow to another platform usually means changing one backend object rather than rewriting the circuit.

ExtensionTargetPurpose
pytket-quantinuumQuantinuum trapped-ion systems and emulatorsNative ZZ-phase and PhasedX compilation
pytket-qiskitIBM devices and Qiskit AerCircuit conversion and execution
pytket-cirqCirq circuits and simulatorsInteroperability with Google tooling
pytket-braketAmazon Braket devicesAccess to several hardware vendors
pytket-qulacs and othersFast classical simulatorsTesting and noise studies
Selected pytket extensions

Converters also let developers import circuits from Qiskit, Cirq or OpenQASM, optimize them in TKET and export them again. This makes TKET usable as a standalone optimization stage inside pipelines that otherwise rely on another SDK.

TKET compared with other compilers

TKET overlaps with the transpiler in Qiskit and with Cirq optimizers, but its emphasis differs. The comparison below highlights the practical distinctions.

AspectTKETQiskit transpilerCirq
Design goalVendor-neutral compilationIBM hardware first, extensibleGoogle hardware first, research flexibility
Core languageC++ with Python bindingsPython with Rust componentsPython
Distinctive strengthPauli gadgets, predicate checksLarge plugin ecosystemFine control of moments and timing
Routing approachArchitecture-aware SWAP and bridge insertionSABRE-based heuristicsBasic and contributed routers
TKET and related compilation tools

In practice teams often combine tools: they build a circuit in one framework and compare compiled two-qubit gate counts across compilers before choosing what to run.

Practical use, limitations and common mistakes

Most users call a backend method that returns a compiled circuit for a chosen optimization level, then submit it and retrieve shot results. Advanced users write custom pass sequences for specific algorithm families, such as preserving Pauli structure until late in compilation.

  • Compiling before choosing the backend wastes effort, because routing and rebasing depend on the target device.
  • Decomposing boxes too early destroys the structure that Pauli gadget synthesis needs.
  • Ignoring compile time on large circuits can be costly, since the most aggressive levels scale poorly with circuit size.
  • Pulse-level control is outside its scope: TKET works at the gate level, so pulse schedules belong to vendor tools.

Another frequent oversight concerns measurement and classical control. TKET supports mid-circuit measurement and conditional gates, but not every backend accepts them, and the predicate check will reject such circuits on devices without dynamic circuit support. Developers should also verify results on a noiseless simulator first, because a compilation that is formally valid can still hide a modeling error in the original circuit. Finally, versions of pytket and its extensions should be kept aligned, since mismatched releases are a common source of import and conversion failures.

In everyday language

Different quantum computers understand different basic operations and connect their qubits in different ways. A program written for one machine will often not run well, or at all, on another.

TKET is like a skilled translator and editor in one. It takes a quantum program, removes unnecessary steps, and rewrites it in the dialect of the chosen machine. Shorter programs mean fewer errors on today’s noisy hardware.

Seen in the real world

A research group studying small molecules builds a unitary coupled cluster circuit with 12 qubits and several hundred Pauli exponentials. Written naively, the circuit contains well over a thousand CNOT gates, far too many for current devices.

The group represents the ansatz with Pauli boxes and runs TKET Pauli gadget synthesis followed by peephole optimization and routing for a trapped-ion emulator. The compiled circuit uses substantially fewer two-qubit gates, and the same source code is then compiled for a superconducting backend through another extension. Comparing both runs lets the team choose the device with the lower expected error before spending paid hardware time.