Skip to content

feat: added hash.rs, updated imports#2840

Merged
nicolaassolini-qntm merged 18 commits intomainfrom
na/2091-move-tket2s-circuithash-here
Feb 6, 2026
Merged

feat: added hash.rs, updated imports#2840
nicolaassolini-qntm merged 18 commits intomainfrom
na/2091-move-tket2s-circuithash-here

Conversation

@nicolaassolini-qntm
Copy link
Copy Markdown
Contributor

No description provided.

@nicolaassolini-qntm nicolaassolini-qntm linked an issue Jan 27, 2026 that may be closed by this pull request
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 27, 2026

Codecov Report

❌ Patch coverage is 77.07317% with 47 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.71%. Comparing base (d35b706) to head (931def5).
⚠️ Report is 13 commits behind head on main.

Files with missing lines Patch % Lines
hugr-passes/src/utils.rs 75.00% 21 Missing and 3 partials ⚠️
hugr-passes/src/hash.rs 78.89% 8 Missing and 15 partials ⚠️
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     
Flag Coverage Δ
python 88.58% <ø> (ø)
rust 83.12% <77.07%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nicolaassolini-qntm nicolaassolini-qntm changed the title added hash.rs, updated imports feat: added hash.rs, updated imports Feb 3, 2026
@nicolaassolini-qntm nicolaassolini-qntm marked this pull request as ready for review February 3, 2026 13:41
@nicolaassolini-qntm nicolaassolini-qntm requested a review from a team as a code owner February 3, 2026 13:41
///
/// 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>;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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())
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I have used hugr.entrypoint() in tests though.

@aborgna-q
Copy link
Copy Markdown
Collaborator

@nicolaassolini-qntm nicolaassolini-qntm self-assigned this Feb 6, 2026
Copy link
Copy Markdown
Collaborator

@aborgna-q aborgna-q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@nicolaassolini-qntm nicolaassolini-qntm added this pull request to the merge queue Feb 6, 2026
Merged via the queue into main with commit f532764 Feb 6, 2026
29 of 30 checks passed
@nicolaassolini-qntm nicolaassolini-qntm deleted the na/2091-move-tket2s-circuithash-here branch February 6, 2026 17:49
@hugrbot hugrbot mentioned this pull request Feb 6, 2026
github-merge-queue bot pushed a commit that referenced this pull request Feb 20, 2026
## 🤖 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/).
@hugrbot hugrbot mentioned this pull request Feb 27, 2026
github-merge-queue bot pushed a commit to Quantinuum/tket2 that referenced this pull request Mar 3, 2026
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move tket2's CircuitHash here

2 participants