quantumlib / Cirq

A python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
Apache License 2.0
4.19k stars 995 forks source link

Compiling: heuristic for compiling 2 qubits gates to the native gateset #4362

Open tanujkhattar opened 2 years ago

tanujkhattar commented 2 years ago

Is your feature request related to a use case or problem? Please describe. Approximate compilation to arbitrary target gatesets is a useful compilation primitive for the NISQ era. Currently, cirq only has GateTabulation method in cirq_google which supports approximate compilation to arbitrary target gatesets. However, being in cirq_google, GateTabulation is not very easily discoverable.

There are also other nice approximate compilation techniques like https://arxiv.org/pdf/2106.15490.pdf which should exist in cirq_core.

Describe the solution you'd like Implement approximate compilation routine based on NuOps and bring GateTabulation to Cirq core

What is the urgency from your perspective for this issue? Is it blocking important work? This work should be done as part of the gate compiling roadmap item (#3239) and we should eventually aim for a suit of approximate compilation methods similar to the various exact kak based analytical gate synthesis methods that exist today.

P2 - we should do it in the next couple of quarters

Ashalynd commented 2 years ago

Hi Tanuj. Would you mind if I have a look at this?

tanujkhattar commented 2 years ago

Sure! There are multiple smaller work items for this larger bug

  1. Bring GateTabulation out of cirq-google to cirq-core 2.Add a generic optimizer that makes use of GateTabulation
  2. Implement the NuOps compiler, given in the linked paper, in cirq-core.

@chrischris96 had also reached out to me over email earlier expressing interest in this issue but I think the issue is large enough that more than one person can work on it in parallel.

Please let me know if you have any further questions.

Ashalynd commented 2 years ago

Thanks for the quick reply!

Is there a dependency between the first (GateTabulation refactoring + optimizer) and the second (NuOps implementation) tasks?

If not, would it help to split this issue into two or more separate ones?

tanujkhattar commented 2 years ago

No, there's no dependency.

There's already https://github.com/quantumlib/Cirq/issues/4059 that talks about adding an optimizer that uses the GateTabulation method. Feel free to create new smaller sub-issues to track specific work items.

chrischris96 commented 2 years ago

@Ashalynd I read the paper and don't have any preferences about which part to work on. Would you rather work on the optimizer or the NuOps implementation task?

Ashalynd commented 2 years ago

Hi @chrischris96,

Sure, I can take the first part (refactoring GateTabulation and creating an optimizer).

@tanujkhattar - that would correspond to issue #4059 plus may be a separate issue for refactoring, correct?

tanujkhattar commented 2 years ago

@Ashalynd Yes, that's correct.

Ashalynd commented 2 years ago

I created #4461 (can't assign additional labels to it though).

tanujkhattar commented 2 years ago

@chrischris96 As part of tracking the progress towards our Cirq 1.0 roadmap items, I wanted to check in on the progress on this issue. Could you start working on it yet?

chrischris96 commented 2 years ago

@tanujkhattar I am having exams until Monday but will start working on it full-time next week

Ashalynd commented 2 years ago

What is the status of the next task (write generic optimizer based on GateTabulation)? @tanujkhattar I have more cycles now , can work on that if it's still in scope.

Ashalynd commented 2 years ago

Gentle ping :) Is this issue still in scope? If yes, is #4059 taken / are there any parts left for this issue?

tanujkhattar commented 2 years ago

@Ashalynd You can work on #4059 now that GateTabulation has been moved to cirq-core and we have new transformer API and transformer primitives checked-in, which should be used to implement #4059

Please let me know if you have any questions.

Ashalynd commented 2 years ago

Thanks for confirmatilon!

Ashalynd commented 2 years ago

Hi, apologies I have been away due to force majeure. Looping back in.