quantumlib / Cirq

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

Add warning when converting global phase operator to OpenQASM 2.0 #6476

Closed kenya-sk closed 8 months ago

kenya-sk commented 8 months ago

OpenQASM 2.0 does not support global phase (https://github.com/Qiskit/qiskit/issues/7167#issuecomment-947821313). Therefore, the current implementation generated an error and terminated the program. Since the global phase does not affect the observation results, I have changed it to be supported as a warning and the program can be executed.

The following is how to handle the situation.

  1. Determine if the operator passed to qasm() is an instance of ops.GlobalPhaseGate. If a Circuit is passed, it is deployed to each operator by existing implementations and a decision is made for each.
  2. If it is an instance of ops.GlobalPhaseGate, generate a warning and return an empty string for compatibility with previous implementations.
  3. Otherwise, the operation is the same as before.

fixes https://github.com/quantumlib/Cirq/issues/6457

codecov[bot] commented 8 months ago

Codecov Report

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

Project coverage is 97.76%. Comparing base (eef7c5c) to head (4281e86).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #6476 +/- ## ======================================= Coverage 97.75% 97.76% ======================================= Files 1105 1105 Lines 94924 94936 +12 ======================================= + Hits 92793 92810 +17 + Misses 2131 2126 -5 ```

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

NoureldinYosri commented 8 months ago

@kenya-sk thanks for taking care of this

kenya-sk commented 8 months ago

@NoureldinYosri Thank you for review. I have removed the changes that are not relevant to this issue.

rht commented 8 months ago

Thank you @kenya-sk @NoureldinYosri.