[ANN] Quasar.jl - Pure Julia OpenQASM 3 Lexing and Parsing

Quasar.jl - Pure Julia OpenQASM3 lexing and parsing

Links: GitHub

Quasar.jl is a pure Julia package for lexing and parsing OpenQASM, a popular intermediate representation for quantum programs. Quasar supports:

  • Subroutines
  • Custom gate definitions
  • Gate modifiers
  • Control flow
  • Inputs
  • Type casting
  • Supplying your own pragma definitions

What’s not yet supported:

  • Output variables (coming soon!)
  • OpenPulse
  • angle types and their logic (coming soon!)

You can parse an OpenQASM program, str, in string form like so:

parsed = Quasar.parse_qasm(str)
visitor = Quasar.QasmProgramVisitor(inputs)
visitor(parsed)

The process occurs in two steps: first an AST is generated then visited with any inputs (a Dict{String, <:Any}), so that you can re-use the AST with various sets of inputs.

Then you can query instructions(visitor) to get a list of CircuitInstructions, which you can turn into your own program’s gates and other instructions using a package like StructTypes.jl..

Quasar.jl is built on top of Automa.jl, and many thanks to the developers and maintainers of that package for creating it and answering my many questions.

Future plans are to add proper support for angles and outputs, and improve documentation for pragmas and generating your idiomatic gate dialects.

8 Likes

@kslimes If you have a publicly accessible presentation programmed, please advise us here.

Or maybe you could do an ad hoc presentation.

In fact, the OpenQASM Technical Steering Committee would love to hear a presentation on Quasar.jl at their meeting. Please contact me or Erik Davis (or anyone else with connections to the TSC) if you are interested.

Heya @jlapeyre, thanks very much for the invite! I’m basically fully booked until mid-December, but perhaps in the new year? I’ll email you (can you DM me an appropriate address?).

2 Likes