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

Add classical variable support to qasm3_qir_converter #85

Merged
merged 6 commits into from
May 2, 2024

Conversation

TheGupta2012
Copy link
Collaborator

@TheGupta2012 TheGupta2012 commented Apr 19, 2024

Fixes #76

Changes

  • Added implementation for the classical variable declarations and assignments.
  • Elements -
    • scalar type declarations
    • array declarations
    • const declarations
    • scope checking and update
    • scalar assignment
    • array assignment
    • type checking for assignment
    • index validation in assignment
    • array initialization and validation
    • Implicit Type Casting
    • Explicit Type Casting

Copy link
Member

@ryanhill1 ryanhill1 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 these updates. Gave a couple suggestions for error handling using Exceptions instead of assert. Also consider using collections.deque for the scope dict list. And finally, if you could just add test cases for any new code that would be great.

qbraid_qir/qasm3/visitor.py Outdated Show resolved Hide resolved
qbraid_qir/qasm3/visitor.py Outdated Show resolved Hide resolved
qbraid_qir/qasm3/visitor.py Outdated Show resolved Hide resolved
qbraid_qir/qasm3/visitor.py Outdated Show resolved Hide resolved
qbraid_qir/qasm3/visitor.py Show resolved Hide resolved
@TheGupta2012
Copy link
Collaborator Author

TheGupta2012 commented Apr 22, 2024

Thanks for the suggestions! Was still a WIP so that's why haven't added tests yet. Will update with the changes and tests

Copy link
Member

@ryanhill1 ryanhill1 left a comment

Choose a reason for hiding this comment

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

Updates look good! The _get_scope method has a bug that will need to be fixed, and offered a couple other optional suggestions for some of the other scope methods.

If you could provide some clarity on the left / right variable constants that you're multiplying that would be helpful.

qbraid_qir/qasm3/visitor.py Outdated Show resolved Hide resolved
qbraid_qir/qasm3/visitor.py Outdated Show resolved Hide resolved
qbraid_qir/qasm3/visitor.py Outdated Show resolved Hide resolved
qbraid_qir/qasm3/visitor.py Outdated Show resolved Hide resolved
qbraid_qir/qasm3/visitor.py Show resolved Hide resolved
Copy link
Member

@ryanhill1 ryanhill1 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 to me!

tests/qir_utils.py Outdated Show resolved Hide resolved
@TheGupta2012
Copy link
Collaborator Author

Yea thanks, had missed this debug statement.
Also, can you hold this PR? I'm yet to write the tests for the exceptions.

@TheGupta2012
Copy link
Collaborator Author

TheGupta2012 commented Apr 29, 2024

Hey @ryanhill1 , after reviewing you can go ahead and merge. Will take up the last three tasks in another PR as this is getting too big for one feature! I have created a new issue #90 with the leftover stuff

@ryanhill1 ryanhill1 merged commit 887c210 into main May 2, 2024
7 checks passed
@ryanhill1 ryanhill1 deleted the qasm3-classical-variables branch July 7, 2024 00:47
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.

Add support for classical variables in qasm3_to_qir converter
2 participants