-
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.
BREAKING CHANGE: require `hugr-0.5.0`
- Loading branch information
Showing
10 changed files
with
238 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
Empty file.
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,33 @@ | ||
[package] | ||
name = "tket2-hseries" | ||
version = "0.1.0-alpha.1" | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
|
||
license.workspace = true | ||
readme = "README.md" | ||
documentation = "https://docs.rs/tket2-hseries" | ||
homepage.workspace = true | ||
repository.workspace = true | ||
description = "TKET2 tool for preparing and validating `Hugr`s for compilation targeting Quantinuum H-series quantum computers" | ||
keywords = ["Quantum", "Quantinuum"] | ||
categories = ["compilers"] | ||
|
||
[features] | ||
default = ["cli"] | ||
cli = ["dep:hugr-cli", "dep:clap"] | ||
|
||
[dependencies] | ||
hugr.workspace = true | ||
hugr-cli = { workspace = true, optional = true } | ||
clap = { workspace = true, optional = true, features = ["derive"] } | ||
tket2 = { path = "../tket2", version = "0.1.0-alpha.1" } | ||
serde_json.workspace = true | ||
lazy_static.workspace = true | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[[bin]] | ||
name = "tket2-hseries" | ||
required-features = ["cli"] |
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,34 @@ | ||
# tket2-hseries | ||
|
||
![msrv][] | ||
|
||
A TKET2 tool for preparing and validating `Hugr`s for compilation targeting | ||
Quantinuum H-series quantum computers. | ||
|
||
## Usage | ||
|
||
Install using `cargo`: | ||
|
||
```bash | ||
cargo install tket2-hseries | ||
``` | ||
|
||
This will install the `tket2-hseries` binary. | ||
|
||
## Recent Changes | ||
|
||
See [CHANGELOG][] for a list of changes. The minimum supported rust | ||
version will only change on major releases. | ||
|
||
## Development | ||
|
||
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). | ||
|
||
[msrv]: https://img.shields.io/badge/rust-1.75.0%2B-blue.svg | ||
[LICENSE]: https://github.com/CQCL/tket2/blob/main/LICENCE | ||
[CHANGELOG]: https://github.com/CQCL/tket2/blob/main/tket2-hseries/CHANGELOG.mdd | ||
[DEVELOPMENT.md]: https://github.com/CQCL/tket2/blob/main/DEVELOPMENT.md |
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,50 @@ | ||
//! Provides a command line interface to tket2-hseries | ||
use clap::Parser; | ||
use hugr::std_extensions::arithmetic::{ | ||
conversions::EXTENSION as CONVERSIONS_EXTENSION, float_ops::EXTENSION as FLOAT_OPS_EXTENSION, | ||
float_types::EXTENSION as FLOAT_TYPES_EXTENSION, int_ops::EXTENSION as INT_OPS_EXTENSION, | ||
int_types::EXTENSION as INT_TYPES_EXTENSION, | ||
}; | ||
use hugr::std_extensions::logic::EXTENSION as LOGICS_EXTENSION; | ||
|
||
use hugr::extension::{ExtensionRegistry, PRELUDE}; | ||
use lazy_static::lazy_static; | ||
|
||
lazy_static! { | ||
/// A registry suitable for passing to `run`. Use this unless you have a | ||
/// good reason not to do so. | ||
pub static ref REGISTRY: ExtensionRegistry = ExtensionRegistry::try_new([ | ||
PRELUDE.to_owned(), | ||
INT_OPS_EXTENSION.to_owned(), | ||
INT_TYPES_EXTENSION.to_owned(), | ||
CONVERSIONS_EXTENSION.to_owned(), | ||
FLOAT_OPS_EXTENSION.to_owned(), | ||
FLOAT_TYPES_EXTENSION.to_owned(), | ||
LOGICS_EXTENSION.to_owned(), | ||
]) | ||
.unwrap(); | ||
} | ||
|
||
/// Arguments for `run`. | ||
#[derive(Parser, Debug)] | ||
#[command(version, about)] | ||
pub struct CmdLineArgs { | ||
#[command(flatten)] | ||
base: hugr_cli::CmdLineArgs, | ||
} | ||
|
||
impl CmdLineArgs { | ||
/// Run the ngrte preparation and validation workflow with the given | ||
/// registry. | ||
pub fn run(&self, registry: &ExtensionRegistry) -> Result<(), hugr_cli::CliError> { | ||
let mut hugr = self.base.run(registry)?; | ||
crate::prepare_ngrte(&mut hugr).unwrap(); | ||
serde_json::to_writer_pretty(std::io::stdout(), &hugr)?; | ||
Ok(()) | ||
} | ||
|
||
/// Test whether a `level` message should be output. | ||
pub fn verbosity(&self, level: hugr_cli::Level) -> bool { | ||
self.base.verbosity(level) | ||
} | ||
} |
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,14 @@ | ||
//! Provides a preparation and validation workflow for Hugrs targeting | ||
//! Quantinuum H-series quantum computers. | ||
|
||
use hugr::Hugr; | ||
|
||
#[cfg(feature = "cli")] | ||
pub mod cli; | ||
|
||
/// Modify a [Hugr] into a form that is acceptable for ingress into an H-series. | ||
/// | ||
/// Returns an error if this cannot be done. | ||
pub fn prepare_ngrte(#[allow(unused)] hugr: &mut Hugr) -> Result<(), Box<dyn std::error::Error>> { | ||
Ok(()) | ||
} |
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,16 @@ | ||
//! A command line interface to tket2-hseries | ||
use hugr_cli::{Level, Parser as _}; | ||
use tket2_hseries::cli; | ||
|
||
fn main() { | ||
let opts = cli::CmdLineArgs::parse(); | ||
let registry = &cli::REGISTRY; | ||
|
||
// validate with all std extensions | ||
if let Err(e) = opts.run(registry) { | ||
if opts.verbosity(Level::Error) { | ||
eprintln!("{}", e); | ||
} | ||
std::process::exit(1); | ||
} | ||
} |
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