-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Move tket2 code to a workspace member #210
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for some reason github didn't recognize this file move |
||
|
||
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); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we set some kind of workspace environment variable or something to make this less flaky?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That will be a bit noisy, so I'll open an issue for that.