From 5d4ffacdba1052aa31acf77cdc9d5ed546ce695f Mon Sep 17 00:00:00 2001 From: sengthai Date: Thu, 27 Nov 2025 13:49:32 -0500 Subject: [PATCH 1/6] Rewrite interface --- mlir/include/QEC/IR/QECDialect.td | 18 ++------ mlir/include/QEC/IR/QECOpInterfaces.td | 63 ++++++++++++++++++++------ 2 files changed, 54 insertions(+), 27 deletions(-) diff --git a/mlir/include/QEC/IR/QECDialect.td b/mlir/include/QEC/IR/QECDialect.td index ec4f65f6a0..eae60ad042 100644 --- a/mlir/include/QEC/IR/QECDialect.td +++ b/mlir/include/QEC/IR/QECDialect.td @@ -203,7 +203,7 @@ def FabricateOp : QEC_Op<"fabricate"> { let hasVerifier = 1; } -def PPRotationOp : QEC_Op<"ppr", [QECOpInterface, AttrSizedOperandSegments]> { +def PPRotationOp : QEC_Op<"ppr", [PPRNonArbitraryOpInterface, AttrSizedOperandSegments]> { let summary = "Pauli Product Rotation on qubits."; let description = [{ @@ -351,7 +351,7 @@ def PPRotationOp : QEC_Op<"ppr", [QECOpInterface, AttrSizedOperandSegments]> { let extraClassDeclaration = extraBaseClassDeclaration; } -def PPRotationArbitraryOp : QEC_Op<"ppr.arbitrary", [AttrSizedOperandSegments]> { +def PPRotationArbitraryOp : QEC_Op<"ppr.arbitrary", [PPRArbitraryOpInterface,AttrSizedOperandSegments]> { let summary = "Pauli Product Rotation with arbitrary angle."; let description = [{ The PPRotationArbitraryOp represents a Pauli product rotation operation with an arbitrary angle. @@ -392,7 +392,7 @@ def PPRotationArbitraryOp : QEC_Op<"ppr.arbitrary", [AttrSizedOperandSegments]> let hasCanonicalizeMethod = 1; } -def PPMeasurementOp : QEC_Op<"ppm", [QECOpInterface, AttrSizedOperandSegments]> { +def PPMeasurementOp : QEC_Op<"ppm", [PauliProductMeasurementInterface, AttrSizedOperandSegments]> { let summary = "Pauli Product Measurement on qubits."; let description = [{ @@ -523,19 +523,9 @@ def PPMeasurementOp : QEC_Op<"ppm", [QECOpInterface, AttrSizedOperandSegments]> }]; let hasVerifier = 1; - - code extraBaseClassDeclaration = [{ - uint16_t getRotationKind(){ - return getRotationSign(); - }; - void setRotationKind(uint16_t attrValue){ - setRotationSign(static_cast(attrValue) < 0 ? -1 : 1); - }; - }]; - let extraClassDeclaration = extraBaseClassDeclaration; } -def SelectPPMeasurementOp : QEC_Op<"select.ppm"> { +def SelectPPMeasurementOp : QEC_Op<"select.ppm", [PauliProductMeasurementInterface]> { let summary = "Multiplexed Pauli product measurement."; let description = [{ diff --git a/mlir/include/QEC/IR/QECOpInterfaces.td b/mlir/include/QEC/IR/QECOpInterfaces.td index eed6dbb0cc..949b8a9457 100644 --- a/mlir/include/QEC/IR/QECOpInterfaces.td +++ b/mlir/include/QEC/IR/QECOpInterfaces.td @@ -17,12 +17,16 @@ include "mlir/IR/OpBase.td" +//===----------------------------------------------------------------------===// +// QEC Operation Interface +//===----------------------------------------------------------------------===// + def QECOpInterface : OpInterface<"QECOpInterface"> { let description = [{ This interface provides a generic way to interact with instructions that are - considered QEC Operations. These are characterized by operating on zero - or more qubit values, and returning the same amount of qubit values. + considered QEC Operations. These are characterized by operating on one or more qubit values, + and returning the same amount of qubit values. }]; let cppNamespace = "::catalyst::qec"; @@ -36,36 +40,69 @@ def QECOpInterface : OpInterface<"QECOpInterface"> { InterfaceMethod< /*desc=*/"Get the output qubits for this operation.", /*retTy=*/"mlir::Operation::result_range", - /*methodName=*/"getOutQubits" + /*meth + odName=*/"getOutQubits" >, InterfaceMethod< /*desc=*/"Get the Pauli product for this operation.", - /*retTy=*/" ::mlir::ArrayAttr", + /*retTy=*/"::mlir::ArrayAttr", /*methodName=*/"getPauliProduct" >, InterfaceMethod< - /*desc=*/"Get the Pauli product for this operation.", - /*retTy=*/" ::mlir::ArrayAttr", - /*methodName=*/"getPauliProductAttr" - >, + /*desc=*/"Set the Pauli product for this operation.", + /*retTy=*/"void", + /*methodName=*/"setPauliProductAttr", (ins "const ::mlir::ArrayAttr&":$propValue) + > + ]; + +} + +//===----------------------------------------------------------------------===// +// Pauli Product Rotation Interface +//===----------------------------------------------------------------------===// + +def PPRNonArbitraryOpInterface : OpInterface<"PPRNonArbitraryOpInterface", [QECOpInterface]> { + let description = [{ + This interface provides a generic way to interact with non-arbitrary rotation operations. + }]; + + let methods = [ InterfaceMethod< /*desc=*/"Get the rotation kind for this operation.", /*retTy=*/"uint16_t", /*methodName=*/"getRotationKind" >, InterfaceMethod< - /*desc=*/"Set the Pauli product for this operation.", + /*desc=*/"Set the rotation kind for this operation.", /*retTy=*/"void", - /*methodName=*/"setPauliProductAttr", (ins " ::mlir::ArrayAttr":$attr) + /*methodName=*/"setRotationKind", (ins "uint16_t":$rotationKind) + > + ]; +} + +def PPRArbitraryOpInterface: OpInterface<"PPRArbitraryOpInterface", [QECOpInterface]>{ + let description = [{ + This interface provides a generic way to interact with arbitrary rotation operations. + }]; + + let methods = [ + InterfaceMethod< + /*desc=*/"Get the arbitrary angle for this operation.", + /*retTy=*/"::mlir::Value", + /*methodName=*/"getArbitraryAngle" >, InterfaceMethod< - /*desc=*/"Set the rotation kind for this operation.", + /*desc=*/"Set the arbitrary angle for this operation.", /*retTy=*/"void", - /*methodName=*/"setRotationKind", (ins "uint16_t":$attrValue) + /*methodName=*/"setArbitraryAngle", (ins "::mlir::Value":$attrValue) > ]; +} +//===----------------------------------------------------------------------===// +// Pauli Product Measurement Interface +//===----------------------------------------------------------------------===// -} +def PauliProductMeasurementInterface: OpInterface<"PauliProductMeasurementInterface", [QECOpInterface]>; #endif // QECOP_INTERFACES From 97d03d8eeb3e30f9c68ff22d44153627f17646f8 Mon Sep 17 00:00:00 2001 From: sengthai Date: Sun, 30 Nov 2025 23:49:58 -0500 Subject: [PATCH 2/6] Update QEC operation interfaces and update related transformations. --- mlir/include/QEC/IR/QECDialect.td | 8 ++-- mlir/include/QEC/IR/QECOpInterfaces.td | 48 ------------------- mlir/lib/QEC/Transforms/CountPPMSpecs.cpp | 10 ++-- .../Transforms/DecomposeNonCliffordPPR.cpp | 2 +- mlir/lib/QEC/Transforms/PPRToMBQC.cpp | 10 ++-- mlir/lib/QEC/Transforms/TLayerReduction.cpp | 10 +++- mlir/lib/QEC/Utils/PauliStringWrapper.cpp | 32 ++++++++++--- 7 files changed, 53 insertions(+), 67 deletions(-) diff --git a/mlir/include/QEC/IR/QECDialect.td b/mlir/include/QEC/IR/QECDialect.td index eae60ad042..76f351a1b8 100644 --- a/mlir/include/QEC/IR/QECDialect.td +++ b/mlir/include/QEC/IR/QECDialect.td @@ -203,7 +203,7 @@ def FabricateOp : QEC_Op<"fabricate"> { let hasVerifier = 1; } -def PPRotationOp : QEC_Op<"ppr", [PPRNonArbitraryOpInterface, AttrSizedOperandSegments]> { +def PPRotationOp : QEC_Op<"ppr", [QECOpInterface, AttrSizedOperandSegments]> { let summary = "Pauli Product Rotation on qubits."; let description = [{ @@ -351,7 +351,7 @@ def PPRotationOp : QEC_Op<"ppr", [PPRNonArbitraryOpInterface, AttrSizedOperandSe let extraClassDeclaration = extraBaseClassDeclaration; } -def PPRotationArbitraryOp : QEC_Op<"ppr.arbitrary", [PPRArbitraryOpInterface,AttrSizedOperandSegments]> { +def PPRotationArbitraryOp : QEC_Op<"ppr.arbitrary", [QECOpInterface, AttrSizedOperandSegments]> { let summary = "Pauli Product Rotation with arbitrary angle."; let description = [{ The PPRotationArbitraryOp represents a Pauli product rotation operation with an arbitrary angle. @@ -392,7 +392,7 @@ def PPRotationArbitraryOp : QEC_Op<"ppr.arbitrary", [PPRArbitraryOpInterface,Att let hasCanonicalizeMethod = 1; } -def PPMeasurementOp : QEC_Op<"ppm", [PauliProductMeasurementInterface, AttrSizedOperandSegments]> { +def PPMeasurementOp : QEC_Op<"ppm", [QECOpInterface, AttrSizedOperandSegments]> { let summary = "Pauli Product Measurement on qubits."; let description = [{ @@ -525,7 +525,7 @@ def PPMeasurementOp : QEC_Op<"ppm", [PauliProductMeasurementInterface, AttrSized let hasVerifier = 1; } -def SelectPPMeasurementOp : QEC_Op<"select.ppm", [PauliProductMeasurementInterface]> { +def SelectPPMeasurementOp : QEC_Op<"select.ppm"> { let summary = "Multiplexed Pauli product measurement."; let description = [{ diff --git a/mlir/include/QEC/IR/QECOpInterfaces.td b/mlir/include/QEC/IR/QECOpInterfaces.td index 949b8a9457..a2dc9e95eb 100644 --- a/mlir/include/QEC/IR/QECOpInterfaces.td +++ b/mlir/include/QEC/IR/QECOpInterfaces.td @@ -57,52 +57,4 @@ def QECOpInterface : OpInterface<"QECOpInterface"> { } -//===----------------------------------------------------------------------===// -// Pauli Product Rotation Interface -//===----------------------------------------------------------------------===// - -def PPRNonArbitraryOpInterface : OpInterface<"PPRNonArbitraryOpInterface", [QECOpInterface]> { - let description = [{ - This interface provides a generic way to interact with non-arbitrary rotation operations. - }]; - - let methods = [ - InterfaceMethod< - /*desc=*/"Get the rotation kind for this operation.", - /*retTy=*/"uint16_t", - /*methodName=*/"getRotationKind" - >, - InterfaceMethod< - /*desc=*/"Set the rotation kind for this operation.", - /*retTy=*/"void", - /*methodName=*/"setRotationKind", (ins "uint16_t":$rotationKind) - > - ]; -} - -def PPRArbitraryOpInterface: OpInterface<"PPRArbitraryOpInterface", [QECOpInterface]>{ - let description = [{ - This interface provides a generic way to interact with arbitrary rotation operations. - }]; - - let methods = [ - InterfaceMethod< - /*desc=*/"Get the arbitrary angle for this operation.", - /*retTy=*/"::mlir::Value", - /*methodName=*/"getArbitraryAngle" - >, - InterfaceMethod< - /*desc=*/"Set the arbitrary angle for this operation.", - /*retTy=*/"void", - /*methodName=*/"setArbitraryAngle", (ins "::mlir::Value":$attrValue) - > - ]; -} - -//===----------------------------------------------------------------------===// -// Pauli Product Measurement Interface -//===----------------------------------------------------------------------===// - -def PauliProductMeasurementInterface: OpInterface<"PauliProductMeasurementInterface", [QECOpInterface]>; - #endif // QECOP_INTERFACES diff --git a/mlir/lib/QEC/Transforms/CountPPMSpecs.cpp b/mlir/lib/QEC/Transforms/CountPPMSpecs.cpp index 57bb822c42..265eaa3908 100644 --- a/mlir/lib/QEC/Transforms/CountPPMSpecs.cpp +++ b/mlir/lib/QEC/Transforms/CountPPMSpecs.cpp @@ -129,8 +129,8 @@ struct CountPPMSpecsPass : public impl::CountPPMSpecsPassBase return true; } - bool isPPR(QECOpInterface op) { return isa(op); } - bool isPPM(QECOpInterface op) { return isa(op); } + bool isPPR(QECOpInterface op) { return isa(op.getOperation()); } + bool isPPM(QECOpInterface op) { return isa(op.getOperation()); } // Check if two ops have the same rotation kind. bool equalTypes(QECOpInterface lhsOp, QECOpInterface rhsOp) @@ -156,7 +156,11 @@ struct CountPPMSpecsPass : public impl::CountPPMSpecsPassBase assert(!layer.empty() && "Layer is empty"); auto op = layer.getOps().back(); - int16_t absRk = std::abs(static_cast(op.getRotationKind())); + + int16_t absRk = 0; + if (auto pprOp = dyn_cast(op.getOperation())) { + absRk = std::abs(static_cast(pprOp.getRotationKind())); + } auto parentFuncOp = op->getParentOfType(); StringRef funcName = parentFuncOp.getName(); llvm::StringSaver saver(stringAllocator); diff --git a/mlir/lib/QEC/Transforms/DecomposeNonCliffordPPR.cpp b/mlir/lib/QEC/Transforms/DecomposeNonCliffordPPR.cpp index 398f81d86b..59633a0784 100644 --- a/mlir/lib/QEC/Transforms/DecomposeNonCliffordPPR.cpp +++ b/mlir/lib/QEC/Transforms/DecomposeNonCliffordPPR.cpp @@ -34,7 +34,7 @@ using namespace catalyst::quantum; namespace { // Return the magic state or complex conjugate of the magic state -LogicalInitKind getMagicState(QECOpInterface op) +LogicalInitKind getMagicState(PPRotationOp op) { int16_t rotationKind = static_cast(op.getRotationKind()); if (rotationKind > 0) { diff --git a/mlir/lib/QEC/Transforms/PPRToMBQC.cpp b/mlir/lib/QEC/Transforms/PPRToMBQC.cpp index 00354c61b7..3b1e08e490 100644 --- a/mlir/lib/QEC/Transforms/PPRToMBQC.cpp +++ b/mlir/lib/QEC/Transforms/PPRToMBQC.cpp @@ -137,16 +137,20 @@ void constructReverseCNOTLadder(SmallVector &qubits, ConversionPatternRew void constructKernelOperation(SmallVector &qubits, Value &measResult, QECOpInterface op, ConversionPatternRewriter &rewriter) { - if (isa(op)) { + + if (isa(op.getOperation())) { auto measOp = buildMeasurementOp(qubits[0], rewriter); measResult = measOp.getMres(); qubits[0] = measOp.getOutQubit(); } - else { - int16_t signedRk = static_cast(op.getRotationKind()); + else if (auto pprOp = dyn_cast(op.getOperation())) { + int16_t signedRk = static_cast(pprOp.getRotationKind()); double rk = llvm::numbers::pi / (static_cast(signedRk) / 2); qubits[0] = buildSingleQubitGate(qubits[0], "RZ", {rk}, rewriter).getOutQubits().front(); } + else if (isa(op.getOperation())) { + op->emitError("Unsupported qec.ppr.arbitrary operation."); + } } //===----------------------------------------------------------------------===// diff --git a/mlir/lib/QEC/Transforms/TLayerReduction.cpp b/mlir/lib/QEC/Transforms/TLayerReduction.cpp index 29c8b30ca2..a2144dda70 100644 --- a/mlir/lib/QEC/Transforms/TLayerReduction.cpp +++ b/mlir/lib/QEC/Transforms/TLayerReduction.cpp @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "QEC/IR/QECDialect.h" #define DEBUG_TYPE "reduce-t-depth" #include @@ -63,6 +64,8 @@ std::pair checkCommutationAndFindMerge(QECOpInterface rhsO auto normalizedOps = normalizePPROps(lhsOp, rhsOp, lhsOp.getInQubits(), rhsOpInQubitsFromLhsOp); + // TODO: Handle PPRotationArbitraryOp properly + if (!normalizedOps.first.commutes(normalizedOps.second)) { return std::pair(false, nullptr); } @@ -132,8 +135,11 @@ void moveOpToLayer(QECOpInterface rhsOp, QECLayer &rhsLayer, QECOpInterface merg // then just remove the `rhsOp` from the rhsLayer. void mergePPR(QECOpInterface rhsOp, QECLayer &rhsLayer, QECOpInterface mergeOp, IRRewriter &writer) { - int16_t signedRk = static_cast(mergeOp.getRotationKind()); - mergeOp.setRotationKind(static_cast(signedRk / 2)); + auto mergeOpPprOp = dyn_cast(mergeOp.getOperation()); + assert(mergeOpPprOp != nullptr && "Op is not a PPRotationOp"); + + int16_t signedRk = static_cast(mergeOpPprOp.getRotationKind()); + mergeOpPprOp.setRotationKind(static_cast(signedRk / 2)); rhsLayer.eraseOp(rhsOp); writer.replaceOp(rhsOp, rhsOp->getOperands()); diff --git a/mlir/lib/QEC/Utils/PauliStringWrapper.cpp b/mlir/lib/QEC/Utils/PauliStringWrapper.cpp index 7fe40c25cb..02482a3793 100644 --- a/mlir/lib/QEC/Utils/PauliStringWrapper.cpp +++ b/mlir/lib/QEC/Utils/PauliStringWrapper.cpp @@ -150,8 +150,21 @@ PauliWordPair normalizePPROps(QECOpInterface lhs, QECOpInterface rhs, ValueRange lhsPSWrapper.op = lhs; rhsPSWrapper.op = rhs; - lhsPSWrapper.updateSign((int16_t)lhs.getRotationKind() < 0); - rhsPSWrapper.updateSign((int16_t)rhs.getRotationKind() < 0); + auto applySignFromOp = [](PauliStringWrapper &wrapper, QECOpInterface qecOp) { + Operation *operation = qecOp.getOperation(); + + if (auto pprOp = dyn_cast(operation)) { + wrapper.updateSign(static_cast(pprOp.getRotationKind()) < 0); + return; + } + + if (auto ppmOp = dyn_cast(operation)) { + wrapper.updateSign(static_cast(ppmOp.getRotationSign()) < 0); + } + }; + + applySignFromOp(lhsPSWrapper, lhs); + applySignFromOp(rhsPSWrapper, rhs); return std::make_pair(std::move(lhsPSWrapper), std::move(rhsPSWrapper)); } @@ -210,10 +223,17 @@ void updatePauliWord(QECOpInterface op, const PauliWord &newPauliWord, PatternRe void updatePauliWordSign(QECOpInterface op, bool isNegated, PatternRewriter &rewriter) { - int16_t rotationKind = static_cast(op.getRotationKind()); - int16_t sign = isNegated ? -1 : 1; - rotationKind = (rotationKind < 0 ? -rotationKind : rotationKind) * sign; - op.setRotationKind(rotationKind); + if (auto pprOp = dyn_cast(op.getOperation())) { + int16_t rotationKind = static_cast(pprOp.getRotationKind()); + int16_t sign = isNegated ? -1 : 1; + rotationKind = (rotationKind < 0 ? -rotationKind : rotationKind) * sign; + pprOp.setRotationKind(rotationKind); + } + else if (auto ppmOp = dyn_cast(op.getOperation())) { + int16_t rotationSign = static_cast(ppmOp.getRotationSign()); + rotationSign = (rotationSign < 0 ? -rotationSign : rotationSign) * (isNegated ? -1 : 1); + ppmOp.setRotationSign(rotationSign); + } } SmallVector extractPauliString(QECOpInterface op) From 6d651bdf8503f52f0f943dc88767544ebb7a2003 Mon Sep 17 00:00:00 2001 From: sengthai Date: Mon, 1 Dec 2025 11:09:17 -0500 Subject: [PATCH 3/6] update changelog --- doc/releases/changelog-dev.md | 4 ++++ mlir/include/QEC/IR/QECOpInterfaces.td | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index e2228f0bbe..8e124177f9 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -286,6 +286,10 @@ that sum to identity. [(#2224)](https://github.com/PennyLaneAI/catalyst/pull/2224) + * Removed the `getRotationKind` and `setRotationKind` methods from + the QEC interface `QECOpInterface` to simplify the interface. + [(#2250)](https://github.com/PennyLaneAI/catalyst/pull/2250) +

Documentation 📝

* A typo in the code example for :func:`~.passes.ppr_to_ppm` has been corrected. diff --git a/mlir/include/QEC/IR/QECOpInterfaces.td b/mlir/include/QEC/IR/QECOpInterfaces.td index a2dc9e95eb..dc2fbd3e4a 100644 --- a/mlir/include/QEC/IR/QECOpInterfaces.td +++ b/mlir/include/QEC/IR/QECOpInterfaces.td @@ -40,8 +40,7 @@ def QECOpInterface : OpInterface<"QECOpInterface"> { InterfaceMethod< /*desc=*/"Get the output qubits for this operation.", /*retTy=*/"mlir::Operation::result_range", - /*meth - odName=*/"getOutQubits" + /*methodName=*/"getOutQubits" >, InterfaceMethod< /*desc=*/"Get the Pauli product for this operation.", From a56c1124fe4a91d7ceac306fa896872c14097ad1 Mon Sep 17 00:00:00 2001 From: sengthai Date: Mon, 1 Dec 2025 11:11:26 -0500 Subject: [PATCH 4/6] satisfy codefactor --- mlir/lib/QEC/Transforms/PPRToMBQC.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/mlir/lib/QEC/Transforms/PPRToMBQC.cpp b/mlir/lib/QEC/Transforms/PPRToMBQC.cpp index 3b1e08e490..50b8a23017 100644 --- a/mlir/lib/QEC/Transforms/PPRToMBQC.cpp +++ b/mlir/lib/QEC/Transforms/PPRToMBQC.cpp @@ -137,7 +137,6 @@ void constructReverseCNOTLadder(SmallVector &qubits, ConversionPatternRew void constructKernelOperation(SmallVector &qubits, Value &measResult, QECOpInterface op, ConversionPatternRewriter &rewriter) { - if (isa(op.getOperation())) { auto measOp = buildMeasurementOp(qubits[0], rewriter); measResult = measOp.getMres(); From b01acda693b0f35063d9acabc524ba52cf9e79c2 Mon Sep 17 00:00:00 2001 From: sengthai Date: Tue, 2 Dec 2025 14:30:00 -0500 Subject: [PATCH 5/6] Clean code --- mlir/lib/QEC/Transforms/CountPPMSpecs.cpp | 4 ++-- mlir/lib/QEC/Transforms/PPRToMBQC.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mlir/lib/QEC/Transforms/CountPPMSpecs.cpp b/mlir/lib/QEC/Transforms/CountPPMSpecs.cpp index 265eaa3908..0de7b5b5e8 100644 --- a/mlir/lib/QEC/Transforms/CountPPMSpecs.cpp +++ b/mlir/lib/QEC/Transforms/CountPPMSpecs.cpp @@ -129,8 +129,8 @@ struct CountPPMSpecsPass : public impl::CountPPMSpecsPassBase return true; } - bool isPPR(QECOpInterface op) { return isa(op.getOperation()); } - bool isPPM(QECOpInterface op) { return isa(op.getOperation()); } + bool isPPR(QECOpInterface op) { return isa(op); } + bool isPPM(QECOpInterface op) { return isa(op); } // Check if two ops have the same rotation kind. bool equalTypes(QECOpInterface lhsOp, QECOpInterface rhsOp) diff --git a/mlir/lib/QEC/Transforms/PPRToMBQC.cpp b/mlir/lib/QEC/Transforms/PPRToMBQC.cpp index 50b8a23017..faaf209733 100644 --- a/mlir/lib/QEC/Transforms/PPRToMBQC.cpp +++ b/mlir/lib/QEC/Transforms/PPRToMBQC.cpp @@ -137,7 +137,7 @@ void constructReverseCNOTLadder(SmallVector &qubits, ConversionPatternRew void constructKernelOperation(SmallVector &qubits, Value &measResult, QECOpInterface op, ConversionPatternRewriter &rewriter) { - if (isa(op.getOperation())) { + if (isa(op)) { auto measOp = buildMeasurementOp(qubits[0], rewriter); measResult = measOp.getMres(); qubits[0] = measOp.getOutQubit(); @@ -147,7 +147,7 @@ void constructKernelOperation(SmallVector &qubits, Value &measResult, QEC double rk = llvm::numbers::pi / (static_cast(signedRk) / 2); qubits[0] = buildSingleQubitGate(qubits[0], "RZ", {rk}, rewriter).getOutQubits().front(); } - else if (isa(op.getOperation())) { + else if (isa(op)) { op->emitError("Unsupported qec.ppr.arbitrary operation."); } } From 3c5cef7ccf146a89b37e11f70853525f0cefbaf8 Mon Sep 17 00:00:00 2001 From: Sengthai Heng Date: Wed, 3 Dec 2025 11:09:13 -0500 Subject: [PATCH 6/6] Add QECOps.h include to TLayerReduction.cpp --- mlir/lib/QEC/Transforms/TLayerReduction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mlir/lib/QEC/Transforms/TLayerReduction.cpp b/mlir/lib/QEC/Transforms/TLayerReduction.cpp index 7aee59e2fc..65f86b2f70 100644 --- a/mlir/lib/QEC/Transforms/TLayerReduction.cpp +++ b/mlir/lib/QEC/Transforms/TLayerReduction.cpp @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "QEC/IR/QECDialect.h" #define DEBUG_TYPE "reduce-t-depth" #include @@ -21,6 +20,7 @@ #include "mlir/IR/PatternMatch.h" #include "mlir/Pass/Pass.h" +#include "QEC/IR/QECOps.h" #include "QEC/Utils/PauliStringWrapper.h" #include "QEC/Utils/QECLayer.h" #include "QEC/Utils/QECOpUtils.h"