-
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
bitwise operations for classically conditioned gates #6434
Comments
@ikd-sci is this for simulation or for circuit diagrams. for simulation we have the abstract class |
Classical controls don't currently work with The easiest option here though would be to add a bitmask field to
resolve (though it doesn't hurt to check).
|
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days |
Issue closed due to inactivity. |
Does this look like it would be useful? https://github.com/quantumlib/Cirq/pull/6914/files |
Is your feature request related to a use case or problem? Please describe.
The main use case is conditional circuits, however, this might be more broadly applicable as the task of splitting bits and doing bitwise operations is fairly common.
Describe the solution you'd like
There is a long-standing issue of limited out-of-the-box support of bitwise operations in sympy
sympy/sympy#5353
Currently, cirq doesn't provide ways to split integer register into individual bits in order to use those bits for classically conditioned operations. The typical example of such operations includes pairwise XOR (as in constant-depth feedforward protocols).
[optional] Describe alternatives/workarounds you've considered
Current workaround consists in creating individual bit registers for every single readout operation (LSB or MSB representation) and then performing pairwise sympy.Xor on those bits:
Another approach consist in calculating a truth table. Example:
Both approaches work and are correctly simulated.
Yet another way consists in bit shifting as the following is technically allowed by SymPy:
[optional] Additional context (e.g. screenshots)
The approach of adding bit registers doesn't scale gracefully even for a small system size:
Even though it does encode the correct circuit -- there is a lot of notation clutter in ASCII representation and suboptimal to work with due the growing number of sympy operations.
What is the urgency from your perspective for this issue? Is it blocking important work?
P1 - I need this no later than the next release (end of quarter)
The text was updated successfully, but these errors were encountered: