From 8fcd4789850213e5ff696de56a3afb1684ed881f Mon Sep 17 00:00:00 2001 From: Daniel Haag <121057143+denialhaag@users.noreply.github.com> Date: Thu, 19 Mar 2026 01:20:33 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=8E=A8=20Fix=20dependent=20dialects?= =?UTF-8?q?=20of=20conversions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mlir/Conversion/JeffToQCO/JeffToQCO.td | 1 - .../mlir/Conversion/QCOToJeff/QCOToJeff.td | 4 -- .../mlir/Conversion/QCOToQC/QCOToQC.td | 12 ++-- .../mlir/Conversion/QCToQCO/QCToQCO.td | 12 ++-- .../mlir/Conversion/QCToQIR/QCToQIR.td | 68 +++++++++---------- 5 files changed, 42 insertions(+), 55 deletions(-) diff --git a/mlir/include/mlir/Conversion/JeffToQCO/JeffToQCO.td b/mlir/include/mlir/Conversion/JeffToQCO/JeffToQCO.td index 9237a19aa4..5a561215f2 100644 --- a/mlir/include/mlir/Conversion/JeffToQCO/JeffToQCO.td +++ b/mlir/include/mlir/Conversion/JeffToQCO/JeffToQCO.td @@ -31,7 +31,6 @@ def JeffToQCO : Pass<"jeff-to-qco"> { "mlir::arith::ArithDialect", "mlir::math::MathDialect", "mlir::tensor::TensorDialect", - "mlir::jeff::JeffDialect", "mlir::qco::QCODialect", ]; } diff --git a/mlir/include/mlir/Conversion/QCOToJeff/QCOToJeff.td b/mlir/include/mlir/Conversion/QCOToJeff/QCOToJeff.td index e31f5bc5a1..1c54ad9d15 100644 --- a/mlir/include/mlir/Conversion/QCOToJeff/QCOToJeff.td +++ b/mlir/include/mlir/Conversion/QCOToJeff/QCOToJeff.td @@ -19,10 +19,6 @@ def QCOToJeff : Pass<"qco-to-jeff"> { }]; let dependentDialects = [ - "mlir::arith::ArithDialect", - "mlir::math::MathDialect", - "mlir::tensor::TensorDialect", "mlir::jeff::JeffDialect", - "mlir::qco::QCODialect", ]; } diff --git a/mlir/include/mlir/Conversion/QCOToQC/QCOToQC.td b/mlir/include/mlir/Conversion/QCOToQC/QCOToQC.td index 2d18c02fa3..1863f4c957 100644 --- a/mlir/include/mlir/Conversion/QCOToQC/QCOToQC.td +++ b/mlir/include/mlir/Conversion/QCOToQC/QCOToQC.td @@ -12,15 +12,11 @@ def QCOToQC : Pass<"qco-to-qc"> { let summary = "Convert QCO dialect to QC dialect."; let description = [{ - 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. - }]; + 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. + }]; - // Define dependent dialects let dependentDialects = [ - "mlir::qco::QCODialect", - "mlir::qc::QCDialect" + "mlir::qc::QCDialect", ]; } diff --git a/mlir/include/mlir/Conversion/QCToQCO/QCToQCO.td b/mlir/include/mlir/Conversion/QCToQCO/QCToQCO.td index e9bb48328e..46dfd45336 100644 --- a/mlir/include/mlir/Conversion/QCToQCO/QCToQCO.td +++ b/mlir/include/mlir/Conversion/QCToQCO/QCToQCO.td @@ -12,15 +12,11 @@ def QCToQCO : Pass<"qc-to-qco"> { let summary = "Convert QC dialect to QCO dialect."; let description = [{ - 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. - }]; + 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. + }]; - // Define dependent dialects let dependentDialects = [ - "mlir::qc::QCDialect", - "mlir::qco::QCODialect" + "mlir::qco::QCODialect", ]; } diff --git a/mlir/include/mlir/Conversion/QCToQIR/QCToQIR.td b/mlir/include/mlir/Conversion/QCToQIR/QCToQIR.td index dbc875b6ee..dd76a403ca 100644 --- a/mlir/include/mlir/Conversion/QCToQIR/QCToQIR.td +++ b/mlir/include/mlir/Conversion/QCToQIR/QCToQIR.td @@ -12,40 +12,40 @@ def QCToQIR : Pass<"qc-to-qir"> { let summary = "Lower the QC dialect to the LLVM dialect compliant with QIR 2.0"; let description = [{ - This pass lowers all operations from the QC dialect to their equivalent - operations in the LLVM dialect, ensuring compliance with the QIR 2.0 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`, `__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. - - Producing LLVM IR: - - After conversion to the LLVM dialect, produce LLVM IR with: - mlir-translate --mlir-to-llvmir input.mlir > output.ll - }]; - - - // Define dependent dialects + This pass lowers all operations from the QC dialect to their equivalent operations in the LLVM dialect, ensuring compliance with the QIR 2.0 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. + + Producing LLVM IR: + + - After conversion to the LLVM dialect, produce LLVM IR with: + + ``` + mlir-translate --mlir-to-llvmir input.mlir > output.ll + ``` + }]; + + let dependentDialects = [ - "mlir::LLVM::LLVMDialect", - "mlir::QCDialect", + "mlir::LLVM::LLVMDialect", ]; } From ef4fafc1681eaba42854fde03046fe6503ca93c5 Mon Sep 17 00:00:00 2001 From: Daniel Haag <121057143+denialhaag@users.noreply.github.com> Date: Thu, 19 Mar 2026 01:25:12 +0100 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0de707dd37..2a54605c71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ This project adheres to [Semantic Versioning], with the exception that minor rel - ✨ Add conversions between Jeff and QCO ([#1479], [#1548], [#1565]) ([**@denialhaag**]) - ✨ Add a `place-and-route` pass for mapping circuits to architectures with restricted topologies ([#1537], [#1547], [#1568]) ([**@MatthiasReumann**]) - ✨ Add initial infrastructure for new QC and QCO MLIR dialects - ([#1264], [#1330], [#1402], [#1428], [#1430], [#1436], [#1443], [#1446], [#1464], [#1465], [#1470], [#1471], [#1472], [#1474], [#1475], [#1506], [#1510], [#1513], [#1521], [#1548], [#1550], [#1554], [#1570]) + ([#1264], [#1330], [#1402], [#1428], [#1430], [#1436], [#1443], [#1446], [#1464], [#1465], [#1470], [#1471], [#1472], [#1474], [#1475], [#1506], [#1510], [#1513], [#1521], [#1548], [#1550], [#1554], [#1570], [#1572]) ([**@burgholzer**], [**@denialhaag**], [**@taminob**], [**@DRovara**], [**@li-mingbao**], [**@Ectras**], [**@MatthiasReumann**], [**@simon1hofmann**]) ### Changed @@ -332,6 +332,7 @@ _📚 Refer to the [GitHub Release Notes](https://github.com/munich-quantum-tool +[#1572]: https://github.com/munich-quantum-toolkit/core/pull/1572 [#1571]: https://github.com/munich-quantum-toolkit/core/pull/1571 [#1570]: https://github.com/munich-quantum-toolkit/core/pull/1570 [#1568]: https://github.com/munich-quantum-toolkit/core/pull/1568