Skip to content

Commit 3dd3d2b

Browse files
authored
🔥 Remove legacy MLIR code (#1435)
## Description This PR removed the legacy MLIR code around the MQTRef and MQTOpt dialects from the `main` branch of MQT Core in anticipation of the `v4` release. The respective functionality still remains around in the stable `v3.x` branch. Ongoing contributions targeting the old dialects should target the `v3.x` branch. Any new contribution shall target the new dialects from here on out. We will gradually port over the important bits and pieces from the old dialect infrastructure. This PR also updates the RtD documentation to show the new dialects, which is something that we apparently missed or ignored when merging the dialect redesign PR. Since we are using a modern version of MLIR now for generating the docs, some of the workarounds have been removed as well. ## Checklist: <!--- This checklist serves as a reminder of a couple of things that ensure your pull request will be merged swiftly. --> - [x] 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.
2 parents 5f66420 + b322bf6 commit 3dd3d2b

File tree

127 files changed

+36
-24576
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+36
-24576
lines changed

cmake/SetupMLIR.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ include_directories(${MQT_MLIR_BUILD_INCLUDE_DIR})
4040
link_directories(${LLVM_BUILD_LIBRARY_DIR})
4141
add_definitions(${LLVM_DEFINITIONS})
4242

43-
string(REPLACE "." ";" MLIR_VERSION_COMPONENTS ${MLIR_VERSION})
44-
list(GET MLIR_VERSION_COMPONENTS 0 MLIR_VERSION_MAJOR)
45-
add_compile_definitions(MLIR_VERSION_MAJOR=${MLIR_VERSION_MAJOR})
46-
4743
# set the binary directory for the build tree such that, e.g., docs can be generated in the build
4844
# tree
4945
set(MLIR_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})

docs/mlir/Conversions.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,16 @@
22

33
## Internal Conversions
44

5-
```{include} Conversions/MLIRMQTOptToMQTRef.md
5+
```{include} Conversions/MLIRQCToQCO.md
66
77
```
88

9-
```{include} Conversions/MLIRMQTRefToMQTOpt.md
9+
```{include} Conversions/MLIRQCOToQC.md
1010
1111
```
1212

1313
## QIR Conversions
1414

