9 releases (5 breaking)

0.6.0 Oct 15, 2024
0.5.0 Oct 1, 2024
0.4.0 Sep 16, 2024
0.3.0 Sep 9, 2024
0.1.0-alpha.1 May 24, 2024

#42 in Programming languages

Download history 127/week @ 2024-07-29 8/week @ 2024-08-05 167/week @ 2024-08-12 112/week @ 2024-08-19 398/week @ 2024-08-26 316/week @ 2024-09-02 179/week @ 2024-09-09 390/week @ 2024-09-16 200/week @ 2024-09-23 353/week @ 2024-09-30 327/week @ 2024-10-07 687/week @ 2024-10-14 410/week @ 2024-10-21 255/week @ 2024-10-28 183/week @ 2024-11-04 186/week @ 2024-11-11

1,049 downloads per month
Used in 2 crates

Apache-2.0

445KB
9K SLoC

tket2: The Hardware Agnostic Quantum Compiler

build_status msrv codecov

TKET2 is an open source quantum compiler developed by Quantinuum. Central to TKET2's design is its hardware agnosticism which allows researchers and quantum software developers to take advantage of its powerful compilation for many different quantum architectures.

Circuits are represented using the HUGR IR defined in the hugr crate. TKET2 augments Hugr with

  • The Circuit trait, providing a high-level interface for working with HUGRs representing quantum circuits
  • a HUGR extension with quantum operations
  • A composable pass system for optimising circuits
  • A number of built-in rewrite utilities and passes for common optimisations

This crate is interoperable with tket1 circuits via its serial encoding.

Using TKET2

Defining a circuit in TKET2 is currently done by using the low-level hugr Builder API, or by loading tket1 circuits from JSON files.

use tket2::{Circuit, Hugr};

// Load a tket1 circuit.
let mut circ: Hugr = tket2::json::load_tk1_json_file("test_files/barenco_tof_5.json").unwrap();

assert_eq!(circ.qubit_count(), 9);
assert_eq!(circ.num_gates(), 170);

// Traverse the circuit and print the gates.
for command in circ.commands() {
    println!("{:?}", command.optype());
}

// Render the circuit as a mermaid diagram.
println!("{}", circ.mermaid_string());

// Optimise the circuit.
tket2::passes::apply_greedy_commutation(&mut circ);

Please read the API documentation here.

Features

  • portmatching Enables pattern matching using the portmatching crate.

  • rewrite-tracing Adds opt-in tracking of the rewrites applied to a circuit.

Recent Changes

See CHANGELOG for a list of changes. The minimum supported rust version will only change on major releases.

Developing TKET2

See DEVELOPMENT.md for instructions on setting up the development environment.

License

This project is licensed under Apache License, Version 2.0 (LICENSE or http://www.apache.org/licenses/LICENSE-2.0).

Dependencies

~18–30MB
~474K SLoC