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

[UnitaryHack]Barrier and Delays #980

Closed
wants to merge 5 commits into from

Conversation

Manvi-Agrawal
Copy link

@Manvi-Agrawal Manvi-Agrawal commented May 30, 2024

Issue , if available:

Fixes #974

Testing done:

  • Unit test coverage is 100%.
  • Running this code produces this QASM code
from braket.circuits import Circuit

circ = Circuit().barrier([0, 1, 2])
circ = Circuit().delay([0, 1, 2], 30)

print(circ.to_ir("OPENQASM").source)

OUTPUT

OPENQASM 3.0;
bit[3] b;
qubit[3] q;
delay[30 s] q[0], q[1], q[2];
b[0] = measure q[0];
b[1] = measure q[1];
b[2] = measure q[2];

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.

@Manvi-Agrawal Manvi-Agrawal requested a review from a team as a code owner May 30, 2024 09:54
Copy link

codecov bot commented May 30, 2024

Codecov Report

Attention: Patch coverage is 68.96552% with 9 lines in your changes missing coverage. Please review.

Project coverage is 99.89%. Comparing base (1c46ca7) to head (deb0202).
Report is 2 commits behind head on main.

Current head deb0202 differs from pull request most recent head 86bb75f

Please upload reports for the commit 86bb75f to get more accurate results.

Files Patch % Lines
src/braket/circuits/gates.py 68.96% 9 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##              main     #980      +/-   ##
===========================================
- Coverage   100.00%   99.89%   -0.11%     
===========================================
  Files          135      135              
  Lines         8920     8948      +28     
  Branches      2002     2012      +10     
===========================================
+ Hits          8920     8939      +19     
- Misses           0        9       +9     

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

Copy link
Contributor

@rmshaffer rmshaffer left a comment

Choose a reason for hiding this comment

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

Thanks for taking this on! If you'd like to continue toward merging this, please ensure that you add tests to validate the new functionality and reach 100% code coverage. You can use tox to run linters and unit tests locally.

src/braket/circuits/gates.py Show resolved Hide resolved
src/braket/circuits/gates.py Outdated Show resolved Hide resolved
@@ -68,6 +69,8 @@ class SingleNegControlModifier:
(Gate.Ry, "ry", ir.Ry, [SingleTarget, Angle], {}),
(Gate.Rz, "rz", ir.Rz, [SingleTarget, Angle], {}),
(Gate.U, "u", None, [SingleTarget, TripleAngle], {}),
(Gate.Barrier, "barrier", None, [SingleTarget], {}),
(Gate.Delay, "delay", None, [Duration, SingleTarget], {}),
Copy link
Author

@Manvi-Agrawal Manvi-Agrawal Jun 2, 2024

Choose a reason for hiding this comment

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

Thanks for taking this on! If you'd like to continue toward merging this, please ensure that you add tests to validate the new functionality and reach 100% code coverage.

Hi @rmshaffer , I did some changes in the test file and the input file. I could get some unit tests passing for Barrier but not Delay. Its complaining about missing parameter "duration".

Q1. Schema modification in amazon-braket-schemas doesnt work

class Duration(BaseModel):
    duration: confloat(ge=0)
  • Step 2: Installed editable version of amazon-braket-schemas by running pip install -e . in amazon-braket-schemas.

  • Step 3: Run the Unit tests in this repo(aka amazon-braket-sdk-python). They still failed

    Q2: Bind values

    And its confusing to me how do we decide whether to use bind_values or not. Gates derieved from AngledGate call bind_values function but Unitary gate which takes 2D matrix, has TwoDimensionalMatrix at amazon-braket-schemas repo

Copy link
Author

Choose a reason for hiding this comment

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

Hi @rmshaffer , did you get a chance to look into this?

Copy link
Author

@Manvi-Agrawal Manvi-Agrawal Jun 4, 2024

Choose a reason for hiding this comment

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

Hi @rmshaffer , the coverage is now 100%. For now, I have added Duration class here. Could you please help regarding this?

PS: Working to fix tests. I realized that OpenQASM isnt working

Copy link
Author

Choose a reason for hiding this comment

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

Hi @rmshaffer , I have raised #993 which has 100% test coverage so that I can follow commit message format. I didnt want to do git rebase. Could you please review it?

@Manvi-Agrawal
Copy link
Author

@rmshaffer , created #992 to use the commit format as prescibed.

@Manvi-Agrawal Manvi-Agrawal marked this pull request as draft June 4, 2024 21:34
@rmshaffer
Copy link
Contributor

@rmshaffer , created #992 to use the commit format as prescibed.

The commit format is actually referring to the PR title, which is what becomes the commit title when the PR is squashed and merged. (The individual commits in the PR will disappear anyway when they are squashed and merged.)

@rmshaffer
Copy link
Contributor

Closing this PR in favor of #992

@rmshaffer rmshaffer closed this Jun 5, 2024
@Manvi-Agrawal
Copy link
Author

Manvi-Agrawal commented Jun 5, 2024

The commit format is actually referring to the PR title, which is what becomes the commit title when the PR is squashed and merged. (The individual commits in the PR will disappear anyway when they are squashed and merged.)

Thanks @rmshaffer for the clarification. I saw a couple of merged PRs like (https://github.com/amazon-braket/amazon-braket-sdk-python/pull/977/commits) which was following this convention

Do you think we can update the contributing doc and merge checklist to account for this fact, so that it doesnt confuse new people like me? Currently, merge checklist explicitly says: I used the commit message format described in CONTRIBUTING. Maybe say that I used the PR title format described in CONTRIBUTING to make it more clear. Thoughts?

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.

Support for adding barriers and delays to Circuit
2 participants