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

Merge serializable_forms and deserialized_forms #6520

Closed verult closed 6 months ago

verult commented 6 months ago

This PR simplifies the experience of updating the supported gateset for GridDevice.

The original reasons of separating of serializable_forms and deserialized_forms were twofolds:

  1. FSimGateFamily(gates_to_accept=[cirq.CZ]) does not accept cirq.GateFamily(cirq.CZ), and similarly for other 2q gates.
  2. The deserialized gateset should be as simple as possible to accept all valid gates, i.e.:
    • It should contain the minimum set of gates / GateFamilies to accept all valid gates (for example FSimGateFamily(gates_to_accept=[cirq.CZ]) and cirq.GateFamily(cirq.CZ) were considered redundant for accepting the CZ gate).
    • When possible, prefer gate types over GateFamilies (e.g. cirq.PhasedXZGate instead of cirq.GateFamily(cirq.PhasedXZGate)).

I prefer to merge these fields now because

  1. Having a single field is much easier for developers who wants to update the gateset to understand.
  2. The original design decision was that cirq.GateFamily(cirq.CZ) shouldn't be accepted by the gateset. Although rare, I don't think this is what we want.
  3. Adding GateFamilies instead of gate types is not much more complicated, and is valuable if it simplifies the experience of updating the gateset.

cc @wcourtney

codecov[bot] commented 6 months ago

Codecov Report

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

Project coverage is 97.78%. Comparing base (decf16d) to head (d81a17d). Report is 2 commits behind head on main.

:exclamation: Current head d81a17d differs from pull request most recent head d037f0f. Consider uploading reports for the commit d037f0f to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #6520 +/- ## ========================================== - Coverage 97.78% 97.78% -0.01% ========================================== Files 1105 1105 Lines 95109 95109 ========================================== - Hits 93000 92999 -1 - Misses 2109 2110 +1 ```

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