skillfed

openqasm3

Reference OpenQASM AST in Python

openqasm3 v1.0.1 483.3K downloads/30d#6,415 on PyPI1,497
Permissive license Apache 2.0 Software License Active released

What it is and what it does

openqasm3 is a reference implementation of the OpenQASM 3 abstract syntax tree in Python, designed to help developers write compiler passes and tools for quantum programs. It provides three main components: the AST node definitions, a parser that converts OpenQASM 3 text into the tree structure, and a visitor/transformer base for traversing and modifying the AST.

The package deliberately minimizes dependencies for users who only consume the AST structure itself, with optional dependencies available for parsing functionality. It is maintained as part of the main OpenQASM project and actively developed alongside the OpenQASM 3 language specification itself, though the API is currently in early stages and not considered stable.

Use it for:

  • Build compiler optimization passes that analyze and transform OpenQASM 3 quantum circuits
  • Parse OpenQASM 3 source files into an in-memory representation for analysis or code generation
  • Traverse and modify quantum program ASTs using visitor and transformer patterns
  • Develop quantum software tools that need to understand OpenQASM 3 program structure

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a reference abstract syntax tree (AST) for OpenQASM 3 quantum programs, with parsing and AST manipulation tools for building compiler passes in Python.

Yes, if you are working with OpenQASM 3 quantum programs and need to parse or manipulate them programmatically. The low install friction and active maintenance make it a practical choice. However, be aware that the API is explicitly unstable and subject to breaking changes as the OpenQASM 3 language itself evolves—pin your version carefully in production code.

Install

openqasm3 on PyPI

pip

pip install openqasm3

uv

uv add openqasm3

poetry

poetry add openqasm3

Installing openqasm3

Before you install

Low install friction with no runtime dependencies for basic AST consumption. Actively maintained with recent releases; note that the API is explicitly in early development and not yet stable.

License in practice

Licensed under Apache 2.0 (permissive), allowing commercial and private use with minimal restrictions.

Quickstart

pip install openqasm3

import openqasm3

# Parse OpenQASM 3 text into AST
ast = openqasm3.parser.parse_file('program.qasm')

Parser functionality requires the optional 'parser' extra; install with `pip install openqasm3[parser]` to use parsing features.

Verify before relying

  • Whether the AST API stability improves in future releases or remains subject to breaking changes
  • Performance characteristics when working with large or complex quantum programs

Package facts

License Apache 2.0 Software License (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 541 days since the last release
Last repo commit
First released
Downloads 483,280/month — #6,415 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: openqasm3-1.0.1-py3-none-any.whl

Keywords: openqasm, quantum

Intended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: Apache Software LicenseOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3 :: OnlyTopic :: Scientific/Engineering

Tags

openqasm 3 ast parserquantum program abstract syntax treeopenqasm compiler toolsquantum circuit representation pythonqasm3 ast manipulationquantum language parsing
quantum-computingcompiler-tools

More Scientific/Engineering packages