Skip to content

Commit

Permalink
Fix pulse target qubit in MS gate lowering (#1473)
Browse files Browse the repository at this point in the history
**Context:**
When creating a `Ion::ParallelProtocolOp`, the custom builder
incorrectly took in just the 0th qubit argument of the original gate
operation. This is causing multi-bit gates (specifically the MS gate) to
not be lowered to pulse ops with the correct wires, and causing all
pulses to act on the 0th wire instead.

**Description of the Change:**
`ParallelProtocolOp`'s custom builder now take in all input qubits of
the original gate operation.

**Benefits:** 
Correct MS gate lowering in ion dialect
  • Loading branch information
paul0403 authored Jan 20, 2025
1 parent 4a1122b commit 7780226
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion mlir/lib/Ion/IR/IonOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void ParallelProtocolOp::build(OpBuilder &builder, OperationState &result, Value
bodyBlock->addArgument(v.getType(), v.getLoc());

builder.setInsertionPointToStart(bodyBlock);
bodyBuilder(builder, result.location, bodyBlock->getArgument(0));
bodyBuilder(builder, result.location, bodyBlock->getArguments());
}

//===----------------------------------------------------------------------===//
Expand Down
24 changes: 12 additions & 12 deletions mlir/test/Ion/QuantumToIon.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -240,23 +240,23 @@ func.func @example_ion_two_qubit(%arg0: f64) -> !quantum.bit {
// CHECK-SAME: polarization = dense<[7, 8]> : vector<2xi64>,
// CHECK-SAME: wavevector = dense<[-9, -10]> : vector<2xi64>>,
// CHECK-SAME: phase = 0.000000e+00 : f64}
// CHECK-NEXT: ion.pulse([[timems]] : f64) %arg1 {
// CHECK-NEXT: ion.pulse([[timems]] : f64) %arg2 {
// CHECK-SAME: beam = #ion.beam<
// CHECK-SAME: transition_index = 0 : i64,
// CHECK-SAME: rabi = 1.230000e+00 : f64,
// CHECK-SAME: detuning = 4.560000e+00 : f64,
// CHECK-SAME: polarization = dense<[7, 8]> : vector<2xi64>,
// CHECK-SAME: wavevector = dense<[9, 10]> : vector<2xi64>>,
// CHECK-SAME: phase = 0.000000e+00 : f64}
// CHECK-NEXT: ion.pulse([[timems]] : f64) %arg1 {
// CHECK-NEXT: ion.pulse([[timems]] : f64) %arg2 {
// CHECK-SAME: beam = #ion.beam<
// CHECK-SAME: transition_index = 1 : i64,
// CHECK-SAME: rabi = 1.230000e+00 : f64,
// CHECK-SAME: detuning = 8.960000e+00 : f64,
// CHECK-SAME: polarization = dense<[7, 8]> : vector<2xi64>,
// CHECK-SAME: wavevector = dense<[-9, -10]> : vector<2xi64>>,
// CHECK-SAME: phase = 0.000000e+00 : f64}
// CHECK-NEXT: ion.pulse([[timems]] : f64) %arg1 {
// CHECK-NEXT: ion.pulse([[timems]] : f64) %arg2 {
// CHECK-SAME: beam = #ion.beam<
// CHECK-SAME: transition_index = 1 : i64,
// CHECK-SAME: rabi = 1.230000e+00 : f64,
Expand Down Expand Up @@ -316,23 +316,23 @@ func.func @example_ion_three_qubit(%arg0: f64) -> (!quantum.bit, !quantum.bit, !
// CHECK-SAME: polarization = dense<[7, 8]> : vector<2xi64>,
// CHECK-SAME: wavevector = dense<[-9, -10]> : vector<2xi64>>,
// CHECK-SAME: phase = 0.000000e+00 : f64}
// CHECK-NEXT: ion.pulse([[timems1]] : f64) %arg1 {
// CHECK-NEXT: ion.pulse([[timems1]] : f64) %arg2 {
// CHECK-SAME: beam = #ion.beam<
// CHECK-SAME: transition_index = 0 : i64,
// CHECK-SAME: rabi = 1.230000e+00 : f64,
// CHECK-SAME: detuning = 4.560000e+00 : f64,
// CHECK-SAME: polarization = dense<[7, 8]> : vector<2xi64>,
// CHECK-SAME: wavevector = dense<[9, 10]> : vector<2xi64>>,
// CHECK-SAME: phase = 0.000000e+00 : f64}
// CHECK-NEXT: ion.pulse([[timems1]] : f64) %arg1 {
// CHECK-NEXT: ion.pulse([[timems1]] : f64) %arg2 {
// CHECK-SAME: beam = #ion.beam<
// CHECK-SAME: transition_index = 1 : i64,
// CHECK-SAME: rabi = 1.230000e+00 : f64,
// CHECK-SAME: detuning = 8.960000e+00 : f64,
// CHECK-SAME: polarization = dense<[7, 8]> : vector<2xi64>,
// CHECK-SAME: wavevector = dense<[-9, -10]> : vector<2xi64>>,
// CHECK-SAME: phase = 0.000000e+00 : f64}
// CHECK-NEXT: ion.pulse([[timems1]] : f64) %arg1 {
// CHECK-NEXT: ion.pulse([[timems1]] : f64) %arg2 {
// CHECK-SAME: beam = #ion.beam<
// CHECK-SAME: transition_index = 1 : i64,
// CHECK-SAME: rabi = 1.230000e+00 : f64,
Expand Down Expand Up @@ -371,23 +371,23 @@ func.func @example_ion_three_qubit(%arg0: f64) -> (!quantum.bit, !quantum.bit, !
// CHECK-SAME: polarization = dense<[1, 2]> : vector<2xi64>,
// CHECK-SAME: wavevector = dense<[3, -4]> : vector<2xi64>>,
// CHECK-SAME: phase = 0.000000e+00 : f64}
// CHECK-NEXT: ion.pulse([[timems2]] : f64) %arg1 {
// CHECK-NEXT: ion.pulse([[timems2]] : f64) %arg2 {
// CHECK-SAME: beam = #ion.beam<
// CHECK-SAME: transition_index = 0 : i64,
// CHECK-SAME: rabi = 4.560000e+00 : f64,
// CHECK-SAME: detuning = 7.8899999999999996 : f64,
// CHECK-SAME: polarization = dense<[1, 2]> : vector<2xi64>,
// CHECK-SAME: wavevector = dense<[-3, 4]> : vector<2xi64>>,
// CHECK-SAME: phase = 0.000000e+00 : f64}
// CHECK-NEXT: ion.pulse([[timems2]] : f64) %arg1 {
// CHECK-NEXT: ion.pulse([[timems2]] : f64) %arg2 {
// CHECK-SAME: beam = #ion.beam<
// CHECK-SAME: transition_index = 1 : i64,
// CHECK-SAME: rabi = 4.560000e+00 : f64,
// CHECK-SAME: detuning = 1.559000e+01 : f64,
// CHECK-SAME: polarization = dense<[1, 2]> : vector<2xi64>,
// CHECK-SAME: wavevector = dense<[3, -4]> : vector<2xi64>>,
// CHECK-SAME: phase = 0.000000e+00 : f64}
// CHECK-NEXT: ion.pulse([[timems2]] : f64) %arg1 {
// CHECK-NEXT: ion.pulse([[timems2]] : f64) %arg2 {
// CHECK-SAME: beam = #ion.beam<
// CHECK-SAME: transition_index = 1 : i64,
// CHECK-SAME: rabi = 4.560000e+00 : f64,
Expand Down Expand Up @@ -426,23 +426,23 @@ func.func @example_ion_three_qubit(%arg0: f64) -> (!quantum.bit, !quantum.bit, !
// CHECK-SAME: polarization = dense<[37, 42]> : vector<2xi64>,
// CHECK-SAME: wavevector = dense<[42, 37]> : vector<2xi64>>,
// CHECK-SAME: phase = 0.000000e+00 : f64}
// CHECK-NEXT: ion.pulse([[timems3]] : f64) %arg1 {
// CHECK-NEXT: ion.pulse([[timems3]] : f64) %arg2 {
// CHECK-SAME: beam = #ion.beam<
// CHECK-SAME: transition_index = 0 : i64,
// CHECK-SAME: rabi = 99.989999999999994 : f64,
// CHECK-SAME: detuning = 1.001000e+02 : f64,
// CHECK-SAME: polarization = dense<[37, 42]> : vector<2xi64>,
// CHECK-SAME: wavevector = dense<[-42, -37]> : vector<2xi64>>,
// CHECK-SAME: phase = 0.000000e+00 : f64}
// CHECK-NEXT: ion.pulse([[timems3]] : f64) %arg1 {
// CHECK-NEXT: ion.pulse([[timems3]] : f64) %arg2 {
// CHECK-SAME: beam = #ion.beam<
// CHECK-SAME: transition_index = 1 : i64,
// CHECK-SAME: rabi = 99.989999999999994 : f64,
// CHECK-SAME: detuning = 1.078000e+02 : f64,
// CHECK-SAME: polarization = dense<[37, 42]> : vector<2xi64>,
// CHECK-SAME: wavevector = dense<[42, 37]> : vector<2xi64>>,
// CHECK-SAME: phase = 0.000000e+00 : f64}
// CHECK-NEXT: ion.pulse([[timems3]] : f64) %arg1 {
// CHECK-NEXT: ion.pulse([[timems3]] : f64) %arg2 {
// CHECK-SAME: beam = #ion.beam<
// CHECK-SAME: transition_index = 1 : i64,
// CHECK-SAME: rabi = 99.989999999999994 : f64,
Expand Down

0 comments on commit 7780226

Please sign in to comment.