Is your feature request related to a use case or problem? Please describe.
A very common pattern in building quantum circuits is to have a bunch of two qubit gates that you want to put into a circuit, and you do this by acting on qubits from two lists
for q0, q1 in zip(qubits0, qubits1):
cirq.CNOT.on(q0, q1)
In a similar way to having on_each
we could, for two qubit gates, have zip
:
cirq.CNOT.zip(qubits0, qubits1)
I’m unsure if this could also be extended across multiple qubit gates (or even be another way to do on_each
).
What is the urgency from your perspective for this issue? Is it blocking important work?
P2 - we should do it in the next couple of quarters
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
Buy Now, Pay Later with Zip, previously Quadpay
Installment fees are $4 for purchases from $35 to $99.99, $5 for purchases from $100 to $199.99, and $6 for purchases $200 and...
Read more >ZipRecruiter: Job Search - Millions of Jobs Hiring Near You
Search for jobs hiring in your area using ZipRecruiter's job search engine - the best way to find a job. Find jobs hiring...
Read more >7-Zip
7-Zip is a file archiver with a high compression ratio. ... You can use 7-Zip on any computer, including a computer in a...
Read more >ZIP Code™ Lookup - USPS Tracking
Enter a corporate or residential street address, city, and state to see a specific ZIP Code ™. ... Enter city and state to...
Read more >Zip and unzip files - Microsoft Support
Zipped (compressed) files take up less storage space and can be transferred to other computers more quickly than uncompressed files. In Windows, you...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
What if instead we were to extend
on_each
to all gates and allow it to accept a sequence of tuples ofcirq.Qid
for gates that apply to multiple qubits? Then you could doThis is not quite as concise, but more general since you can construct the sequence in other ways in addition to using parallel lists.
One problem with this would be that the current implementation of on_each tries to be flexible by “flattening” nested iterables down to a single list of qubits (it seems likely that this was meant to support
cirq.X.on_each(q0, q1)
andcirq.X.on_each([q0, q1])
, but the actual implementation supports any amount of nesting of sequences). It’s possible this could be made to work by leaving the last level “unflattened” for multi-qubit gates. Probably would still not be able to support “variadic” gates like measure and wait since they could take one or more qubits.This is complete:
Gate.on_each(zip(qubits_0, qubits_1, ...))
provides the requested support and deprecated classes have been removed.