quantumlib / Cirq

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

Adds tools for appending randomized measurement bases and processing renyi entropy from bitstring #6664

Closed senecameeks closed 2 months ago

senecameeks commented 2 months ago

Requested by our NISQ team, this PR:

  1. Adds a new RandomizedMeasurement class to the experiment folder.
  2. Adds a tool in cirq/qis for computing the renyi entropy. The technique is well-known and was used by our team, for example in Satzinger et al (2021), Eq. S4 of the SM.

Notably this PR does not create a new transformer since append_random_measurements returns a sequence of circuits and thus violates the transformer api contract.

CI passes once #6662 is merged

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 97.82%. Comparing base (3922a63) to head (c92e7c9).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #6664 +/- ## ======================================== Coverage 97.82% 97.82% ======================================== Files 1068 1072 +4 Lines 91919 92029 +110 ======================================== + Hits 89917 90027 +110 Misses 2002 2002 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

eliottrosenberg commented 2 months ago

Notably this PR does not create a new transformer since append_random_measurements returns a sequence of circuits and thus violates the transformer api contract.

This could be written as a transformer that just appends the random measurements once; then append_randomized_measurements would just call that transformer num_unitaries times. That is the strategy that I took in https://github.com/quantumlib/Cirq/pull/6665, which is also meant to be called many times.