Skip to content
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

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

Open
tanujkhattar opened this issue Jul 28, 2021 · 15 comments
Open
Assignees
Labels
area/gate-compilation complexity/high introduces/modifies 6+ concepts or touches Cirq core concepts or > 1 month for an expert good for learning For beginners in QC, this will help picking up some knowledge. Bit harder than "good first issues" kind/feature-request Describes new functionality triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on

Comments

@tanujkhattar
Copy link
Collaborator

tanujkhattar commented Jul 28, 2021

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

  • The GateTabulation compilation technique is not specific to cirq_google and should exist in cirq_core. There have also been requests in the past to implement a generic optimizer based on GateTabulation (Add a generic Optimizer that makes use of GateTabulation #4059), which should also exist in cirq_core.
  • The NuOps compilation method described https://arxiv.org/pdf/2106.15490.pdf is very similar to GateTabulation, but smarter in the sense that instead of first trying to tabulate the weyl chamber by generating random single qubit unitaries it rather considers the rotation angles of single qubit unitaries as optimization parameters and uses a numerical optimizer to find those angles for a given target unitary. This removes the heavy precomputation stage needed for GateTabulation and should potentially also improve the accuracy. It also allows for noise adoptability during gate compilation by enabling compilation to different base gates for different target unitaries (which is still possible by GateTabulation but would need a precomputation stage for each different base gate).

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

@tanujkhattar tanujkhattar added kind/feature-request Describes new functionality area/gate-compilation complexity/high introduces/modifies 6+ concepts or touches Cirq core concepts or > 1 month for an expert good for learning For beginners in QC, this will help picking up some knowledge. Bit harder than "good first issues" labels Jul 28, 2021
@tanujkhattar tanujkhattar changed the title Implement randomized compiler based on NuOps and bring GateTabulation to Cirq core Implement approximate compilation routine based on NuOps and bring GateTabulation to Cirq core Jul 28, 2021
@viathor viathor added the triage/discuss Needs decision / discussion, bring these up during Cirq Cynque label Aug 6, 2021
@tanujkhattar tanujkhattar added triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on and removed triage/discuss Needs decision / discussion, bring these up during Cirq Cynque labels Aug 9, 2021
@Ashalynd
Copy link
Collaborator

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

@tanujkhattar
Copy link
Collaborator Author

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
Copy link
Collaborator

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
Copy link
Collaborator Author

No, there's no dependency.

There's already #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
Copy link

@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
Copy link
Collaborator

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
Copy link
Collaborator Author

@Ashalynd Yes, that's correct.

@Ashalynd
Copy link
Collaborator

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

@vcatherine vcatherine changed the title Implement approximate compilation routine based on NuOps and bring GateTabulation to Cirq core Compiling: heuristic for compiling 2 qubits gates to the native gateset Sep 13, 2021
@tanujkhattar
Copy link
Collaborator Author

@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
Copy link

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

@Ashalynd
Copy link
Collaborator

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
Copy link
Collaborator

Ashalynd commented Feb 9, 2022

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

@tanujkhattar
Copy link
Collaborator Author

@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
Copy link
Collaborator

Thanks for confirmatilon!

@Ashalynd Ashalynd self-assigned this Feb 16, 2022
@Ashalynd
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/gate-compilation complexity/high introduces/modifies 6+ concepts or touches Cirq core concepts or > 1 month for an expert good for learning For beginners in QC, this will help picking up some knowledge. Bit harder than "good first issues" kind/feature-request Describes new functionality triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on
Projects
None yet
Development

No branches or pull requests

6 participants