qiskit-advocate/qamp-fall-21

OpenQASM 3 Reference Implementation

jwoehr opened this issue · 19 comments

Description

Begin a reference implementation of OpenQASM 3 that can be updated as details of the specification necessarily change somewhat.

The new version of the Open Quantum Assembler has a reference grammar written in Apache ANTLR4.

The mentor has already used a subset of the grammar to create an OpenQASM 2 implementation. We can evolve that concept towards an OpenQASM 3.

Mentor/s

Jack Woehr

Type of participant

Good Python coder (or other languages) with some experience in DSLs (Domain-Specific Languages)

Number of participants

1-2

Deliverable

Working, updatable reference implementation of OpenQASM 3

I am very interested in OpenQASM3 so I am thinking about whether I should become a mentee this time :) What exactly do you in mind as a “reference implantation”? Is it a compiler that takes OpenQASM3 code and converts to Qiskit code?

I am very interested in OpenQASM3 so I am thinking about whether I should become a mentee this time :) What exactly do you in mind as a “reference implantation”? Is it a compiler that takes OpenQASM3 code and converts to Qiskit code?

Output is a QuantumCircuit instance (or a text dump of the AST if desired for debugging, that sort of thing)

I am very much interested by this project too!
What are the tools you plan to use for this project? Without a doubt Python, but how will the grammar be read? Do you have any library in mind (ANTLR4, other?) or is it something that needs to be discussed beforehand and that has not been decided yet?

There is an ANTLR4 grammar in the Qiskit/openqasm tree.

If you clone Qiskit/openqasm and do make html you will see there is a chapter at the end of the OpenQASM Live Specification about the Grammar.

The developers to some extent dismiss it as a reference grammar and expect more performant tools will be used in final products, and this is probably true.

However, a reference implementation of at least part of OpenQASM 3 would be a milestone.

I already have used a subset of that grammar (qasm3.g4) to do a rewrite of the OpenQASM 2 compiler which is currently in PR for Qiskit Terra: New OpenQASM2 translator based on ANTLR4 grammar

If we put a team together, e.g., @nelimee @HuangJunye @AbeerVaishnav13 of course we can discuss what tools to use. But since already have a working OpenQASM2 translator to QuantumCircuit it might be easy to start there.

Yes, I too am interested in working on this project. I went through some resources that @jwoehr sent through slack and I found it very interesting.

Is everyone who is interested applying via the mentorship form?

@nelimee @AbeerVaishnav13 @HuangJunye check out the recording which @taalexander posted to the open-qasm channel on Qiskit Slack.

Today 2021-08-30 is the deadline for applying for mentorship.

All ... note this PR openqasm/openqasm#269

https://github.com/mentor-fall2021-openqasm is our new GitHub organization

@mrvee-qC Can you please comment in the issue so that I can assign you?

@mrvee-qC Can you please comment in the issue so that I can assign you?

Sure! :D

@mrvee-qC @nelimee @AbeerVaishnav13 Can you please upload your presentation here by the end of today? Thank you!

Uploading the updated presentation after certain changes.

#23-OpenQASM3 Reference Implementation.pdf

Checkpoint 2, November 11

For a unified report, please check out our dedicated website page for this mentorship project! https://mentor-fall2021-openqasm.github.io/posts/checkpoint-2/

Summary since October 7 Checkpoint #1

Progress Summary

The version 1 of the implementation showcased on October 7 - Checkpoint #1 now has several fixes and changes with regards to the translator functionality with conformance to the OpenQASM 3.0 specification. Here are a few changes summarized on the v1 implementation:

  • Type system flaws identified and fixed in conformance to specification
  • Implementations for quantum and classical registers now robust in aliasing.
  • Initial implementation of 'duration' as per specification
  • Cleanup and reconciling minor changes that further strengthen stricter conformance to implementation according to specification.

Contribution Summary:

  • PR #295 : Suggestion to add Scope for power operator for complex types in language specification. Discussions taken up at TSC meeting. Discussions of requirement of dot notation of complex numbers for few rare use case implementations.
  • Issue #296 : Following discussion with taalexander at IEEE Quantum Week on OpenPulse grammar implementation and Jacks further discussions on the same, team is now added to the openpulse closed group for discussion with guidance from people and teams working on OpenPulse.
  • PR #269 : Team contributed to bug and implementation fixes for reference AST implementation PR which was merged this month.
  • Issue #304 : Bug report for openqasm3 pyPI package.
  • Presented progress and project overview at Qiskit advocate session at IEEE Quantum Week 2021.

Goals and further direction:

  • Reconstruct and restart current repository to depend on openqasm package rather than forks of openqasm repository and outsource package dependencies for openasm parser, ast and other components
  • Work in support of PR #295 and fulfillment of Issue #296.
  • Take inspirations from discussions in Issue #296 and start writing to invent own grammar and connect it to openpulse, eventually towards an implementation for translating to qiskit-pulse/ qiskit-pulse builder syntax.
  • Take opinions and hints from openpulse invested parties in the discussion in Issue #296 while creating it along. Have received guidance support from openpulse closed group