Skip to content

Commit acdbe27

Browse files
committed
update QPD test
1 parent db0d465 commit acdbe27

2 files changed

Lines changed: 11 additions & 19 deletions

File tree

frontend/test/lit/GraphDecomposition/TestQPD.mlir

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,17 @@
1414

1515
// Test that graph-decomposition is able to use compile-time python decompositions
1616

17-
// RUN: catalyst --tool=opt --pass-pipeline='builtin.module(graph-decomposition{gate-set=RX=1.0,Hadamard=1.0,MultiRZ=1.0,GlobalPhase=1.0})' %s | FileCheck %s
17+
// RUN: catalyst --tool=opt --pass-pipeline='builtin.module(graph-decomposition{gate-set=PhaseShift=1.0})' %s | FileCheck %s
1818

1919

20-
func.func @circuit() -> (!quantum.bit, !quantum.bit, !quantum.bit) {
21-
%0 = quantum.alloc(3) : !quantum.reg
22-
%q0 = quantum.extract %0[0] : !quantum.reg -> !quantum.bit
23-
%q1 = quantum.extract %0[1] : !quantum.reg -> !quantum.bit
24-
%q2 = quantum.extract %0[2] : !quantum.reg -> !quantum.bit
20+
func.func @circuit() -> !quantum.bit {
21+
%reg = quantum.alloc(1): !quantum.reg
22+
%0 = quantum.extract %reg[0] : !quantum.reg -> !quantum.bit
2523

26-
%pi = arith.constant 3.1 : f64
27-
%qout:3 = quantum.paulirot ["Y", "X", "Z"](%pi) %q0, %q1, %q2 : !quantum.bit, !quantum.bit, !quantum.bit
28-
29-
// CHECK-NOT: quantum.paulirot
30-
31-
// CHECK-DAG: RX
32-
// CHECK-DAG: Hadamard
33-
// CHECK: multirz
34-
// CHECK-DAG: RX
35-
// CHECK-DAG: Hadamard
36-
37-
return %qout#0, %qout#1, %qout#2 : !quantum.bit, !quantum.bit, !quantum.bit
24+
// CHECK-NOT: quantum.custom "S"
25+
// CHECK: quantum.custom "PhaseShift"
26+
%out_qubits = quantum.custom "S"() %0 : !quantum.bit
27+
return %out_qubits : !quantum.bit
3828
}
29+
30+
// TODO: add a tests for more complicated operators once they're migrated

mlir/lib/Quantum/Transforms/GraphDecomposition/graph_decomposition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ struct GraphDecompositionPass : public impl::GraphDecompositionPassBase<GraphDec
395395
}
396396

397397
moduleOp->walk([&](mlir::func::FuncOp func) {
398-
if (func.getName().starts_with(opId)) {
398+
if (func.getName().ends_with(opId)) {
399399
mlir::OwningOpRef<mlir::func::FuncOp> outOp;
400400
func->remove();
401401
outOp = mlir::OwningOpRef<mlir::func::FuncOp>(func);

0 commit comments

Comments
 (0)