Skip to content
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

Rewrite OpenQASM 3 exporter symbol table #12776

Merged
merged 6 commits into from
Jul 22, 2024

Commits on Jul 22, 2024

  1. Rewrite OpenQASM 3 exporter symbol table

    This rewrites the symbol handling of the OpenQASM 3 exporter to decouple
    object identities from the necessary object identifiers.  As part of
    this, we use the same trick of standard-gate reparametrisation to
    produce gate-definition sources for Qiskit built-ins, which fixes many
    cases of bad parametrisation of gates like `rzx`.
    
    This kind of rewrite was necessary to fix the now-bad assumption within
    the OQ3 exporter that "gate identity" is always static within a circuit.
    Since standard gate `Gate` instances are now only generated on demand,
    there is no guarantee of stability of them.  The fix to the definition
    source for these makes them independent of object identity.
    User-defined gates can still use the identity, as these are still
    guaranteed static.
    
    This commit fixes almost all of the "bad parametrisation" tests in the
    test suite.  There are several other changes in the test suite
    necessary:
    
    * since the uniqueness of the identifier is now independent of how the
      lookup of a Qiskit object works, there is no need to include the
      highly non-deterministic `id` in the generated symbols for user gates.
      Several tests changed to use the new, simple count-based unique names.
    
    * the escaping and uniqueness rules now apply uniformly to all gate
      definitions, fixing several bad test cases that previously were
      testing invalid OpenQASM 3.
    
    * the escaping rules changed slightly for naming collisions with
      keywords, making them slightly more consistent with how other renaming
      rules worked.
    jakelishman committed Jul 22, 2024
    Configuration menu
    Copy the full SHA
    ec8a321 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2cbf15f View commit details
    Browse the repository at this point in the history
  3. Rename qiskit gates whose names are OQ3 hardware qubit identifiers

    If a custom qiskit gate is given a name that is a valid identifer for a
    hardware qubit in OQ3, then, before this commit, the name would not be
    escaped when writing the OQ3 gate definition.
    
    This commit fixes this by escaping the leading dollar sign as it would
    be in any other position in the name. That is, the dollar sign is
    replaced by underscore.
    
    Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
    jlapeyre and jakelishman committed Jul 22, 2024
    Configuration menu
    Copy the full SHA
    598fae3 View commit details
    Browse the repository at this point in the history
  4. Reduce overloading of word "definition"

    Much of what we're doing with the "definition source" is actually a form
    of object canonicalisation for comparison purposes.  It's clearer to use
    this terminology.
    jakelishman committed Jul 22, 2024
    Configuration menu
    Copy the full SHA
    771676c View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    b51386f View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    984c422 View commit details
    Browse the repository at this point in the history