Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ This project adheres to [Semantic Versioning], with the exception that minor rel

### Added

- ✨ Add conversions between Jeff and QCO ([#1479]) ([**@denialhaag**])
- ✨ Add conversions between Jeff and QCO ([#1479], [#1548]) ([**@denialhaag**])
- ✨ Add a `place-and-route` pass for mapping circuits to architectures with restricted topologies ([#1537], [#1547]) ([**@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])
([#1264], [#1330], [#1402], [#1428], [#1430], [#1436], [#1443], [#1446], [#1464], [#1465], [#1470], [#1471], [#1472], [#1474], [#1475], [#1506], [#1510], [#1513], [#1521], [#1548])
([**@burgholzer**], [**@denialhaag**], [**@taminob**], [**@DRovara**], [**@li-mingbao**], [**@Ectras**], [**@MatthiasReumann**])

### Changed
Expand Down Expand Up @@ -329,6 +329,7 @@ _📚 Refer to the [GitHub Release Notes](https://github.com/munich-quantum-tool

<!-- PR links -->

[#1548]: https://github.com/munich-quantum-toolkit/core/pull/1548
[#1547]: https://github.com/munich-quantum-toolkit/core/pull/1547
[#1537]: https://github.com/munich-quantum-toolkit/core/pull/1537
[#1521]: https://github.com/munich-quantum-toolkit/core/pull/1521
Expand Down
10 changes: 10 additions & 0 deletions docs/mlir/Conversions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@

```

## Jeff Conversions

```{include} Conversions/MLIRQCOToJeff.md

```

```{include} Conversions/MLIRJeffToQCO.md

```

## QIR Conversions

```{include} Conversions/MLIRQCToQIR.md
Expand Down
6 changes: 6 additions & 0 deletions docs/mlir/QCO.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ tocdepth: 3
```{include} Dialects/MLIRQCOInterfaces.md
:heading-offset: 1
```

## Passes

```{include} Passes/MLIRQCOTransforms.md

```
6 changes: 3 additions & 3 deletions mlir/lib/Compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ add_mlir_library(
MLIRPass
MLIRTransforms
MLIRTransformUtils
QCToQCO
QCOToQC
QCToQIR
MLIRQCToQCO
MLIRQCOToQC
MLIRQCToQIR
MQT::MLIRSupport
DISABLE_INSTALL)

Expand Down
8 changes: 4 additions & 4 deletions mlir/lib/Conversion/JeffToQCO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

file(GLOB CONVERSION_SOURCES *.cpp)

add_mlir_library(
JeffToQCO
add_mlir_conversion_library(
MLIRJeffToQCO
${CONVERSION_SOURCES}
DEPENDS
JeffToQCOIncGen
Expand All @@ -19,5 +19,5 @@ add_mlir_library(
MLIRTransforms
DISABLE_INSTALL)

target_include_directories(JeffToQCO PRIVATE ${jeff-mlir_SOURCE_DIR}/include
${jeff-mlir_BINARY_DIR}/include)
target_include_directories(MLIRJeffToQCO PRIVATE ${jeff-mlir_SOURCE_DIR}/include
${jeff-mlir_BINARY_DIR}/include)
187 changes: 84 additions & 103 deletions mlir/lib/Conversion/JeffToQCO/JeffToQCO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,59 +299,6 @@ createTwoTargetTwoParameter(JeffOpType& op, ConversionPatternRewriter& rewriter,
}
}

/**
* @brief Converts a one-target, zero-parameter Jeff operation to QCO
*
* @tparam QCOOpType The operation type of the QCO operation
* @tparam JeffOpType The operation type of the Jeff operation
* @tparam JeffOpAdaptorType The OpAdaptor type of the Jeff operation
* @param op The Jeff operation instance to convert
* @param adaptor The OpAdaptor of the Jeff operation
* @param rewriter The pattern rewriter
* @return LogicalResult Success or failure of the conversion
*/
template <typename QCOOpType, typename JeffOpType, typename JeffOpAdaptorType>
static LogicalResult
convertOneTargetZeroParameter(JeffOpType& op, JeffOpAdaptorType& adaptor,
ConversionPatternRewriter& rewriter) {
if (op.getPower() != 1) {
return rewriter.notifyMatchFailure(
op, "Operations with power != 1 are not yet supported");
}

createOneTargetZeroParameter<QCOOpType>(
op, rewriter, adaptor.getInCtrlQubits(), adaptor.getInQubit());

return success();
}

/**
* @brief Converts a one-target, one-parameter Jeff operation to QCO
*
* @tparam QCOOpType The operation type of the QCO operation
* @tparam JeffOpType The operation type of the Jeff operation
* @tparam JeffOpAdaptorType The OpAdaptor type of the Jeff operation
* @param op The Jeff operation instance to convert
* @param adaptor The OpAdaptor of the Jeff operation
* @param rewriter The pattern rewriter
* @return LogicalResult Success or failure of the conversion
*/
template <typename QCOOpType, typename JeffOpType, typename JeffOpAdaptorType>
static LogicalResult
convertOneTargetOneParameter(JeffOpType& op, JeffOpAdaptorType& adaptor,
ConversionPatternRewriter& rewriter) {
if (op.getPower() != 1) {
return rewriter.notifyMatchFailure(
op, "Operations with power != 1 are not yet supported");
}

createOneTargetOneParameter<QCOOpType>(op, rewriter, op.getRotation(),
adaptor.getInCtrlQubits(),
adaptor.getInQubit());

return success();
}

/**
* @brief Creates a qco.barrier operation from a jeff.custom operation
*
Expand Down Expand Up @@ -618,52 +565,78 @@ struct ConvertJeffGPhaseOpToQCO final : OpConversionPattern<jeff::GPhaseOp> {
}
};

// OneTargetZeroParameter

#define DEFINE_ONE_TARGET_ZERO_PARAMETER(OP_CLASS_JEFF, OP_CLASS_QCO) \
struct ConvertJeff##OP_CLASS_JEFF##ToQCO final \
: OpConversionPattern<jeff::OP_CLASS_JEFF> { \
using OpConversionPattern::OpConversionPattern; \
\
LogicalResult \
matchAndRewrite(jeff::OP_CLASS_JEFF op, OpAdaptor adaptor, \
ConversionPatternRewriter& rewriter) const override { \
return convertOneTargetZeroParameter<qco::OP_CLASS_QCO>(op, adaptor, \
rewriter); \
} \
};

DEFINE_ONE_TARGET_ZERO_PARAMETER(IOp, IdOp)
DEFINE_ONE_TARGET_ZERO_PARAMETER(XOp, XOp)
DEFINE_ONE_TARGET_ZERO_PARAMETER(YOp, YOp)
DEFINE_ONE_TARGET_ZERO_PARAMETER(ZOp, ZOp)
DEFINE_ONE_TARGET_ZERO_PARAMETER(HOp, HOp)
DEFINE_ONE_TARGET_ZERO_PARAMETER(SOp, SOp)
DEFINE_ONE_TARGET_ZERO_PARAMETER(TOp, TOp)

#undef DEFINE_ONE_TARGET_ZERO_PARAMETER

// OneTargetOneParameter

#define DEFINE_ONE_TARGET_ONE_PARAMETER(OP_CLASS_JEFF, OP_CLASS_QCO) \
struct ConvertJeff##OP_CLASS_JEFF##ToQCO final \
: OpConversionPattern<jeff::OP_CLASS_JEFF> { \
using OpConversionPattern::OpConversionPattern; \
\
LogicalResult \
matchAndRewrite(jeff::OP_CLASS_JEFF op, OpAdaptor adaptor, \
ConversionPatternRewriter& rewriter) const override { \
return convertOneTargetOneParameter<qco::OP_CLASS_QCO>(op, adaptor, \
rewriter); \
} \
};

DEFINE_ONE_TARGET_ONE_PARAMETER(RxOp, RXOp)
DEFINE_ONE_TARGET_ONE_PARAMETER(RyOp, RYOp)
DEFINE_ONE_TARGET_ONE_PARAMETER(RzOp, RZOp)
DEFINE_ONE_TARGET_ONE_PARAMETER(R1Op, POp)

#undef DEFINE_ONE_TARGET_ONE_PARAMETER
/**
* @brief Converts one-target, zero-parameter Jeff gate to QCO
*
* @tparam QCOOpType The operation type of the QCO operation
* @tparam JeffOpType The operation type of the Jeff operation
*
* @par Example:
* ```mlir
* %q_out = jeff.x {is_adjoint = false, num_ctrls = 0 : i8, power = 1 : i8}
* %q_in : !jeff.qubit
* ```
* is converted to
* ```mlir
* %q_out = qco.x %q_in : !qco.qubit
* ```
*/
template <typename JeffOpType, typename QCOOpType>
struct ConvertJeffOneTargetZeroParameterToQCO final
: OpConversionPattern<JeffOpType> {
using OpConversionPattern<JeffOpType>::OpConversionPattern;

LogicalResult
matchAndRewrite(JeffOpType op, typename JeffOpType::Adaptor adaptor,
ConversionPatternRewriter& rewriter) const override {
if (op.getPower() != 1) {
return rewriter.notifyMatchFailure(
op, "Operations with power != 1 are not yet supported");
}

createOneTargetZeroParameter<QCOOpType>(
op, rewriter, adaptor.getInCtrlQubits(), adaptor.getInQubit());

return success();
}
};

/**
* @brief Converts one-target, one-parameter Jeff gate to QCO
*
* @tparam QCOOpType The operation type of the QCO operation
* @tparam JeffOpType The operation type of the Jeff operation
*
* @par Example:
* ```mlir
* %q_out = jeff.rx(%theta) {is_adjoint = false, num_ctrls = 0 : i8, power = 1 :
* i8} %q_in : !jeff.qubit
* ```
* is converted to
* ```mlir
* %q_out = qco.rx(%theta) %q_in : !qco.qubit
* ```
*/
template <typename JeffOpType, typename QCOOpType>
struct ConvertJeffOneTargetOneParameterToQCO final
: OpConversionPattern<JeffOpType> {
using OpConversionPattern<JeffOpType>::OpConversionPattern;

LogicalResult
matchAndRewrite(JeffOpType op, typename JeffOpType::Adaptor adaptor,
ConversionPatternRewriter& rewriter) const override {
if (op.getPower() != 1) {
return rewriter.notifyMatchFailure(
op, "Operations with power != 1 are not yet supported");
}

createOneTargetOneParameter<QCOOpType>(op, rewriter, op.getRotation(),
adaptor.getInCtrlQubits(),
adaptor.getInQubit());

return success();
}
};

/**
* @brief Converts jeff.u to qco.u
Expand Down Expand Up @@ -1030,10 +1003,18 @@ struct JeffToQCO final : impl::JeffToQCOBase<JeffToQCO> {
.add<ConvertJeffQubitAllocOpToQCO, ConvertJeffQubitFreeOpToQCO,
ConvertJeffQubitFreeZeroOpToQCO, ConvertJeffQubitMeasureOpToQCO,
ConvertJeffQubitMeasureNDOpToQCO, ConvertJeffQubitResetOpToQCO,
ConvertJeffGPhaseOpToQCO, ConvertJeffIOpToQCO, ConvertJeffXOpToQCO,
ConvertJeffYOpToQCO, ConvertJeffZOpToQCO, ConvertJeffHOpToQCO,
ConvertJeffSOpToQCO, ConvertJeffTOpToQCO, ConvertJeffRxOpToQCO,
ConvertJeffRyOpToQCO, ConvertJeffRzOpToQCO, ConvertJeffR1OpToQCO,
ConvertJeffGPhaseOpToQCO,
ConvertJeffOneTargetZeroParameterToQCO<jeff::IOp, qco::IdOp>,
ConvertJeffOneTargetZeroParameterToQCO<jeff::XOp, qco::XOp>,
ConvertJeffOneTargetZeroParameterToQCO<jeff::YOp, qco::YOp>,
ConvertJeffOneTargetZeroParameterToQCO<jeff::ZOp, qco::ZOp>,
ConvertJeffOneTargetZeroParameterToQCO<jeff::HOp, qco::HOp>,
ConvertJeffOneTargetZeroParameterToQCO<jeff::SOp, qco::SOp>,
ConvertJeffOneTargetZeroParameterToQCO<jeff::TOp, qco::TOp>,
ConvertJeffOneTargetOneParameterToQCO<jeff::RxOp, qco::RXOp>,
ConvertJeffOneTargetOneParameterToQCO<jeff::RyOp, qco::RYOp>,
ConvertJeffOneTargetOneParameterToQCO<jeff::RzOp, qco::RZOp>,
ConvertJeffOneTargetOneParameterToQCO<jeff::R1Op, qco::POp>,
ConvertJeffUOpToQCO, ConvertJeffSwapOpToQCO,
ConvertJeffCustomOpToQCO, ConvertJeffPPROpToQCO,
ConvertJeffMainToQCO, ConvertJeffIntConst1OpToArith,
Expand Down
16 changes: 8 additions & 8 deletions mlir/lib/Conversion/QCOToJeff/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

file(GLOB CONVERSION_SOURCES *.cpp)

add_mlir_library(
QCOToJeff
add_mlir_conversion_library(
MLIRQCOToJeff
${CONVERSION_SOURCES}
DEPENDS
QCOToJeffIncGen
Expand All @@ -20,13 +20,13 @@ add_mlir_library(
MLIRTransforms
DISABLE_INSTALL)

target_include_directories(QCOToJeff PRIVATE ${jeff-mlir_SOURCE_DIR}/include
${jeff-mlir_BINARY_DIR}/include)
target_include_directories(MLIRQCOToJeff PRIVATE ${jeff-mlir_SOURCE_DIR}/include
${jeff-mlir_BINARY_DIR}/include)

if(TARGET QCOToJeff)
target_compile_definitions(QCOToJeff PRIVATE MQT_CORE_VERSION="${MQT_CORE_VERSION}")
if(TARGET MLIRQCOToJeff)
target_compile_definitions(MLIRQCOToJeff PRIVATE MQT_CORE_VERSION="${MQT_CORE_VERSION}")
endif()

if(TARGET obj.QCOToJeff)
target_compile_definitions(obj.QCOToJeff PRIVATE MQT_CORE_VERSION="${MQT_CORE_VERSION}")
if(TARGET obj.MLIRQCOToJeff)
target_compile_definitions(obj.MLIRQCOToJeff PRIVATE MQT_CORE_VERSION="${MQT_CORE_VERSION}")
endif()
Loading
Loading