Skip to content
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

Merged
merged 18 commits into from
Sep 6, 2024
Merged

feat: lowering tk2ops -> hseriesops #579

merged 18 commits into from
Sep 6, 2024

Conversation

ss2165
Copy link
Member

@ss2165 ss2165 commented Sep 3, 2024

@ss2165 ss2165 mentioned this pull request Sep 4, 2024
github-merge-queue bot pushed a commit that referenced this pull request Sep 4, 2024
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.
Base automatically changed from ss/nofloat to main September 4, 2024 10:56
Copy link

codecov bot commented Sep 4, 2024

Codecov Report

Attention: Patch coverage is 73.38710% with 66 lines in your changes missing coverage. Please review.

Project coverage is 82.66%. Comparing base (dcc562d) to head (fcff28e).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
tket2-hseries/src/extension/hseries.rs 68.33% 0 Missing and 38 partials ⚠️
tket2-hseries/src/extension/hseries/lower.rs 78.12% 3 Missing and 25 partials ⚠️
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     
Flag Coverage Δ
rust 82.66% <73.38%> (-0.32%) ⬇️

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.

@ss2165 ss2165 force-pushed the ss/lowering branch 5 times, most recently from 0a7d537 to b0cea47 Compare September 5, 2024 13:22
@ss2165 ss2165 changed the base branch from main to ss/move-angle September 5, 2024 13:23
@ss2165 ss2165 requested a review from doug-q September 5, 2024 13:23
@ss2165 ss2165 marked this pull request as ready for review September 5, 2024 13:23
@ss2165 ss2165 requested a review from a team as a code owner September 5, 2024 13:23
@ss2165 ss2165 changed the title feat: lowering tk2ops -> hseriesops feat!: lowering tk2ops -> hseriesops Sep 5, 2024
@ss2165 ss2165 removed the request for review from doug-q September 5, 2024 13:24
@ss2165 ss2165 marked this pull request as draft September 5, 2024 13:24
Base automatically changed from ss/move-angle to main September 5, 2024 13:30
@ss2165 ss2165 changed the title feat!: lowering tk2ops -> hseriesops feat: lowering tk2ops -> hseriesops Sep 5, 2024
@ss2165 ss2165 changed the base branch from main to ss/no-try-from September 5, 2024 13:39
Base automatically changed from ss/no-try-from to main September 5, 2024 13:54
@@ -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"
Copy link
Member Author

Choose a reason for hiding this comment

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

to get lowering functions

@ss2165 ss2165 changed the base branch from main to ss/angle-build September 5, 2024 15:33
@ss2165 ss2165 requested a review from doug-q September 5, 2024 15:33
@ss2165 ss2165 marked this pull request as ready for review September 5, 2024 15:33
@ss2165
Copy link
Member Author

ss2165 commented Sep 6, 2024

Have used a simpler zzphase decomposition for crz, I believe the rest are up to the mark with tket synthesis to the gate set

Copy link
Collaborator

@cqc-alec cqc-alec left a 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>
Copy link
Collaborator

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>
Copy link
Collaborator

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>
Copy link
Collaborator

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> {
Copy link
Collaborator

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]

@ss2165 ss2165 requested a review from doug-q September 6, 2024 12:46
Copy link
Contributor

@doug-q doug-q left a comment

Choose a reason for hiding this comment

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

Thanks looks great!

@ss2165 ss2165 added this pull request to the merge queue Sep 6, 2024
@ss2165 ss2165 removed this pull request from the merge queue due to a manual request Sep 6, 2024
@ss2165 ss2165 added this pull request to the merge queue Sep 6, 2024
Merged via the queue into main with commit 7ac0206 Sep 6, 2024
14 of 15 checks passed
@ss2165 ss2165 deleted the ss/lowering branch September 6, 2024 13:25
github-merge-queue bot pushed a commit that referenced this pull request Sep 9, 2024
## 🤖 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/).
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.

Lower quantum ops in tket2-hseries
3 participants