Skip to content
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

chore: Update hugr dependency #535

Merged
merged 5 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
45 changes: 40 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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',
]

Expand Down
Binary file modified test_files/eccs/nam_4_2.rwr
Binary file not shown.
Binary file modified test_files/eccs/nam_6_3.rwr
Binary file not shown.
Binary file modified test_files/eccs/small_eccs.rwr
Binary file not shown.
Binary file modified tket2-eccs/src/tket2_eccs/data/nam_6_3.rwr
Binary file not shown.
6 changes: 4 additions & 2 deletions tket2-hseries/src/extension/futures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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();
Expand Down
6 changes: 4 additions & 2 deletions tket2-hseries/src/extension/quantum_lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
};
Expand Down
6 changes: 4 additions & 2 deletions tket2-hseries/src/extension/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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
};
Expand Down
14 changes: 11 additions & 3 deletions tket2/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -27,14 +29,17 @@ 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 =
TKET1_EXTENSION.get_type(&TKET1_PAYLOAD_NAME).unwrap().instantiate([]).unwrap();

/// 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(
Expand Down Expand Up @@ -94,14 +99,17 @@ 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 =
TKET2_EXTENSION.get_type(&SYM_EXPR_NAME).unwrap().instantiate([]).unwrap();

/// 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(
Expand Down
8 changes: 2 additions & 6 deletions tket2/src/passes/pytket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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)?;
Expand Down
Loading