15-
```{include} Conversions/MLIRMQTRefToQIR.md
16-
17-
```
18-
19-
```{include} Conversions/MLIRQIRToMQTRef.md
15+
```{include} Conversions/MLIRQCToQIR.md
2016
2117
```

docs/mlir/MQTOpt.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

docs/mlir/MQTRef.md

Lines changed: 0 additions & 23 deletions
This file was deleted.

docs/mlir/QC.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
tocdepth: 3
3+
---
4+
5+
```{include} Dialects/MLIRQCDialect.md
6+
7+
```
8+
9+
```{include} Dialects/MLIRQCInterfaces.md
10+
:heading-offset: 1
11+
```

docs/mlir/QCO.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
tocdepth: 3
3+
---
4+
5+
```{include} Dialects/MLIRQCODialect.md
6+
7+
```
8+
9+
```{include} Dialects/MLIRQCOInterfaces.md
10+
:heading-offset: 1
11+
```

docs/mlir/index.md

Lines changed: 6 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ This part of the MQT explores the capabilities of the Multi-Level Intermediate R
44

55
We define multiple dialects, each with its dedicated purpose:
66

7-
- The {doc}`MQTRef dialect <MQTRef>` uses reference semantics and is designed as a compatibility dialect that simplifies translations from and to existing languages such as Qiskit, OpenQASM, or QIR.
7+
- The {doc}`QC dialect <QC>` uses reference semantics and is designed as a compatibility dialect that simplifies translations from and to existing languages such as Qiskit, OpenQASM, or QIR.
88

9-
- The {doc}`MQTOpt dialect <MQTOpt>` uses value semantics and is mainly designed for running optimizations.
9+
- The {doc}`QCO dialect <QCO>` uses value semantics and is mainly designed for running optimizations.
1010

11-
Both dialects define various transformation passes.
11+
Both dialects define various canonicalization and transformations that enable the compilation of quantum programs to native quantum hardware.
1212

1313
For intercompatibility, we provide {doc}`conversions <Conversions>` between dialects.
14-
So far, this comprises a conversion from MQTOpt to MQTRef and one from MQTRef to MQTOpt.
14+
So far, this comprises conversions between QC and QCO as well as from QC to QIR.
1515

1616
```{toctree}
1717
:maxdepth: 2
1818
19-
MQTRef
20-
MQTOpt
19+
QC
20+
QCO
2121
Conversions
2222
```
2323

@@ -27,100 +27,3 @@ The content is not yet complete and subject to change.
2727
Contributions are welcome.
2828
See the {doc}`contribution guide <../contributing>` for more information.
2929
:::
30-
31-
## Register Handling
32-
33-
In MQT's MLIR dialects, quantum and classical registers are represented by MLIR-native `memref` operations rather than custom types.
34-
This design choice offers several advantages:
35-
36-
- **MLIR Integration**: Seamless compatibility with existing MLIR infrastructure, enabling reuse of memory handling patterns and optimization passes
37-
- **Implementation Efficiency**: No need to define and maintain custom register operations, significantly reducing implementation complexity
38-
- **Enhanced Interoperability**: Easier integration with other MLIR dialects and passes, allowing for more flexible compilation pipelines
39-
- **Sustainable Evolution**: Standard memory operations can handle transformations while allowing new features without changing the fundamental register model
40-
41-
### Quantum Register Representation
42-
43-
A quantum register is represented by a `memref` of type `!mqtref.Qubit` or `!mqtopt.Qubit`, depending on the dialect:
44-
45-
```mlir
46-
// A quantum register with 2 qubits
47-
%qreg = memref.alloc() : memref<2x!mqtref.Qubit>
48-
```
49-
50-
Individual qubits are accessed through standard memory operations:
51-
52-
```mlir
53-
// Load qubits from the register
54-
%q0 = memref.load %qreg[%i0] : memref<2x!mqtref.Qubit>
55-
%q1 = memref.load %qreg[%i1] : memref<2x!mqtref.Qubit>
56-
```
57-
58-
Here's a complete example of quantum register allocation, qubit access, and deallocation:
59-
60-
```mlir
61-
module {
62-
func.func @main() attributes {passthrough = ["entry_point"]} {
63-
%i1 = arith.constant 1 : index
64-
%i0 = arith.constant 0 : index
65-
%qreg = memref.alloc() : memref<2x!mqtref.Qubit>
66-
%q0 = memref.load %qreg[%i0] : memref<2x!mqtref.Qubit>
67-
%q1 = memref.load %qreg[%i1] : memref<2x!mqtref.Qubit>
68-
memref.dealloc %qreg : memref<2x!mqtref.Qubit>
69-
return
70-
}
71-
}
72-
```
73-
74-
### Classical Register Representation
75-
76-
Classical registers follow the same pattern as quantum registers but use the `i1` type for boolean measurement results:
77-
78-
```mlir
79-
// A classical register with 1 bit
80-
%creg = memref.alloc() : memref<1xi1>
81-
```
82-
83-
Measurement operations produce `i1` values that can be stored in classical registers:
84-
85-
```mlir
86-
// Measure a qubit and store the result
87-
%c = mqtref.measure %q
88-
memref.store %c, %creg[%i0] : memref<1xi1>
89-
```
90-
91-
### Example: Full Quantum Program with Measurement
92-
93-
Consider the following quantum computation represented in OpenQASM 3.0 code:
94-
95-
```qasm3
96-
OPENQASM 3.0;
97-
include "stdgates.inc";
98-
qubit[1] q;
99-
bit[1] c;
100-
x q[0];
101-
c[0] = measure q[0];
102-
```
103-
104-
In the MQTRef dialect, this corresponds to:
105-
106-
```mlir
107-
module {
108-
func.func @main() attributes {passthrough = ["entry_point"]} {
109-
%i0 = arith.constant 0 : index
110-
%qreg = memref.alloc() : memref<1x!mqtref.Qubit>
111-
%q = memref.load %qreg[%i0] : memref<1x!mqtref.Qubit>
112-
%creg = memref.alloca() : memref<1xi1>
113-
mqtref.x() %q
114-
%c = mqtref.measure %q
115-
memref.store %c, %creg[%i0] : memref<1xi1>
116-
memref.dealloc %qreg : memref<1x!mqtref.Qubit>
117-
return
118-
}
119-
}
120-
```
121-
122-
## Development
123-
124-
Building the MLIR library requires LLVM version 21.1 or later.
125-
Our CI pipeline on GitHub continuously builds and tests the MLIR library on Linux, macOS, and Windows.
126-
To access the latest build logs, visit the [GitHub Actions page](https://github.com/munich-quantum-toolkit/core/actions/workflows/ci.yml).

mlir/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@ add_subdirectory(tools)
2626

2727
# add test code
2828
if(BUILD_MQT_CORE_TESTS)
29-
add_subdirectory(test)
3029
add_subdirectory(unittests)
3130
endif()

mlir/include/mlir/Conversion/CMakeLists.txt

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

9-
add_subdirectory(MQTRefToMQTOpt)
10-
add_subdirectory(MQTOptToMQTRef)
11-
add_subdirectory(MQTRefToQIR)
12-
add_subdirectory(QIRToMQTRef)
139
add_subdirectory(QCOToQC)
1410
add_subdirectory(QCToQCO)
1511
add_subdirectory(QCToQIR)

mlir/include/mlir/Conversion/MQTOptToMQTRef/CMakeLists.txt

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)