-
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
feat: lowering tk2ops -> hseriesops #579
Conversation
Move Hseries specifc ops to its own extension (some duplicates). Trim Tk2Ops down in to some small "textbook" set. Tk1 removed as it can be made up of Rz.Rx.Rz. Can be used in canonical {Tk1, TK2} based passes in a standalone extension. Lowering from Tk2Ops to Hseries ops in progress : #579 Closes #571 BREAKING CHANGE: Rename lazy extension to "hseries" and add hseries ops. Tk2Ops: remove "f64" from Rx, Rz; remove ZZPhase, ZZMax, PhasedX, TK1.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #579 +/- ##
==========================================
- Coverage 82.98% 82.66% -0.32%
==========================================
Files 45 46 +1
Lines 6264 6496 +232
Branches 6264 6496 +232
==========================================
+ Hits 5198 5370 +172
Misses 765 765
- Partials 301 361 +60
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
0a7d537
to
b0cea47
Compare
@@ -26,8 +26,8 @@ missing_docs = "warn" | |||
[workspace.dependencies] | |||
|
|||
# Make sure to run `just recompile-eccs` if the hugr serialisation format changes. | |||
hugr = "0.12.0" | |||
hugr-core = "0.9.0" | |||
hugr = "0.12.1" |
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.
to get lowering functions
Have used a simpler zzphase decomposition for crz, I believe the rest are up to the mark with tket synthesis to the gate set |
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.
Feel free to ignore these comments as the number of 2-qubit gates is the same
} | ||
|
||
/// Build a CZ gate in terms of HSeries primitives. | ||
fn build_cz(&mut self, a: Wire, b: Wire) -> Result<[Wire; 2], BuildError> |
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.
CZ[0,1] == PhasedX(1, 1)[0] ; ZZMax[0,1] ; PhasedX(1,0.5)[0] ; Rz(0.5)[1] ; Rz(-0.5)[0]
} | ||
|
||
/// Build a CY gate in terms of HSeries primitives. | ||
fn build_cy(&mut self, a: Wire, b: Wire) -> Result<[Wire; 2], BuildError> |
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.
CY[0,1] = PhasedX(-0.5, 0)[1] ; ZZMax[0,1] ; Rz(0.5)[0] ; PhasedX(0.5, 0.5)[1] ; Rz(-0.5)[1]
} | ||
|
||
/// Build a CRZ gate in terms of HSeries primitives. | ||
fn build_crz(&mut self, a: Wire, b: Wire, lambda: Wire) -> Result<[Wire; 2], BuildError> |
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.
CRz(a)[0,1] = PhasedX(0.5, 0.5)[0] ; ZZMax[0,1] ; PhasedX(-1 + 0.5a, -0.5)[0] ; ZZMax[0,1] ; PhasedX(0.5, 0.5)[0] ; Rz(0.5a)[1]
} | ||
|
||
/// Build a Toffoli (CCX) gate in terms of HSeries primitives. | ||
fn build_toffoli(&mut self, a: Wire, b: Wire, c: Wire) -> Result<[Wire; 3], BuildError> { |
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.
CCX = PhasedX(1,1)[2] ; ZZMax[1,2] ; PhasedX(0.25,-0.5)[2] ; ZZMax[0,2] ; PhasedX(-0.25,0)[2] ; ZZMax[1,2] ; PhasedX(-0.5,0.25)[1] ; PhasedX(0.25,0.5)[2] ; ZZMax[0,2] ; ZZMax[0,1] ; PhasedX(-0.75,0)[2] ; PhasedX(0.25, 0.25)[1] ; ZZMax[0,1] ; Rz(0.25)[0] ; PhasedX(-0.5, 0.25)[1] ; Rz(0.25)[1]
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.
Thanks looks great!
## 🤖 New release * `tket2`: 0.2.0 -> 0.3.0 * `tket2-hseries`: 0.2.0 -> 0.3.0 <details><summary><i><b>Changelog</b></i></summary><p> ## `tket2` <blockquote> ## [0.3.0](tket2-v0.2.0...tket2-v0.3.0) - 2024-09-09 ### Bug Fixes - extension ops checking against incorrect name ([#593](#593)) - [**breaking**] remove TryFrom for extension ops use `cast` ([#592](#592)) - don't load angle extensions on to quantum ([#597](#597)) ### New Features - [**breaking**] move angle types + and ops to new "tket2.angle" extension ([#591](#591)) - dataflow builder methods for angle ops ([#596](#596)) - lowering tk2ops -> hseriesops ([#579](#579)) </blockquote> ## `tket2-hseries` <blockquote> ## [0.3.0](tket2-hseries-v0.2.0...tket2-hseries-v0.3.0) - 2024-09-09 ### Bug Fixes - extension ops checking against incorrect name ([#593](#593)) - [**breaking**] remove TryFrom for extension ops use `cast` ([#592](#592)) ### New Features - lowering tk2ops -> hseriesops ([#579](#579)) - *(tket2-hseries)* cli extension dumping ([#584](#584)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/MarcoIeni/release-plz/).
Closes #490
Using definitions in hqslib1 https://github.com/CQCL/pytket-quantinuum/blob/main/pytket/extensions/quantinuum/backends/hqslib1.inc