Skip to content

[XEB] Plan to deprecate duplicate functionality #3775

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

Closed
mpharrigan opened this issue Feb 10, 2021 · 3 comments
Closed

[XEB] Plan to deprecate duplicate functionality #3775

mpharrigan opened this issue Feb 10, 2021 · 3 comments
Assignees
Labels
area/xeb kind/task A task that's part of a larger effort

Comments

@mpharrigan
Copy link
Collaborator

cirq.experiments.random_quantum_circuit_generation

This has fully-general utilities for making random quantum circuits on grids. Everything should use this.

cirq.experiments.fidelity_estimation 🟡

The first set of functions are nice enough, and are appropriate for computing XEB fidelity like in Arute 2019, although there are no examples on how to use this in practice. We should add some!

The final set of functions (least_squares_xxx) are appropriate for computing XEB fidelity for narrow (i.e. two-qubit) circuits. This math is used in the forthcoming suite of xeb characterization utilities (https://github.com/quantumlib/Cirq/issues?q=label%3Aarea%2Fxeb+) however, the data structures used as input and output are very confusing and not suitable for fast, numpy-vectorized-style application to real results. I think these should be deprecated in their current form

cirq.experiments.cross_entropy_benchmarking 🔴

And examples/cross_entropy_benchmarking_example.

This has a self-contained end-to-end implementation of cross entropy benchmarking. Therefore, it has its own fidelity estimation code and random circuit generation code. At the very least, it should be refactored to use the functionality in the more generalized modules described above and the example should use a noisy simulator. However, I recommend these modules be deprecated/removed completely: the example is not particularly instructive and the tight coupling between circuit construction, sampling, simulation, and analysis makes it hard to adapt and extend. The example is redundant with the more rich documentation provided as part of the xeb prs

cirq.experiments.google_v2_supremacy_circuit 🔴

This uses terminology we're trying to move away from. It also has its own, third implementation of random quantum circuit generation. These are also not the random circuits used in the flagship arute 2019 nature paper but rather the 2018 boixo theory paper. As far as I can tell, this is supposed to act as a supplemental information for that paper. This is not a good use of the Cirq repository. This should be re-written to use random_quantum_circuit_generation, renamed, and moved to a different repository.

grid_parallel_two_qubit_xeb 🟡

This module uses the "data collection idioms" from ReCirq to run a full parallel-2q-XEB experiment and save the results in a structured way. Unfortunately, this file is over 500 lines long and contains a lot of "business logic". This should be re-written to use the new XEB utilities and moved to ReCirq.

This uses some of the dataclasses from .cross_entropy_benchmarking, so we should audit/preserve those if applicable during the deprecation/removal of that module.

@balopat balopat added the kind/task A task that's part of a larger effort label Feb 10, 2021
CirqBot pushed a commit that referenced this issue Feb 18, 2021
Add a new method to perform optimization of angles (aka characterization) by pair. This is essential for "parallel" XEB. At it's heart, this is simply a "groupby" operation on the dataframe before calling the characterize function. There are additional code changes:

 - Lots of boilerplate for making a "closure class" so we can optimize by pair in parallel. This is an embarrassingly parallel operation, and it's important when doing very "wide" (i.e. lots of pairs) calibrations.
 - The least-squares estimation of individual (one pair, one cycle depth) fidelities involved using pandas `apply`, which turned out to be very slow! I profiled the `benchmark` function on a test workflow. It was taking 7.87 seconds, of which 5.3s were cumulative inside the apply function. The rest of it involved simulating the many circuits. `benchmark_...` is called during the optimization's objective function so it's performance critical. With the change, the call was a total of 2.5s and the least-squares estimation no longer appeared in the top many cumulative-time profiling calls.
 - Bug fix if you tried to do parallel XEB on a device that couldn't do all four layers. With added test.
 - The result of the `characterize_..` function has been beefed up to be a dataclass with more fields. Not only do you get the optimization results, but a nicer dictionary of angles and a dataframe of the refit fidelities. This simplifies one of the older notebooks. This data is also per-pair so you can do parallel xeb effectively
 - An exponential decay fitting function, taken from `experiments.cross_entropy_benchmarking`, which will be deprecated, #3775 
 - Some helpful pandas magic wrapped with nice function names to simplify plotting
@mpharrigan
Copy link
Collaborator Author

Discussed at cirq cync: @balopat cirq.experiments.google_v2_supremacy_circuit is high-priority because it is blocking cirq.google refactor.

  1. Re-write using cirq.experiments random quantum circuit generation functionality and put this in ReCirq
  2. Upload to a supplemental data hosting service like figshare and remove from git / GitHub

@balopat
Copy link
Contributor

balopat commented Mar 18, 2021

Yes, thank you, if we get this in, then I don't have to importorskip('cirq.google') the tests related to it. See #3894 (comment).

@dstrain115 dstrain115 self-assigned this Mar 28, 2022
dstrain115 added a commit to dstrain115/Cirq-1 that referenced this issue May 31, 2022
- cirq.experiments.cross_entropy_benchmarking is redundant and not easy
  to adapt.
- cirq.experiments.grid_parallel_two_qubit_xeb moved to
  recirq.benchmarks.xeb
- Also delete cross_entropy_benchmarking example

This is part of quantumlib#3775.
CirqBot pushed a commit that referenced this issue May 31, 2022
#5424)

- cirq.experiments.cross_entropy_benchmarking is redundant and not easy
  to adapt.
- cirq.experiments.grid_parallel_two_qubit_xeb moved to
  recirq.benchmarks.xeb
- Also delete cross_entropy_benchmarking example

This is part of #3775.
dstrain115 added a commit to dstrain115/Cirq-1 that referenced this issue Jun 1, 2022
- These functions are inefficient and have been obsoleted
by vectorized versions in xeb_fitting.

This is part of the plan to deprecate redundant XEB functionality as
part of quantumlib#3775.
dstrain115 added a commit that referenced this issue Jun 1, 2022
- These functions are inefficient and have been obsoleted
by vectorized versions in xeb_fitting.

This is part of the plan to deprecate redundant XEB functionality as
part of #3775.
@dstrain115
Copy link
Collaborator

All tasks for this issue have been closed. If you find more XEB functionality that needs to be deprecated, a new issue can be opened.

rht pushed a commit to rht/Cirq that referenced this issue May 1, 2023
quantumlib#5424)

- cirq.experiments.cross_entropy_benchmarking is redundant and not easy
  to adapt.
- cirq.experiments.grid_parallel_two_qubit_xeb moved to
  recirq.benchmarks.xeb
- Also delete cross_entropy_benchmarking example

This is part of quantumlib#3775.
rht pushed a commit to rht/Cirq that referenced this issue May 1, 2023
…5428)

- These functions are inefficient and have been obsoleted
by vectorized versions in xeb_fitting.

This is part of the plan to deprecate redundant XEB functionality as
part of quantumlib#3775.
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this issue Oct 31, 2024
quantumlib#5424)

- cirq.experiments.cross_entropy_benchmarking is redundant and not easy
  to adapt.
- cirq.experiments.grid_parallel_two_qubit_xeb moved to
  recirq.benchmarks.xeb
- Also delete cross_entropy_benchmarking example

This is part of quantumlib#3775.
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this issue Oct 31, 2024
…5428)

- These functions are inefficient and have been obsoleted
by vectorized versions in xeb_fitting.

This is part of the plan to deprecate redundant XEB functionality as
part of quantumlib#3775.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/xeb kind/task A task that's part of a larger effort
Projects
None yet
Development

No branches or pull requests

3 participants