question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 2 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
maffoocommented, Apr 20, 2021

What if instead we were to extend on_each to all gates and allow it to accept a sequence of tuples of cirq.Qid for gates that apply to multiple qubits? Then you could do

cirq.CNOT.on_each(zip(qubits0, qubits1))

This 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) and cirq.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.

0reactions
95-martin-orioncommented, Jun 23, 2022

This is complete: Gate.on_each(zip(qubits_0, qubits_1, ...)) provides the requested support and deprecated classes have been removed.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found