Skip to content

Commit d8f551d

Browse files
denialhaagpre-commit-ci[bot]burgholzer
authored
✨ Add conversions between Jeff and QCO (#1479)
## Description This PR adds conversions for the [Jeff dialect](https://github.com/PennyLaneAI/jeff-mlir). Fixes #1546 ## Checklist: - [ ] The pull request only contains commits that are focused and relevant to this change. - [x] I have added appropriate tests that cover the new/changed functionality. - [x] ~~I have updated the documentation to reflect these changes.~~ - [x] I have added entries to the changelog for any noteworthy additions, changes, fixes, or removals. - [x] ~~I have added migration instructions to the upgrade guide (if needed).~~ - [x] The changes follow the project's style guidelines and introduce no new warnings. - [x] The changes are fully tested and pass the CI checks. - [x] I have reviewed my own code changes. --------- Signed-off-by: Daniel Haag <121057143+denialhaag@users.noreply.github.com> Signed-off-by: burgholzer <burgholzer@me.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: burgholzer <burgholzer@me.com>
1 parent ab78766 commit d8f551d

27 files changed

Lines changed: 3484 additions & 70 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning], with the exception that minor rel
1111

1212
### Added
1313

14+
- ✨ Add conversions between Jeff and QCO ([#1479]) ([**@denialhaag**])
1415
- ✨ Add a `place-and-route` pass for mapping circuits to architectures with restricted topologies ([#1537]) ([**@MatthiasReumann**])
1516
- ✨ Add initial infrastructure for new QC and QCO MLIR dialects
1617
([#1264], [#1330], [#1402], [#1428], [#1430], [#1436], [#1443], [#1446], [#1464], [#1465], [#1470], [#1471], [#1472], [#1474], [#1475], [#1506], [#1510], [#1513], [#1521])
@@ -334,6 +335,7 @@ _📚 Refer to the [GitHub Release Notes](https://github.com/munich-quantum-tool
334335
[#1510]: https://github.com/munich-quantum-toolkit/core/pull/1510
335336
[#1506]: https://github.com/munich-quantum-toolkit/core/pull/1506
336337
[#1481]: https://github.com/munich-quantum-toolkit/core/pull/1481
338+
[#1479]: https://github.com/munich-quantum-toolkit/core/pull/1479
337339
[#1475]: https://github.com/munich-quantum-toolkit/core/pull/1475
338340
[#1474]: https://github.com/munich-quantum-toolkit/core/pull/1474
339341
[#1472]: https://github.com/munich-quantum-toolkit/core/pull/1472

CMakeLists.txt

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ project(
1414
LANGUAGES C CXX
1515
DESCRIPTION "MQT Core - The Backbone of the Munich Quantum Toolkit")
1616

17+
if(NOT DEFINED CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 20)
18+
set(CMAKE_CXX_STANDARD
19+
20
20+
CACHE STRING "C++ standard to conform to" FORCE)
21+
endif()
22+
1723
# Add path for custom modules
1824
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1925

@@ -51,16 +57,8 @@ if(BUILD_MQT_CORE_BINDINGS)
5157
${SKBUILD_SABI_COMPONENT})
5258
endif()
5359

54-
# check if this is the master project or used via add_subdirectory
55-
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
56-
set(MQT_CORE_MASTER_PROJECT ON)
57-
else()
58-
set(MQT_CORE_MASTER_PROJECT OFF)
59-
endif()
60-
61-
option(MQT_CORE_INSTALL "Generate installation instructions for MQT Core"
62-
${MQT_CORE_MASTER_PROJECT})
63-
option(BUILD_MQT_CORE_TESTS "Build tests for the MQT Core project" ${MQT_CORE_MASTER_PROJECT})
60+
option(MQT_CORE_INSTALL "Generate installation instructions for MQT Core" ${PROJECT_IS_TOP_LEVEL})
61+
option(BUILD_MQT_CORE_TESTS "Build tests for the MQT Core project" ${PROJECT_IS_TOP_LEVEL})
6462
option(BUILD_MQT_CORE_SHARED_LIBS "Build MQT Core libraries as shared libraries"
6563
${BUILD_SHARED_LIBS})
6664
option(BUILD_MQT_CORE_MLIR "Build the MLIR submodule of the MQT Core project" ON)
@@ -97,6 +95,10 @@ project(
9795
VERSION ${MQT_CORE_VERSION}
9896
DESCRIPTION "MQT Core - The Backbone of the Munich Quantum Toolkit")
9997

98+
if(BUILD_MQT_CORE_MLIR)
99+
include(SetupMLIR)
100+
endif()
101+
100102
include(cmake/ExternalDependencies.cmake)
101103

102104
# set the include directory for the build tree
@@ -116,9 +118,6 @@ endif()
116118

117119
set(MQT_CORE_TARGET_NAME "mqt-core")
118120

119-
if(BUILD_MQT_CORE_MLIR)
120-
include(SetupMLIR)
121-
endif()
122121
cmake_dependent_option(BUILD_MQT_CORE_QIR_RUNNER "Build the QIR runner of the MQT Core project" ON
123122
"BUILD_MQT_CORE_MLIR" OFF)
124123

@@ -155,10 +154,9 @@ if(BUILD_MQT_CORE_MLIR)
155154
${CMAKE_CURRENT_SOURCE_DIR}/cmake/CleanMLIRDocs.cmake
156155
COMMENT "Copying and cleaning up generated MLIR documentation"
157156
VERBATIM)
158-
159157
endif()
160158

161-
if(MQT_CORE_MASTER_PROJECT)
159+
if(PROJECT_IS_TOP_LEVEL)
162160
if(NOT TARGET mqt-core-uninstall)
163161
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in
164162
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY)

cmake/ExternalDependencies.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ if(BUILD_MQT_CORE_MLIR)
3333
CACHE INTERNAL "Disable building Eigen tests")
3434
FetchContent_Declare(Eigen URL ${Eigen_URL} FIND_PACKAGE_ARGS ${Eigen_VERSION})
3535
list(APPEND FETCH_PACKAGES Eigen)
36+
37+
# Fetch jeff-mlir
38+
set(BUILD_JEFF_MLIR_TRANSLATION
39+
OFF
40+
CACHE BOOL "Disable building the translation submodule of jeff-mlir")
41+
FetchContent_Declare(
42+
jeff-mlir
43+
GIT_REPOSITORY https://github.com/PennyLaneAI/jeff-mlir.git
44+
GIT_TAG 7960f4e83e9bbc48c6d6bf203ebe5250945d9de3)
45+
list(APPEND FETCH_PACKAGES jeff-mlir)
3646
endif()
3747

3848
set(JSON_VERSION

cmake/GetVersion.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
# * MQT_CORE_VERSION_FOUND (TRUE if version was found, FALSE otherwise)
2020

2121
function(version_from_skbuild)
22-
if(NOT MQT_CORE_MASTER_PROJECT)
22+
if(NOT PROJECT_IS_TOP_LEVEL)
2323
message(VERBOSE
24-
"Not the master project. Cannot determine project version from scikit-build-core.")
24+
"Not the top-level project. Cannot determine project version from scikit-build-core.")
2525
return()
2626
endif()
2727

@@ -205,7 +205,7 @@ function(get_mqt_core_version)
205205
FALSE
206206
CACHE INTERNAL "MQT_CORE_VERSION_FOUND")
207207

208-
if(MQT_CORE_MASTER_PROJECT)
208+
if(PROJECT_IS_TOP_LEVEL)
209209
version_from_skbuild()
210210
if(MQT_CORE_VERSION_FOUND)
211211
message(

mlir/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66
#
77
# Licensed under the MIT License
88

9-
if(NOT DEFINED CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 20)
10-
set(CMAKE_CXX_STANDARD
11-
20
12-
CACHE STRING "C++ standard to conform to")
13-
endif()
14-
159
if(MSVC)
1610
add_compile_definitions(_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING)
1711
endif()

mlir/include/mlir/Conversion/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#
77
# Licensed under the MIT License
88

9+
add_subdirectory(JeffToQCO)
10+
add_subdirectory(QCOToJeff)
911
add_subdirectory(QCOToQC)
1012
add_subdirectory(QCToQCO)
1113
add_subdirectory(QCToQIR)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) 2023 - 2026 Chair for Design Automation, TUM
2+
# Copyright (c) 2025 - 2026 Munich Quantum Software Company GmbH
3+
# All rights reserved.
4+
#
5+
# SPDX-License-Identifier: MIT
6+
#
7+
# Licensed under the MIT License
8+
9+
set(LLVM_TARGET_DEFINITIONS JeffToQCO.td)
10+
mlir_tablegen(JeffToQCO.h.inc -gen-pass-decls -name JeffToQCO)
11+
add_public_tablegen_target(JeffToQCOIncGen)
12+
13+
add_mlir_doc(JeffToQCO MLIRJeffToQCO Conversions/ -gen-pass-doc)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (c) 2023 - 2026 Chair for Design Automation, TUM
3+
* Copyright (c) 2025 - 2026 Munich Quantum Software Company GmbH
4+
* All rights reserved.
5+
*
6+
* SPDX-License-Identifier: MIT
7+
*
8+
* Licensed under the MIT License
9+
*/
10+
11+
#pragma once
12+
13+
#include <mlir/Pass/Pass.h>
14+
15+
namespace mlir {
16+
#define GEN_PASS_DECL_JEFFTOQCO
17+
#include "mlir/Conversion/JeffToQCO/JeffToQCO.h.inc"
18+
19+
#define GEN_PASS_REGISTRATION
20+
#include "mlir/Conversion/JeffToQCO/JeffToQCO.h.inc"
21+
} // namespace mlir
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (c) 2023 - 2026 Chair for Design Automation, TUM
2+
// Copyright (c) 2025 - 2026 Munich Quantum Software Company GmbH
3+
// All rights reserved.
4+
//
5+
// SPDX-License-Identifier: MIT
6+
//
7+
// Licensed under the MIT License
8+
9+
include "mlir/Pass/PassBase.td"
10+
11+
def JeffToQCO : Pass<"jeff-to-qco"> {
12+
let summary = "Convert Jeff operations to QCO operations";
13+
14+
let description = [{
15+
This pass converts all operations from the Jeff dialect to their equivalent operations in the QCO dialect.
16+
It ensures that the returned module is a valid QCO module.
17+
18+
Note that this pass is still in development as QCO and Jeff do not have full feature parity yet.
19+
20+
Known limitations:
21+
22+
- Gates with a non-trivial power are currently not supported
23+
- Only specific `CustomOp`s are currently supported
24+
- Only specific `PPROp`s are currently supported
25+
- `Qureg_Op`s are currently not supported
26+
- `SCF_Op`s are currently not supported
27+
- Support for multiple functions is currently limited
28+
}];
29+
30+
let dependentDialects = [
31+
"mlir::arith::ArithDialect",
32+
"mlir::jeff::JeffDialect",
33+
"mlir::qco::QCODialect",
34+
];
35+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) 2023 - 2026 Chair for Design Automation, TUM
2+
# Copyright (c) 2025 - 2026 Munich Quantum Software Company GmbH
3+
# All rights reserved.
4+
#
5+
# SPDX-License-Identifier: MIT
6+
#
7+
# Licensed under the MIT License
8+
9+
set(LLVM_TARGET_DEFINITIONS QCOToJeff.td)
10+
mlir_tablegen(QCOToJeff.h.inc -gen-pass-decls -name QCOToJeff)
11+
add_public_tablegen_target(QCOToJeffIncGen)
12+
13+
add_mlir_doc(QCOToJeff MLIRQCOToJeff Conversions/ -gen-pass-doc)

0 commit comments

Comments
 (0)