Catalyst Quantum Compiler

The Catalyst Quantum Compiler is an MLIR-based compiler core for hybrid quantum-classical programs. Catalyst defines a new quantum dialect in MLIR which is used alongside built-in MLIR dialects to represent, transform, and optimize such hybrid programs using a single unified representation.

The quantum dialect employs a value-semantics representation of quantum operations, meaning that quantum ops consume and produce qubit “state values”. These state values are not “computed” in a traditional sense during execution, and are in fact removed when lowering out of the IR, but do allow the dataflow of quantum operations to be represented in the SSA graph of the IR, similar to directed acyclic graph (DAG) representations of quantum circuits. This allows quantum circuit transformations to more easily traverse the IR without requiring dataflow analysis.

Quantum and classical gradient methods have also been implemented at the IR level in a separate dialect. These methods generally work (with some limitations) even in the presence of control flow and classical instructions embedded in the quantum program. Provided techniques include the parameter-shift, adjoint, and finite-difference methods.

Contents

This module contains out-of-tree dialect definitions for the MLIR compiler framework, and the directory structure generally follows the recommended practices from the upstream project:

  • include:

    This contains declarative definitions of new IR objects such as custom dialects, types, and operations in the form of TableGen (.td) files. TableGen is a small language used by MLIR to simplify the definition of C++ classes and reduce boilerplate code.

    Additionally, headers for use in various parts of the compiler core are also defined here.

  • lib:

    Any C++ code for dialects not generated by TableGen is placed here. This includes additional operation methods such as verifiers, canonicalizers, and interface functions, as well as transformation passes and rewrite patterns. Some of the transformations include dialect bufferizations, dialect conversions, gradient methods, and optimizations.

  • python:

    MLIR Python bindings for the quantum and gradient dialects.

  • test:

    A collection of lit (LLVM integrated tester) tests for the quantum and gradient dialects.

  • tools:

    A collection of stand-alone executables built by the project. Currently includes the quantum-opt tool to run passes on .mlir files, and quantum-lsp-server, a language server for MLIR with support for the quantum and gradient dialect.