-
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
fix: Support hugr packages, fix the notebooks #622
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #622 +/- ##
==========================================
- Coverage 82.13% 82.06% -0.08%
==========================================
Files 48 48
Lines 6550 6556 +6
Branches 6550 6556 +6
==========================================
Hits 5380 5380
- Misses 812 818 +6
Partials 358 358
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Note that the guppy parsing is not currently tested, since we want to avoid cyclic dev dependencies. |
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.
This is great, thank you
.map_err(|e| PyErr::new::<PyAttributeError, _>(format!("Invalid encoded HUGR: {e}")))?; | ||
Ok(Tk2Circuit { circ: hugr.into() }) | ||
let mut reg = REGISTRY.clone(); | ||
let mut hugrs = pkg.validate(&mut reg).map_err(|e| { |
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.
There is nastiness with mismatched extensions here. What happens when the in-package registry and our REGISTRY have different versions of the same extension? Nothing to do for now I think.
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.
Yeah, currently we merge the extensions and keep the latest one but I see how that may cause problems.
https://github.com/CQCL/hugr/blob/836b6656adc4f014f1182a39e403184f7f8d45e7/hugr-core/src/extension.rs#L90-L95
## 🤖 New release * `tket2`: 0.4.0 -> 0.5.0 (⚠️ API breaking changes) * `tket2-hseries`: 0.4.0 -> 0.5.0 (⚠️ API breaking changes) ###⚠️ `tket2` breaking changes ``` --- failure enum_marked_non_exhaustive: enum marked #[non_exhaustive] --- Description: A public enum has been marked #[non_exhaustive]. Pattern-matching on it outside of its crate must now include a wildcard pattern like `_`, or it will fail to compile. ref: https://doc.rust-lang.org/cargo/reference/semver.html#attr-adding-non-exhaustive impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.35.0/src/lints/enum_marked_non_exhaustive.ron Failed in: enum InvalidPatternMatch in /tmp/.tmp7zsbCi/tket2/tket2/src/portmatching/matcher.rs:376 enum MatcherSerialisationError in /tmp/.tmp7zsbCi/tket2/tket2/src/portmatching/matcher.rs:401 enum CircuitError in /tmp/.tmp7zsbCi/tket2/tket2/src/circuit.rs:458 enum CircuitError in /tmp/.tmp7zsbCi/tket2/tket2/src/circuit.rs:458 enum RewriterSerialisationError in /tmp/.tmp7zsbCi/tket2/tket2/src/rewrite/ecc_rewriter.rs:209 enum PullForwardError in /tmp/.tmp7zsbCi/tket2/tket2/src/passes/commutation.rs:187 enum CircuitLoadError in /tmp/.tmp7zsbCi/tket2/tket2/src/serialize/guppy.rs:114 enum CircuitLoadError in /tmp/.tmp7zsbCi/tket2/tket2/src/serialize/guppy.rs:114 enum CircuitMutError in /tmp/.tmp7zsbCi/tket2/tket2/src/circuit.rs:495 enum CircuitMutError in /tmp/.tmp7zsbCi/tket2/tket2/src/circuit.rs:495 --- failure enum_tuple_variant_changed_kind: An enum tuple variant changed kind --- Description: A public enum's exhaustive tuple variant has changed to a different kind of enum variant, breaking possible instantiations and patterns. ref: https://doc.rust-lang.org/reference/items/enumerations.html impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.35.0/src/lints/enum_tuple_variant_changed_kind.ron Failed in: variant PullForwardError::NoQbInCommand in /tmp/.tmp7zsbCi/tket2/tket2/src/passes/commutation.rs:194 variant PullForwardError::NoCommandForQb in /tmp/.tmp7zsbCi/tket2/tket2/src/passes/commutation.rs:200 variant CircuitMutError::DeleteNonEmptyWire in /tmp/.tmp7zsbCi/tket2/tket2/src/circuit.rs:504 variant CircuitMutError::InvalidPortOffset in /tmp/.tmp7zsbCi/tket2/tket2/src/circuit.rs:512 variant CircuitMutError::DeleteNonEmptyWire in /tmp/.tmp7zsbCi/tket2/tket2/src/circuit.rs:504 variant CircuitMutError::InvalidPortOffset in /tmp/.tmp7zsbCi/tket2/tket2/src/circuit.rs:512 ``` ###⚠️ `tket2-hseries` breaking changes ``` --- failure enum_marked_non_exhaustive: enum marked #[non_exhaustive] --- Description: A public enum has been marked #[non_exhaustive]. Pattern-matching on it outside of its crate must now include a wildcard pattern like `_`, or it will fail to compile. ref: https://doc.rust-lang.org/cargo/reference/semver.html#attr-adding-non-exhaustive impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.35.0/src/lints/enum_marked_non_exhaustive.ron Failed in: enum HSeriesPassError in /tmp/.tmp7zsbCi/tket2/tket2-hseries/src/lib.rs:38 enum LazifyMeasurePassError in /tmp/.tmp7zsbCi/tket2/tket2-hseries/src/lazify_measure.rs:45 enum LowerTk2Error in /tmp/.tmp7zsbCi/tket2/tket2-hseries/src/extension/hseries/lower.rs:41 --- failure enum_tuple_variant_changed_kind: An enum tuple variant changed kind --- Description: A public enum's exhaustive tuple variant has changed to a different kind of enum variant, breaking possible instantiations and patterns. ref: https://doc.rust-lang.org/reference/items/enumerations.html impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.35.0/src/lints/enum_tuple_variant_changed_kind.ron Failed in: variant LowerTk2Error::Unlowered in /tmp/.tmp7zsbCi/tket2/tket2-hseries/src/extension/hseries/lower.rs:57 ``` <details><summary><i><b>Changelog</b></i></summary><p> ## `tket2` <blockquote> ## [0.5.0](tket2-v0.4.0...tket2-v0.5.0) - 2024-09-30 ### Bug Fixes - Support hugr packages, fix the notebooks ([#622](#622)) ### New Features - Add an explicit struct for the tket2 sympy op ([#616](#616)) - Support encoding float and sympy ops ([#618](#618)) </blockquote> ## `tket2-hseries` <blockquote> ## [0.4.0](tket2-hseries-v0.3.0...tket2-hseries-v0.4.0) - 2024-09-16 ### New Features - [**breaking**] `HSeriesPass` lowers `Tk2Op`s into `HSeriesOp`s ([#602](#602)) - [**breaking**] simplify angle extension in to a half turns rotation type ([#611](#611)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/MarcoIeni/release-plz/).
🤖 I have created a release *beep* *boop* --- ## [0.4.0](tket2-py-v0.3.0...tket2-py-v0.4.0) (2024-10-01) ### ⚠ BREAKING CHANGES * Made all errors `non_exhaustive`, and renamed some fields for clarity. * "tket2.angle" extension replaced with "tket2.rotation" extension with rotation type and simplified set of operations. * TryFrom implementations for extension op structs removed, use `cast` ### Features * `BadgerOptimiser.load_precompiled`, `BadgerOptimiser.compile_eccs` and `passes.badger_pass` now take an optional `cost_fn` parameter to specify the cost function to minimise. Supported values are `'cx'` (default behaviour) and `'rz'`. ([83ebfcb](83ebfcb)) * simplify angle extension in to a half turns rotation type ([#611](#611)) ([0723937](0723937)) * Support encoding float and sympy ops ([#618](#618)) ([74dcbf7](74dcbf7)) * **tket2-hseries:** cli extension dumping ([#584](#584)) ([abf292f](abf292f)) ### Bug Fixes * remove TryFrom for extension ops use `cast` ([#592](#592)) ([5ca29af](5ca29af)) * Support hugr packages, fix the notebooks ([#622](#622)) ([1cf9dcb](1cf9dcb)) ### Documentation * Add tket2-py module docstring ([#539](#539)) ([8ef7a57](8ef7a57)) ### Miscellaneous Chores * Replace thiserror with derive_more 1.0 ([#624](#624)) ([2250ce7](2250ce7)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: Agustín Borgna <[email protected]> Co-authored-by: Agustín Borgna <[email protected]>
This is a small bundle of changes aimed at fixing the example notebooks.
hugr-cli
, since packages are currently defined there. See MovePackage
out ofhugr-cli
hugr#1530The
guppy -> pytket
pipeline is still broken, as guppy now generates many more function calls and nested control flow primitives, which we do not currently support.drive-by: Make
crate::serialize::guppy::find_function
public.Closes #621.