Conversions

Internal Conversions

-qc-to-qco

Convert QC dialect to QCO dialect.

This pass converts all operations from the QC dialect to their equivalent operations in the QCO dialect. It handles the transformation of qubit references in QC to qubit values in QCO, ensuring that the semantics of quantum operations are preserved during the conversion process.

-qco-to-qc

Convert QCO dialect to QC dialect.

This pass converts all operations from the QCO dialect to their equivalent operations in the QC dialect. It handles the transformation of qubit values in QCO to qubit references in QC, ensuring that the semantics of quantum operations are preserved during the conversion process.

jeff Conversions

-qco-to-jeff

Convert QCO operations to jeff operations

This pass converts all operations from the QCO dialect to their equivalent operations in the jeff dialect. It ensures that the returned module is a valid jeff module that can be serialized.

Note that this pass is still in development as QCO and jeff do not have full feature parity yet.

qco.static is currently converted to jeff.qubit_alloc because jeff does not yet represent static (index-based) qubits. As the index is not preserved in jeff, it is not possible to round-tripping static qubits.

-jeff-to-qco

Convert jeff operations to QCO operations

This pass converts all operations from the jeff dialect to their equivalent operations in the QCO dialect. It ensures that the returned module is a valid QCO module.

Note that this pass is still in development as QCO and jeff do not have full feature parity yet.

Known limitations:

  • Only specific CustomOps are currently supported

  • Only specific PPROps are currently supported

  • Support for multiple functions is currently limited

QIR Conversions

-qc-to-qir-base

Lower the QC dialect to the LLVM dialect compliant with the QIR Base Profile 2.1

This pass lowers all operations from the QC dialect to their equivalent operations in the LLVM dialect, ensuring compliance with the QIR Base Profile 2.1 standard. It translates quantum operations and types from QC to their corresponding representations in QIR, facilitating interoperability with quantum computing frameworks that utilize the QIR standard.

Requirements:

  • Input is a valid module in the QC dialect.

  • The entry function must be marked with the entry_point attribute.

  • The input entry function must consist of a single block. Multi-block input functions are currently not supported.

  • The program must have straight-line control flow (i.e., Base Profile QIR).

Behavior:

  • Each QC quantum operation is replaced by a call to the corresponding QIR function in the LLVM dialect.

  • Required QIR module flags are attached as attributes to the entry function.

  • The pass transforms the single-block entry function into four blocks to satisfy QIR Base Profile constraints: 0. Initialization block: Sets up the execution environment and performs required runtime initialization.

    1. Reversible operations block: Contains only void-returning calls to reversible quantum operations.

    2. Irreversible operations block: Contains only void-returning calls to operations marked irreversible (e.g., __quantum__qis__mz__body and __quantum__qis__reset__body).

    3. Epilogue block: Records measurement results and returns from the entry function.

  • Blocks are connected via unconditional branches in the order listed above.

  • Non-quantum dialects are lowered via MLIR’s built-in conversions.

-qc-to-qir-adaptive

Lower the QC dialect to the LLVM dialect compliant with the QIR Adaptive Profile 2.1

This pass lowers all operations from the QC dialect to their equivalent operations in the LLVM dialect, ensuring compliance with the QIR Adaptive Profile 2.1 standard. It translates quantum operations and types from QC to their corresponding representations in QIR, facilitating interoperability with quantum computing frameworks that utilize the QIR standard.

Requirements:

  • Input is a valid module in the QC dialect.

  • The entry function must be marked with the entry_point attribute.

Behavior:

  • Each QC quantum operation is replaced by a call to the corresponding QIR function in the LLVM dialect.

  • Operations from the scf dialect are lowered into the cf dialect before they are lowered to the LLVM dialect.

  • Required QIR module flags are attached to the MLIR module.

  • Required attributes are attached to the entry function.

  • The pass extends the existing block structure of the entry function with an entry block and an epilogue block: 0. Initialization block: Sets up the execution environment and performs required runtime initialization.

    1. Epilogue block: Records measurement results and returns from the entry function. Any blocks in-between have no restrictions regarding their operations as long as they are supported.

  • Measurement results may be used as classical values to drive conditional branches.

  • Non-quantum dialects are lowered via MLIR’s built-in conversions.