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: add U and GPhase gates #799

Merged
merged 55 commits into from
Dec 20, 2023
Merged

feat: add U and GPhase gates #799

merged 55 commits into from
Dec 20, 2023

Conversation

jcjaskula-aws
Copy link
Contributor

@jcjaskula-aws jcjaskula-aws commented Nov 14, 2023

Issue #, if available:
Adding the U and GPhase gates so customers can build circuits from OpenQASM3 and simulate them with the local simulator.
This allows to import "stdgates.inc".

Description of changes:
Created a U and GPhase class and adding them to the translator dict.

Testing done:
Adding a series of new tests.

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have checked that my tests are not configured for a specific region or account (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jcjaskula-aws jcjaskula-aws requested a review from a team as a code owner November 14, 2023 22:10
Copy link

codecov bot commented Nov 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f44ab58) 100.00% compared to head (b6e9563) 100.00%.
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##              main      #799    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          129       129            
  Lines         8398      8519   +121     
  Branches      1871      1905    +34     
==========================================
+ Hits          8398      8519   +121     

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

@jcjaskula-aws jcjaskula-aws marked this pull request as draft November 15, 2023 17:53
@jcjaskula-aws jcjaskula-aws changed the title Add U gate Add U and GPhase gates Nov 15, 2023
Comment on lines +1421 to +1423
angle_1: Union[FreeParameterExpression, float],
angle_2: Union[FreeParameterExpression, float],
angle_3: Union[FreeParameterExpression, float],
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add defaults for this gate as we did with MS? That way we can users can define a u2 gate by only providing relevant params.

Copy link
Contributor

Choose a reason for hiding this comment

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

Might be tricky since only the first gate would have a default, so maybe we circle back to this in another pr

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we just add documentation that setting angle_1 to pi/2 is equivalent to U2

Copy link
Contributor Author

@jcjaskula-aws jcjaskula-aws Dec 11, 2023

Choose a reason for hiding this comment

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

Looks like u2/u3 are defined with a combination of gphase and U here. I like the idea to define u_i / update the docstring in another PR.

speller26
speller26 previously approved these changes Dec 20, 2023
Copy link
Member

@speller26 speller26 left a comment

Choose a reason for hiding this comment

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

Looks good, just some nits

src/braket/circuits/ascii_circuit_diagram.py Outdated Show resolved Hide resolved
src/braket/circuits/ascii_circuit_diagram.py Outdated Show resolved Hide resolved
src/braket/circuits/gate.py Show resolved Hide resolved
@jcjaskula-aws jcjaskula-aws merged commit 5d8d04c into main Dec 20, 2023
24 checks passed
@jcjaskula-aws jcjaskula-aws deleted the jcjaskula-aws/add_u_gate branch December 20, 2023 23:25
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.

4 participants