Architecture
Component Overview
The following diagram shows the architecture of the backend:
The backend is composed of the following main components:
Processing (
app.transformation_manager): Coordinates the end-to-end handling ofCompileRequest, including compilation and enrichment.Enricher (
app.enricher): Retrieves implementations and is extendable via strategies that implementEnricherStrategyPreprocessing (
app.transformation_manager.pre): Contains logic for individual node transformations that do not require global graph context, such as:Converter (
app.transformation_manager.pre.converter): Converts OpenQASM 2 to OpenQASM 3.Renaming (
app.transformation_manager.pre.renaming): Ensures unique and conflict-free identifiers.Inlining (
app.transformation_manager.pre.inlining): Replaces aliases with their resolved content.IO Parser (
app.transformation_manager.pre.io_parser): Parses input/output annotations.Size Casting (
app.transformation_manager.pre.size_casting): Aligns input register sizes.
Optimization (
app.transformation_manager.optimize): Attempts to reduce circuit width via ancilla reuse heuristics.Merging (
app.transformation_manager.merge): Applies the graph connections and flattens the node structure into a single, linear OpenQASM program.Postprocessing (
app.transformation_manager.post): Performs cleanup steps such as removing duplicate imports and rendering the final program into OpenQASM 3.1.Nested Structures (
app.transformation_manager.nested):Repeat (
app.transformation_manager.nested.repeat): Unrolls the repeat node to be processed by the pipeline.If-Then-Else (
app.transformation_manager.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:
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.