Architecture

Component Overview

The following diagram shows the architecture of the backend:

Backend Component Overview

The backend is composed of the following main components:

  • Processing (app.processing): Coordinates the end-to-end handling of CompileRequest, including compilation and enrichment.

  • Enricher (app.enricher): Retrieves implementations and is extendable via strategies that implement EnricherStrategy

  • Preprocessing (app.processing.pre): Contains logic for individual node transformations that do not require global graph context, such as:

  • Optimization (app.processing.optimize): Attempts to reduce circuit width via ancilla reuse heuristics.

  • Merging (app.processing.merge): Applies the graph connections and flattens the node structure into a single, linear OpenQASM program.

  • Postprocessing (app.processing.post): Performs cleanup steps such as removing duplicate imports and rendering the final program into OpenQASM 3.1.

  • Nested Structures (app.processing.nested):

    • Repeat (app.processing.nested.repeat): Unrolls the repeat node to be processed by the pipeline.

    • If-Then-Else (app.processing.nested.if_then_else): Merges two subgraphs into one big if-then-else statement by using parts of processing

Pipeline Flow

The following diagram illustrates the pipeline stages for processing a CompileRequest:

Compilation Pipeline

Upon receiving a CompileRequest, the backend transforms the input model into an internal graph and processes it through a five-stage pipeline: node enrichment, syntactic and semantic preprocessing, optional ancilla-optimized circuit optimization, output-input merging, and final AST normalization. The result is a complete, semantically valid OpenQASM 3 program.