-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Allow measurement keys with differing qubits in OpenQASM #6803
Merged
dstrain115
merged 8 commits into
quantumlib:main
from
dstrain115:fix_classical_register_size
Nov 22, 2024
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0bcac30
Allow measurement keys with differing qubits in OpenQASM
dstrain115 8d8a20d
Merge branch 'main' into fix_classical_register_size
dstrain115 56ebbec
Fix merge issues.
dstrain115 4e2693c
Change to function and put in constructor.
dstrain115 a91318a
Update cirq-core/cirq/circuits/qasm_output_test.py
dstrain115 b75090b
Update cirq-core/cirq/circuits/qasm_output_test.py
dstrain115 3772025
Update cirq-core/cirq/circuits/qasm_output_test.py
dstrain115 5a90191
Merge branch 'main' into fix_classical_register_size
dstrain115 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If you did this in the QasmOutput constructor and stored it in QasmArgs, you could pass it into KeyCondition.qasm, and fix #5691.
The reason it's required is that KeyCondition is triggered if
meas[m_key] != 0
. In OpenQasm2, the only logical comparator is equality, so!= 0
can only be represented if the creg is a single bit (i.e. it would convert the condition toif m_key == 1
). If the creg is multiple bits, thenif m_key == 1
would be incorrect, andm_key != 0
is not representable. So that's why the existing behavior is to play it safe and just fail.Going a little bit further, in OpenQasm3, it looks like
m_key != 0
is representable, so checkingQasmArgs.version
in KeyCondition.qasm would allow supporting multi-bit classical controls ifversion == '3.0'
. OpenQasm3 could also potentially support serializing additional types of logic in SympyConditions.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.
It might also be useful to have this be a function on
Circuit
or part of themeasurement_keys
protocol. I'd imagine "get the shapes of all the measurement keys in the circuit" would be a common need.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.
Changed to put into constructor, but I am not convinced that helps, since we don't pass QasmOutput during the qasm protocol. In any case, I will deal with classical controls in a follow-up PR.
Also, Circuit has enough cruft on it that I don't think it's a good idea to add more functions onto it, so I will leave it here.