openqasm icon indicating copy to clipboard operation
openqasm copied to clipboard

Make the semantic of `gphase();` clearer.

Open nakrakiiya opened this issue 3 years ago • 2 comments

Summary

Make the semantic of gphase(); clearer. See https://github.com/openqasm/openqasm/issues/383 . This definition of gphase() also allows accumulation.

Details and comments

The semantic of gphase(); in Amazon Braket is just add a global phase gate to the containing scope. No matter which qubit is applied to, the result state of the circuit is the same. In this case, an n-qubits global phase gate is more reasonable.

If someone just want the state of a specific qubit, this design cannot distinguish which qubit gphase(); applies to.

The "scope" is also more specific. Only gate, subroutine, and global scope have qubits declaration/definition. If we only limit to the containing scope, for example, the for scope, the semantic can also be "do nothing" because no qubits declared/defined in the for scope.

nakrakiiya avatar Aug 22 '22 06:08 nakrakiiya

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Aug 22 '22 06:08 CLAassistant

From TSC meeting 2022-09-02: there is a question of what gphase would mean inside a subroutine, and whether it's worth needing to specify any special rules for it. In particular, it's not obvious what the behaviour would be if the same qubit is passed as different arguments.

There was approximate agreement (without a quorum) to:

  • accept this PR as-is
  • (Lev) largely rewrite gates.rst to simplify all of its text, including this PR
  • (me) add a separate PR to explicitly forbid qubit references to alias the same qubit in subroutine calls

We need further assent/comment from @pschindler, @blakejohnson or @ajavadia before we can merge this, though.

jakelishman avatar Sep 02 '22 16:09 jakelishman

Is this now subsumed by #393 ?

blakejohnson avatar Jan 06 '23 15:01 blakejohnson

Is this now subsumed by #393 ? Yes my intention is that #393 morally includes this revision.

levbishop avatar Jan 06 '23 16:01 levbishop

Closing in favour of #393.

jakelishman avatar Jan 06 '23 18:01 jakelishman