diff --git a/Cargo.lock b/Cargo.lock index 48534de6..79720f8c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -720,9 +720,9 @@ dependencies = [ [[package]] name = "hugr" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daa4ecfcad4aaf337f974e196e0b79ac9288a19535a5b57c9c77f0aaed1d0c6a" +checksum = "888ee8f56c9e2788b9d74162e2d057426fae9d5cfe4167c415c20260754ea433" dependencies = [ "hugr-core", "hugr-passes", @@ -730,9 +730,9 @@ dependencies = [ [[package]] name = "hugr-core" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7de0f6d5bd8ce765a989d928a773b6816b89051bdf1da55d27ac2b6965fa0e07" +checksum = "ff8a7da4d5b36861d0695e7b9bc3120099bc2b579642e33886022b3e65c92d16" dependencies = [ "bitvec", "cgmath", @@ -749,6 +749,7 @@ dependencies = [ "petgraph", "portgraph 0.12.2", "regex", + "semver", "serde", "serde_json", "smol_str", @@ -760,9 +761,9 @@ dependencies = [ [[package]] name = "hugr-passes" -version = "0.6.2" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c601b2bc2168e841cb1087f2f7d383a4cace5c9926e10e79e2dd4829cd6758" +checksum = "75f2dd0e0c842e9513532b3025420dfdb5fed2db511cc83c749f964b25982bc8" dependencies = [ "hugr-core", "itertools 0.13.0", @@ -1515,6 +1516,9 @@ name = "semver" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" +dependencies = [ + "serde", +] [[package]] name = "serde" diff --git a/Cargo.toml b/Cargo.toml index 3a8e3cc4..e9dc4c38 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,8 +26,8 @@ missing_docs = "warn" [workspace.dependencies] # Make sure to run `just recompile-eccs` if the hugr serialisation format changes. -hugr = "0.10.0" -hugr-core = "0.7.0" +hugr = "0.11.0" +hugr-core = "0.8.0" portgraph = "0.12" pyo3 = "0.21.2" itertools = "0.13.0" diff --git a/poetry.lock b/poetry.lock index c2dd79e2..40781175 100644 --- a/poetry.lock +++ b/poetry.lock @@ -178,17 +178,19 @@ test = ["coverage", "pytest (>=7,<8.1)", "pytest-cov", "pytest-mock (>=3)"] [[package]] name = "hugr" -version = "0.5.0" +version = "0.6.0" description = "Quantinuum's common representation for quantum programs" optional = false python-versions = ">=3.10" files = [ - {file = "hugr-0.5.0-py3-none-any.whl", hash = "sha256:7e6c6660e3c7143dd5b89bf429e3ccc68add0d329db4ac35076e7692d2899326"}, - {file = "hugr-0.5.0.tar.gz", hash = "sha256:c362e19e6842c89d00c9eab8e3afe161a380459ecb212374ecb78e4081964f15"}, + {file = "hugr-0.6.0-py3-none-any.whl", hash = "sha256:fd08362a2d7723eacd9aecd47b1a9fc6e9434dc1edbd0b97e81df6c53bcbdc9e"}, + {file = "hugr-0.6.0.tar.gz", hash = "sha256:6070503d5b01b2a8abfe4152cb023661e92cecec4c881793be6263f86435bf2f"}, ] [package.dependencies] pydantic = ">=2.7,<2.9" +pydantic-extra-types = ">=2.9.0,<3.0.0" +semver = ">=3.0.2,<4.0.0" [[package]] name = "hypothesis" @@ -721,6 +723,28 @@ files = [ [package.dependencies] typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0" +[[package]] +name = "pydantic-extra-types" +version = "2.9.0" +description = "Extra Pydantic types." +optional = false +python-versions = ">=3.8" +files = [ + {file = "pydantic_extra_types-2.9.0-py3-none-any.whl", hash = "sha256:f0bb975508572ba7bf3390b7337807588463b7248587e69f43b1ad7c797530d0"}, + {file = "pydantic_extra_types-2.9.0.tar.gz", hash = "sha256:e061c01636188743bb69f368dcd391f327b8cfbfede2fe1cbb1211b06601ba3b"}, +] + +[package.dependencies] +pydantic = ">=2.5.2" + +[package.extras] +all = ["pendulum (>=3.0.0,<4.0.0)", "phonenumbers (>=8,<9)", "pycountry (>=23)", "python-ulid (>=1,<2)", "python-ulid (>=1,<3)", "pytz (>=2024.1)", "semver (>=3.0.2)", "tzdata (>=2024.1)"] +pendulum = ["pendulum (>=3.0.0,<4.0.0)"] +phonenumbers = ["phonenumbers (>=8,<9)"] +pycountry = ["pycountry (>=23)"] +python-ulid = ["python-ulid (>=1,<2)", "python-ulid (>=1,<3)"] +semver = ["semver (>=3.0.2)"] + [[package]] name = "pytest" version = "8.3.2" @@ -942,6 +966,17 @@ dev = ["cython-lint (>=0.12.2)", "doit (>=0.36.0)", "mypy (==1.10.0)", "pycodest doc = ["jupyterlite-pyodide-kernel", "jupyterlite-sphinx (>=0.13.1)", "jupytext", "matplotlib (>=3.5)", "myst-nb", "numpydoc", "pooch", "pydata-sphinx-theme (>=0.15.2)", "sphinx (>=5.0.0)", "sphinx-design (>=0.4.0)"] test = ["Cython", "array-api-strict", "asv", "gmpy2", "hypothesis (>=6.30)", "meson", "mpmath", "ninja", "pooch", "pytest", "pytest-cov", "pytest-timeout", "pytest-xdist", "scikit-umfpack", "threadpoolctl"] +[[package]] +name = "semver" +version = "3.0.2" +description = "Python helper for Semantic Versioning (https://semver.org)" +optional = false +python-versions = ">=3.7" +files = [ + {file = "semver-3.0.2-py3-none-any.whl", hash = "sha256:b1ea4686fe70b981f85359eda33199d60c53964284e0cfb4977d243e37cf4bf4"}, + {file = "semver-3.0.2.tar.gz", hash = "sha256:6253adb39c70f6e51afed2fa7152bcd414c411286088fb4b9effb133885ab4cc"}, +] + [[package]] name = "setuptools" version = "72.1.0" @@ -988,7 +1023,7 @@ dev = ["hypothesis (>=6.70.0)", "pytest (>=7.1.0)"] [[package]] name = "tket2-eccs" -version = "0.1.0a4" +version = "0.1.0" description = "Precompiled rewrite sets for the tket 2 compiler" optional = false python-versions = "^3.10" @@ -1044,4 +1079,4 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "b95cccc876bf1e0b33d1790780d84a50001dfffa49a516c3386d309243fe37cf" +content-hash = "d65274422e54bbb3c1a61bc7a584ac8584b5d0bac5874533a953524a2e4f3769" diff --git a/pyproject.toml b/pyproject.toml index cc3d438d..7c015fea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ python = "^3.10" # https://github.com/python-poetry/poetry/issues/3332 tket2_eccs = { path = "tket2-eccs", develop = true } pytket = "1.31.1" -hugr = "^0.5.0" +hugr = "^0.6.0" [tool.poetry.group.dev.dependencies] maturin = "^1.7.0" @@ -77,7 +77,7 @@ license = { file = "LICENCE" } # Note: Be sure to update the dependency versions in [tool.poetry.dependencies] as well dependencies = [ 'pytket >= 1.29.2, < 2', - 'hugr >= 0.5.0, < 0.6', + 'hugr >= 0.6.0, < 0.7', 'tket2_eccs >= 0.1.0, < 0.2', ] diff --git a/test_files/eccs/nam_4_2.rwr b/test_files/eccs/nam_4_2.rwr index 84858952..22ab3f52 100644 Binary files a/test_files/eccs/nam_4_2.rwr and b/test_files/eccs/nam_4_2.rwr differ diff --git a/test_files/eccs/nam_6_3.rwr b/test_files/eccs/nam_6_3.rwr index f3680602..66961a72 100644 Binary files a/test_files/eccs/nam_6_3.rwr and b/test_files/eccs/nam_6_3.rwr differ diff --git a/test_files/eccs/small_eccs.rwr b/test_files/eccs/small_eccs.rwr index da60153c..45230ed4 100644 Binary files a/test_files/eccs/small_eccs.rwr and b/test_files/eccs/small_eccs.rwr differ diff --git a/tket2-eccs/src/tket2_eccs/data/nam_6_3.rwr b/tket2-eccs/src/tket2_eccs/data/nam_6_3.rwr index f3680602..66961a72 100644 Binary files a/tket2-eccs/src/tket2_eccs/data/nam_6_3.rwr and b/tket2-eccs/src/tket2_eccs/data/nam_6_3.rwr differ diff --git a/tket2-hseries/src/extension/futures.rs b/tket2-hseries/src/extension/futures.rs index d7378231..4fb4bb22 100644 --- a/tket2-hseries/src/extension/futures.rs +++ b/tket2-hseries/src/extension/futures.rs @@ -11,7 +11,7 @@ use hugr::{ OpLoadError, }, ExtensionBuildError, ExtensionId, ExtensionRegistry, OpDef, SignatureError, SignatureFunc, - TypeDef, + TypeDef, Version, }, ops::{custom::ExtensionOp, NamedOp, OpType}, types::{type_param::TypeParam, CustomType, PolyFuncType, Signature, Type, TypeArg, TypeBound}, @@ -24,11 +24,13 @@ use strum_macros::{EnumIter, EnumString, IntoStaticStr}; /// The ID of the `tket2.futures` extension. pub const EXTENSION_ID: ExtensionId = ExtensionId::new_unchecked("tket2.futures"); +/// The "tket2.futures" extension version +pub const EXTENSION_VERSION: Version = Version::new(0, 1, 0); lazy_static! { /// The "tket2.futures" extension. pub static ref EXTENSION: Extension = { - let mut ext = Extension::new(EXTENSION_ID); + let mut ext = Extension::new(EXTENSION_ID, EXTENSION_VERSION); let _ = add_future_type_def(&mut ext).unwrap(); FutureOpDef::load_all_ops(&mut ext).unwrap(); diff --git a/tket2-hseries/src/extension/quantum_lazy.rs b/tket2-hseries/src/extension/quantum_lazy.rs index 72dc3f11..02ec4fe7 100644 --- a/tket2-hseries/src/extension/quantum_lazy.rs +++ b/tket2-hseries/src/extension/quantum_lazy.rs @@ -8,7 +8,7 @@ use hugr::{ extension::{ prelude::{BOOL_T, QB_T}, simple_op::{try_from_name, MakeOpDef, MakeRegisteredOp, OpLoadError}, - ExtensionId, ExtensionRegistry, OpDef, SignatureFunc, PRELUDE, + ExtensionId, ExtensionRegistry, OpDef, SignatureFunc, Version, PRELUDE, }, ops::{NamedOp as _, OpType}, types::Signature, @@ -24,11 +24,13 @@ use super::futures::future_type; /// The "tket2.quantum.lazy" extension id. pub const EXTENSION_ID: ExtensionId = ExtensionId::new_unchecked("tket2.quantum.lazy"); +/// The "tket2.quantum.lazy" extension version. +pub const EXTENSION_VERSION: Version = Version::new(0, 1, 0); lazy_static! { /// The "tket2.quantum.lazy" extension. pub static ref EXTENSION: Extension = { - let mut ext = Extension::new(EXTENSION_ID); + let mut ext = Extension::new(EXTENSION_ID, EXTENSION_VERSION); LazyQuantumOp::load_all_ops(&mut ext).unwrap(); ext }; diff --git a/tket2-hseries/src/extension/result.rs b/tket2-hseries/src/extension/result.rs index b0264693..ff0e7e35 100644 --- a/tket2-hseries/src/extension/result.rs +++ b/tket2-hseries/src/extension/result.rs @@ -7,7 +7,7 @@ use hugr::{ extension::{ prelude::{self, BOOL_T, PRELUDE}, simple_op::{try_from_name, MakeExtensionOp, MakeOpDef, MakeRegisteredOp, OpLoadError}, - ExtensionId, ExtensionRegistry, ExtensionSet, OpDef, SignatureFunc, + ExtensionId, ExtensionRegistry, ExtensionSet, OpDef, SignatureFunc, Version, }, ops::{CustomOp, NamedOp, OpType}, std_extensions::arithmetic::{ @@ -30,11 +30,13 @@ use strum_macros::{EnumIter, EnumString, IntoStaticStr}; /// The "tket2.result" extension id. pub const EXTENSION_ID: ExtensionId = ExtensionId::new_unchecked("tket2.result"); +/// The "tket2.result" extension version. +pub const EXTENSION_VERSION: Version = Version::new(0, 1, 0); lazy_static! { /// The "tket2.result" extension. pub static ref EXTENSION: Extension = { - let mut ext = Extension::new_with_reqs(EXTENSION_ID, ExtensionSet::from_iter([INT_EXTENSION_ID, FLOAT_EXTENSION_ID])); + let mut ext = Extension::new(EXTENSION_ID, EXTENSION_VERSION).with_reqs(ExtensionSet::from_iter([INT_EXTENSION_ID, FLOAT_EXTENSION_ID])); ResultOpDef::load_all_ops(&mut ext).unwrap(); ext }; diff --git a/tket2/src/extension.rs b/tket2/src/extension.rs index 7636b8fe..b27dd67b 100644 --- a/tket2/src/extension.rs +++ b/tket2/src/extension.rs @@ -6,7 +6,9 @@ use crate::serialize::pytket::OpaqueTk1Op; use crate::Tk2Op; use hugr::extension::prelude::PRELUDE; use hugr::extension::simple_op::MakeOpDef; -use hugr::extension::{CustomSignatureFunc, ExtensionId, ExtensionRegistry, SignatureError}; +use hugr::extension::{ + CustomSignatureFunc, ExtensionId, ExtensionRegistry, SignatureError, Version, +}; use hugr::hugr::IdentList; use hugr::std_extensions::arithmetic::float_types::{EXTENSION as FLOAT_EXTENSION, FLOAT64_TYPE}; use hugr::types::type_param::{TypeArg, TypeParam}; @@ -27,6 +29,9 @@ pub const TKET1_OP_NAME: SmolStr = SmolStr::new_inline("TKET1 Json Op"); /// The ID of an opaque TKET1 operation metadata. pub const TKET1_PAYLOAD_NAME: SmolStr = SmolStr::new_inline("TKET1 Json Payload"); +/// Current version of the TKET 1 extension +pub const TKET1_EXTENSION_VERSION: Version = Version::new(0, 1, 0); + lazy_static! { /// A custom type for the encoded TKET1 operation pub static ref TKET1_OP_PAYLOAD : CustomType = @@ -34,7 +39,7 @@ pub static ref TKET1_OP_PAYLOAD : CustomType = /// The TKET1 extension, containing the opaque TKET1 operations. pub static ref TKET1_EXTENSION: Extension = { - let mut res = Extension::new(TKET1_EXTENSION_ID); + let mut res = Extension::new(TKET1_EXTENSION_ID, TKET1_EXTENSION_VERSION); let tket1_op_payload = TypeParam::String; res.add_op( @@ -94,6 +99,9 @@ pub const SYM_EXPR_NAME: SmolStr = SmolStr::new_inline("SymExpr"); /// The name of the symbolic expression opaque type arg. pub const SYM_OP_ID: SmolStr = SmolStr::new_inline("symbolic_float"); +/// Current version of the TKET 2 extension +pub const TKET2_EXTENSION_VERSION: Version = Version::new(0, 1, 0); + lazy_static! { /// The type of the symbolic expression opaque type arg. pub static ref SYM_EXPR_T: CustomType = @@ -101,7 +109,7 @@ pub static ref SYM_EXPR_T: CustomType = /// The extension definition for TKET2 ops and types. pub static ref TKET2_EXTENSION: Extension = { - let mut e = Extension::new(TKET2_EXTENSION_ID); + let mut e = Extension::new(TKET2_EXTENSION_ID, TKET2_EXTENSION_VERSION); Tk2Op::load_all_ops(&mut e).expect("add fail"); e.add_op( diff --git a/tket2/src/passes/pytket.rs b/tket2/src/passes/pytket.rs index 87c7ecb8..33bd552c 100644 --- a/tket2/src/passes/pytket.rs +++ b/tket2/src/passes/pytket.rs @@ -49,7 +49,7 @@ mod test { Container, Dataflow, DataflowSubContainer, HugrBuilder, ModuleBuilder, SubContainer, }; use hugr::extension::prelude::QB_T; - use hugr::extension::{ExtensionSet, PRELUDE_REGISTRY}; + use hugr::extension::PRELUDE_REGISTRY; use hugr::ops::handle::NodeHandle; use hugr::ops::{MakeTuple, OpType, Tag, UnpackTuple}; use hugr::types::{Signature, TypeRow}; @@ -74,11 +74,7 @@ mod test { let [q1, q2] = func.input_wires_arr(); let cfg = { - let mut cfg = func.cfg_builder( - [(QB_T, q1), (QB_T, q2)], - two_qbs.clone(), - ExtensionSet::new(), - )?; + let mut cfg = func.cfg_builder([(QB_T, q1), (QB_T, q2)], two_qbs.clone())?; circ = { let mut dfg = cfg.simple_entry_builder(two_qbs.clone(), 1)?;