chore: new tket-qsim unitary simulator for unit testing - #1886
ferbetanzo wants to merge 7 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1886 +/- ##
==========================================
- Coverage 86.25% 86.24% -0.02%
==========================================
Files 202 207 +5
Lines 31992 32862 +870
Branches 30500 31370 +870
==========================================
+ Hits 27594 28341 +747
- Misses 3165 3272 +107
- Partials 1233 1249 +16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
doug-q
left a comment
There was a problem hiding this comment.
Thanks for this. Apologies but I do not think we should proceed with this approach. Happy to discuss.
I think that we can't use selene because of dependency loops, is that right?
Problems with this approach
- It relys on the hugrs under test to get optimised into single-dfg functions
- lowerings that contain control flow cannot be handled
- lowerings that include ancillas or mid circuit measurements cannot be handled
- The hugrs that are tested are fixed. This approach is not going to catch corner cases (e.g. bugs where special angles cause big problems)
I don't think this is the right solution to verifying our transformations.
I suggest
- Each op should be verified independently
- The expected unitary should be specified local to the test
- I don't think we should build an interpreter here. (I would be ok on depending on a separate, complete(ish) interpreter)
- A better approach, IMO, would be to
- depend on selene in such a way as it doesn't create circular dependencies. This is surely possible because we don't need to run any tket transformations in selene (we can do it beforehand)
- For parameterised gates use property testing to explore the parameter space and catch corner cases
|
|
||
| let unitary_after = simulate_circuit(&h, ¶ms).unwrap(); | ||
| assert!( | ||
| unitary_before.approx_eq_up_to_global_phase(&unitary_after, 1e-10), |
There was a problem hiding this comment.
I would prefer to use the https://docs.rs/approx/latest/approx/ crate for this
| /// | ||
| /// Stored in row-major order. | ||
| #[derive(Clone)] | ||
| pub struct UnitaryMatrix { |
There was a problem hiding this comment.
I would prefer to use the https://www.nalgebra.rs/docs/ crate for this
Closes #1648. Includes the following:
tket-qsimcrate that allows to simulate (purely unitary) hugrs. It defines the required<tket|helios|sol>_opsunitary matrices but compares them againstroqoqo's gate definitions.