feat: added hash.rs, updated imports#2840
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2840 +/- ##
==========================================
- Coverage 83.73% 83.71% -0.02%
==========================================
Files 264 266 +2
Lines 53101 53306 +205
Branches 47374 47579 +205
==========================================
+ Hits 44462 44623 +161
- Misses 6250 6276 +26
- Partials 2389 2407 +18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
hugr-passes/src/hash.rs
Outdated
| /// | ||
| /// Adapted from Quartz (Apache 2.0) | ||
| /// <https://github.com/quantum-compiler/quartz/blob/2e13eb7ffb3c5c5fe96cf5b4246f4fd7512e111e/src/quartz/tasograph/tasograph.cpp#L410> | ||
| fn hugr_hash(&self, node: Self::Node) -> Result<u64, HashError>; |
There was a problem hiding this comment.
Just a suggestion, but could we rename this to region_hash, and have a "whole hugr hash"?
fn hugr_hash(&self) -> Result<u64, HashError> {
self.region_hash(self.module_root())
}There was a problem hiding this comment.
Makes sense, I have used hugr.entrypoint() in tests though.
Co-authored-by: Agustín Borgna <[email protected]>
|
Also, see if you can import the hash benchmarks from |
## 🤖 New release * `hugr-model`: 0.25.5 -> 0.25.6 (✓ API compatible changes) * `hugr-core`: 0.25.5 -> 0.25.6 (✓ API compatible changes) * `hugr-llvm`: 0.25.5 -> 0.25.6 (✓ API compatible changes) * `hugr-passes`: 0.25.5 -> 0.25.6 (✓ API compatible changes) * `hugr`: 0.25.5 -> 0.25.6 (✓ API compatible changes) * `hugr-cli`: 0.25.5 -> 0.25.6 (✓ API compatible changes) * `hugr-persistent`: 0.4.5 -> 0.4.6 <details><summary><i><b>Changelog</b></i></summary><p> ## `hugr-model` <blockquote> ## [0.25.6](hugr-model-v0.25.5...hugr-model-v0.25.6) - 2026-02-20 ### New Features - Remove size limitation for binary envelopes ([#2880](#2880)) </blockquote> ## `hugr-core` <blockquote> ## [0.25.6](hugr-core-v0.25.5...hugr-core-v0.25.6) - 2026-02-20 ### Bug Fixes - Canonicalize more ([#2839](#2839)) - used_extensions should include transitive requirements ([#2891](#2891)) ### New Features - Add s expression format to envelope formats ([#2864](#2864)) - added hash.rs, updated imports ([#2840](#2840)) - *(hugr-py)* Define typed Metadata protocol ([#2765](#2765)) - Add a `NodeTemplate::call_to_function` helper ([#2878](#2878)) - Remove size limitation for binary envelopes ([#2880](#2880)) </blockquote> ## `hugr-llvm` <blockquote> ## [0.25.6](hugr-llvm-v0.25.5...hugr-llvm-v0.25.6) - 2026-02-20 ### New Features - Add error context when lowering hugrs to LLVM ([#2869](#2869)) </blockquote> ## `hugr-passes` <blockquote> ## [0.25.6](hugr-passes-v0.25.5...hugr-passes-v0.25.6) - 2026-02-20 ### Bug Fixes - Panic on UntuplePass when nodes had order edges ([#2883](#2883)) ### New Features - added hash.rs, updated imports ([#2840](#2840)) - Add a `NodeTemplate::call_to_function` helper ([#2878](#2878)) </blockquote> ## `hugr` <blockquote> ## [0.25.6](hugr-v0.25.5...hugr-v0.25.6) - 2026-02-20 ### Bug Fixes - Panic on UntuplePass when nodes had order edges ([#2883](#2883)) - Canonicalize more ([#2839](#2839)) - used_extensions should include transitive requirements ([#2891](#2891)) ### New Features - Add s expression format to envelope formats ([#2864](#2864)) - *(hugr-py)* Define typed Metadata protocol ([#2765](#2765)) - Add a `NodeTemplate::call_to_function` helper ([#2878](#2878)) - added hash.rs, updated imports ([#2840](#2840)) - Remove size limitation for binary envelopes ([#2880](#2880)) </blockquote> ## `hugr-cli` <blockquote> ## [0.25.6](hugr-cli-v0.25.5...hugr-cli-v0.25.6) - 2026-02-20 ### New Features - Add s expression format to envelope formats ([#2864](#2864)) </blockquote> ## `hugr-persistent` <blockquote> ## [0.4.0](hugr-persistent-v0.3.4...hugr-persistent-v0.4.0) - 2025-12-22 ### New Features - [**breaking**] Remove `RootCheckable` ([#2704](#2704)) - [**breaking**] Bump MSRV to Rust 1.89 ([#2747](#2747)) - [**breaking**] Type-safe access for node metadata ([#2755](#2755)) ### Refactor - [**breaking**] Remove multiple deprecated definitions ([#2751](#2751)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/).
The hashing code was copied and improved in `hugr-passes` (Quantinuum/hugr#2840). This breaking PR removes the old code from here. I added a new `circuit_hash` method to `Circuit` that should cover previous usages. BREAKING CHANGE: Removed `CircuitHash` trait, use `Circuit::circuit_hash` or `hugr::algorithms::hash::HugrHash` instead. Performance is the same between both implementations: [bench](https://codspeed.io/Quantinuum/tket2/branches/ab%2Fbye-hash?utm_source=github&utm_medium=check&utm_content=button&uri=tket%2Fbenches%2Fbenchmarks%2Fhash.rs%3A%3Abenches%3A%3Abench_hash_simple%3A%3Ahash%2520a%2520simple%2520circuit%3A%3Ahash_simple%255B1000%255D&runnerMode=Simulation)
No description provided.