-
Notifications
You must be signed in to change notification settings - Fork 11
Unroll broadcasted operations when producing QASM from SLR #96
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
Merged
ciaranra
merged 6 commits into
PECOS-packages:development
from
perlinm:unroll-broadcast
Dec 14, 2024
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
09e3ce6
unroll broadcast operations
perlinm 9030cbe
add comment
perlinm 71ab897
Merge branch 'development' into unroll-broadcast
perlinm eb61c9f
add error message
perlinm 424be0f
Fixing regression tests
ciaranra d311f5e
linting
ciaranra 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 hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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 looks to me like that the unconditional final
str_list.append(...)was a bug, and should have been inside anelsestatement. Otherwise this method first acts the gate on everyqs in qand then again appends a gate on (the tuple)q.Uh oh!
There was an error while loading. Please reload this page.
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.
To me, SWAP is a unitary gate that could possibly be converted to a physical permute if a compiler is smart enough. There is a need to distinguish the two operations as you may what fine control and choose one over the other and do not want to rely on a compiler.
As far as rewriting QASM, the user should no longer be responsible with debugging that. This is the job of the language (e.g., SLR)/compiler. If the underlying base language had support for Permute, then that would make things cleaner; however, SLR needs to metaprogram features that are not supported by the base language which is essentially what higher languages have to do when converting to lower languages. They provide more facilities then the simpler underlying language provides.
That being said. I want to rewrite the Permute object to be a little more friendly to code generation and just stores the info in a nice manner to be handed off to the code generator function.
Uh oh!
There was an error while loading. Please reload this page.
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.
Upgrading SWAP to a "native gate" of the hardware is perfectly compatible with thinking of it as a unitary gate. Relabeling qubits does implement the desired unitary operation, and it is an advantage of trapped ion platform that it can perform SWAP gates perfectly 🙂! Not all platforms can do this. This is also a capability that can be leveraged by circuit-level compilers (search this paper for "swap mirroring", for example), but doing so requires that the hardware recognize SWAP as a native gate. This essentially "exposes" the virtual SWAP capability to compilers that work on the level of (say)
pytket,cirq, orqiskit.There is also precedent here: having a virtual native SWAP gate is directly analogous to virtual Rz gates on IBM devices. IBM devices accept Rz instructions, but do not actually apply any physical operations any qubits when asked to "apply" an Rz gate (they instead make a software-level update of a rotating frame).
From the perspective of compiler development, the way to get "fine control" and execute a specific sequence of physical operations is to build the circuit you want, and run it in "verbatim" mode to bypass/disable any compiler. Another option is to have compilation flags that toggle various compiler features. There is no control or choice removed by upgrading the SWAP gate to a native virtual operation (and in fact, at the moment you already "rely on a compiler" to convert a SWAP instruction into 3 MS gates).
Final point:
As a matter of practice, we have definitely resorted to examining QASM to debug PECOS and would appreciate the option to continue doing so 🙂
In any case, what are your thoughts of unrolling broadcast operations in this PR? Some fix for #95 is necessary to use both
Permuteand (say)Steane.szin the same SLR (andPermuteis used forSteane.t_tel).