Skip to content

Commit f612c0b

Browse files
authored
Fine amplitude fix (#698)
* Fixes an issue with fine amplitude where the measurement was not applied on the logical qubit (i.e. before intial mapping).
1 parent be322e3 commit f612c0b

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

qiskit_experiments/library/characterization/fine_amplitude.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,16 @@ def __init__(
124124
qubits: The qubit(s) on which to run the fine amplitude calibration experiment.
125125
gate: The gate that will be repeated.
126126
backend: Optional, the backend to run the experiment on.
127+
measurement_qubits: The qubits in the given physical qubits that need to
128+
be measured.
127129
"""
128130
super().__init__(qubits, analysis=FineAmplitudeAnalysis(), backend=backend)
129131
self.set_experiment_options(gate=gate)
130-
self._measurement_qubits = measurement_qubits or qubits
132+
133+
if measurement_qubits is not None:
134+
self._measurement_qubits = [self.physical_qubits.index(q) for q in measurement_qubits]
135+
else:
136+
self._measurement_qubits = range(self.num_qubits)
131137

132138
def _spam_cal_circuits(self, meas_circuit: QuantumCircuit) -> List[QuantumCircuit]:
133139
"""This method returns the calibration circuits.
@@ -344,7 +350,7 @@ def __init__(self, qubits: Sequence[int], backend: Optional[Backend] = None):
344350
# Failing to do so causes issues with QuantumCircuit.calibrations.
345351
gate = Gate("szx", 2, [])
346352

347-
super().__init__(qubits, gate, backend=backend, measurement_qubits=[1])
353+
super().__init__(qubits, gate, backend=backend, measurement_qubits=[qubits[1]])
348354
# Set default analysis options
349355
self.analysis.set_options(
350356
angle_per_gate=np.pi / 2,

test/calibration/experiments/test_fine_amplitude.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ def test_x90p(self):
148148
self.assertEqual(circ.count_ops().get("sx", 0), expected[idx])
149149

150150

151+
@ddt
151152
class TestSpecializations(QiskitExperimentsTestCase):
152153
"""Test the options of the specialized classes."""
153154

@@ -174,6 +175,16 @@ def test_fine_sx_amp(self):
174175
self.assertEqual(exp.analysis.options.phase_offset, np.pi)
175176
self.assertEqual(exp.experiment_options.gate, SXGate())
176177

178+
@data((2, 3), (3, 1), (0, 1))
179+
def test_measure_qubits(self, qubits):
180+
"""Test that the measurement is on the logical qubits."""
181+
182+
fine_amp = FineZXAmplitude(qubits)
183+
for circuit in fine_amp.circuits():
184+
self.assertEqual(circuit.num_qubits, 2)
185+
self.assertEqual(circuit.data[-1][0].name, "measure")
186+
self.assertEqual(circuit.data[-1][1][0], circuit.qregs[0][1])
187+
177188

178189
class TestFineAmplitudeCal(QiskitExperimentsTestCase):
179190
"""A class to test the fine amplitude calibration experiments."""

0 commit comments

Comments
 (0)