-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Move tket2 code to a workspace member (#210)
Moves the `tket2` crate code to `./tket2/`, and adds it to the workspace. This is mostly for cleaning up, as part of the python module cleanup task. As a drive-by, makes sure that all the `Cargo.toml`s shale the workspace metadata.
- Loading branch information
Showing
46 changed files
with
160 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
[package] | ||
name = "compile-matcher" | ||
version = "0.1.0" | ||
edition = "2021" | ||
edition = { workspace = true } | ||
version = { workspace = true } | ||
rust-version = { workspace = true } | ||
homepage = { workspace = true } | ||
license-file = { workspace = true } | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
clap = { version = "4.4.2", features = ["derive"] } | ||
tket2 = { path = "../", features = ["portmatching"] } | ||
tket2 = { workspace = true, features = ["portmatching"] } | ||
quantinuum-hugr = { workspace = true } | ||
itertools = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
[package] | ||
name = "tket2" | ||
edition = { workspace = true } | ||
version = { workspace = true } | ||
rust-version = { workspace = true } | ||
homepage = { workspace = true } | ||
license-file = { workspace = true } | ||
|
||
[lib] | ||
bench = false | ||
name = "tket2" | ||
path = "src/lib.rs" | ||
|
||
[features] | ||
pyo3 = [ | ||
"dep:pyo3", | ||
"tket-json-rs/pyo3", | ||
"portgraph/pyo3", | ||
"quantinuum-hugr/pyo3", | ||
] | ||
portmatching = ["dep:portmatching", "dep:rmp-serde"] | ||
|
||
[dependencies] | ||
lazy_static = "1.4.0" | ||
cgmath = "0.18.0" | ||
num-rational = "0.4" | ||
num-complex = { version = "0.4", optional = true } | ||
tket-json-rs = { workspace = true } | ||
rayon = "1.5" | ||
thiserror = "1.0.28" | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_json = "1.0" | ||
downcast-rs = "1.2.0" | ||
priority-queue = "1.3.0" | ||
smol_str = "0.2.0" | ||
typetag = "0.2.8" | ||
itertools = { workspace = true } | ||
petgraph = { version = "0.6.3", default-features = false } | ||
serde_yaml = "0.9.22" | ||
# portmatching = { version = "0.2.0", optional = true, features = ["serde"]} | ||
portmatching = { optional = true, git = "https://github.com/lmondada/portmatching", rev = "738c91c", features = [ | ||
"serde", | ||
] } | ||
derive_more = "0.99.17" | ||
quantinuum-hugr = { workspace = true } | ||
portgraph = { workspace = true, features = ["serde"] } | ||
pyo3 = { workspace = true, optional = true, features = ["multiple-pymethods"] } | ||
strum_macros = "0.25.2" | ||
strum = "0.25.0" | ||
fxhash = "0.2.1" | ||
rmp-serde = { version = "1.1.2", optional = true } | ||
delegate = "0.10.0" | ||
csv = { version = "1.2.2" } | ||
chrono = { version = "0.4.30" } | ||
bytemuck = "1.14.0" | ||
stringreader = "0.1.1" | ||
crossbeam-channel = "0.5.8" | ||
tracing = { workspace = true } | ||
|
||
[dev-dependencies] | ||
rstest = "0.18.1" | ||
criterion = { version = "0.5.1", features = ["html_reports"] } | ||
webbrowser = "0.8.10" | ||
urlencoding = "2.1.2" | ||
|
||
[[bench]] | ||
name = "bench_main" | ||
harness = false |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#![cfg(feature = "portmatching")] | ||
|
||
use hugr::Hugr; | ||
use rstest::{fixture, rstest}; | ||
use tket2::{ | ||
json::TKETDecode, | ||
optimiser::{DefaultTasoOptimiser, TasoOptimiser}, | ||
Circuit, | ||
}; | ||
use tket_json_rs::circuit_json::SerialCircuit; | ||
|
||
/// A set of equivalence circuit classes (ECC) | ||
/// | ||
/// This is the complete set of ECCs for 2-qubit circuits with up to | ||
/// 4 gates, using the NAM gateset (CX, Rz, H). | ||
#[fixture] | ||
fn nam_4_2() -> DefaultTasoOptimiser { | ||
TasoOptimiser::default_with_eccs_json_file("../test_files/Nam_4_2_complete_ECC_set.json") | ||
.unwrap() | ||
} | ||
|
||
/// The following circuit | ||
/// ┌──────────┐ ┌───────────┐ | ||
///q_0: ──■──┤ Rz(π/10) ├──■─────────────────────────■────■──┤ Rz(-π/10) ├ | ||
/// │ └──────────┘┌─┴─┐┌───┐┌─────────┐┌───┐┌─┴─┐ │ └───────────┘ | ||
///q_1: ──┼──────────────┤ X ├┤ H ├┤ Rz(π/5) ├┤ H ├┤ X ├──┼─────────────── | ||
/// ┌─┴─┐ └───┘└───┘└─────────┘└───┘└───┘┌─┴─┐ | ||
///q_2: ┤ X ├───────────────────────────────────────────┤ X ├───────────── | ||
/// └───┘ └───┘ | ||
#[fixture] | ||
fn simple_circ() -> Hugr { | ||
// The TK1 json of the circuit | ||
let json = r#"{ | ||
"bits": [], | ||
"commands": [ | ||
{"args": [["q", [0]], ["q", [2]]], "op": {"type": "CX"}}, | ||
{"args": [["q", [0]]], "op": {"params": ["0.1"], "type": "Rz"}}, | ||
{"args": [["q", [0]], ["q", [1]]], "op": {"type": "CX"}}, | ||
{"args": [["q", [1]]], "op": {"type": "H"}}, | ||
{"args": [["q", [1]]], "op": {"params": ["0.2"], "type": "Rz"}}, | ||
{"args": [["q", [1]]], "op": {"type": "H"}}, | ||
{"args": [["q", [0]], ["q", [1]]], "op": {"type": "CX"}}, | ||
{"args": [["q", [0]], ["q", [2]]], "op": {"type": "CX"}}, | ||
{"args": [["q", [0]]], "op": {"params": ["-0.1"], "type": "Rz"}}], | ||
"created_qubits": [], | ||
"discarded_qubits": [], | ||
"implicit_permutation": [ | ||
[["q", [0]], ["q", [0]]], [["q", [1]], ["q", [1]]], [["q", [2]], ["q", [2]]] | ||
], | ||
"phase": "0.0", | ||
"qubits": [["q", [0]], ["q", [1]], ["q", [2]]] | ||
}"#; | ||
let ser: SerialCircuit = serde_json::from_str(json).unwrap(); | ||
ser.decode().unwrap() | ||
} | ||
|
||
#[rstest] | ||
//#[ignore = "Takes 200ms"] | ||
fn taso_termination(simple_circ: Hugr, nam_4_2: DefaultTasoOptimiser) { | ||
let opt_circ = nam_4_2.optimise(&simple_circ, None, 1.try_into().unwrap(), false, 10); | ||
assert_eq!(opt_circ.commands().count(), 11); | ||
} |