qiskit-community / qiskit-experiments

Qiskit Experiments
https://qiskit-community.github.io/qiskit-experiments/
Apache License 2.0
154 stars 125 forks source link

Change T2Ramsey circuit #661

Closed yaelbh closed 2 years ago

yaelbh commented 2 years ago

Quoting a discussion that we had: @nkanazawa1989 (slightly edited): I was wondering why T2Ramsey uses H-delay-H and measures P0. I always use SX-delay-SX followed by measuring P1 (both are the same but I guess SX-delay-SX-P1 is more straightforward). I guess this sequence is from Ignis where we didn't have SX gate in the basis and SX-delay-SX had been giving us inefficient decomposition. I think we no longer need to use this sequence (to eliminate cal error probably we can do SX-delay-SXdag). @wshanks: Oh, yes, I am familiar with SX-delay-SX, not H-delay-H

We should perform the suggested modification, probably after #438 is done. After some delay, we can proceed with #438 now.

ItamarGoldman commented 2 years ago

From A Quantum Engineer’s Guide to Superconducting Qubits, I see we need to use two RX(pi/2):

image
wshanks commented 2 years ago

sx and RX(pi/2) are the same up to a global phase: https://qiskit.org/documentation/stubs/qiskit.circuit.library.SXGate.html?highlight=sxgate#qiskit.circuit.library.SXGate, so either one should work. On the IBM backend, sx is more natural but they probably both work the same here (I am not totally sure how transpiling works out since we typically avoid full transpilation in experiments).

nkanazawa1989 commented 2 years ago

Sometime Rx(pi/2) is translated into weird sequence of two sx pulses (with opt level0), so I recommend to directly use sx. And current Ramsey implementation (H-delay-H) counts |0> probabiliity to match with the curve of the standard sx-delay-sx sequence. This part should be corrected.

wshanks commented 2 years ago

@nkanazawa1989 Just curious, is Rx(pi/2) more in the "spirit" of qiskit than sx or are they just equivalent? We use sx in a lot of other experiments so it is fine to use it here. I was wondering if it was something we do because we usually target the IBM backends. Would it be more proper to use Rx(pi/2) and transpile it individually with high opt level while keeping level0 for the whole circuit?

nkanazawa1989 commented 2 years ago

I don't remember the details but it does some unitary decomposition, i.e.

from qiskit import QuantumCircuit, transpile
import numpy as np

qc = QuantumCircuit(1)
qc.rx(np.pi/2, 0)

transpile(qc, basis_gates=["sx", "rz"], optimization_level=0).draw()

will give you

global phase: 3π/2
   ┌─────────┐┌────┐┌──────────┐┌────┐┌──────────┐
q: ┤ Rz(π/2) ├┤ √X ├┤ Rz(3π/2) ├┤ √X ├┤ Rz(5π/2) ├
   └─────────┘└────┘└──────────┘└────┘└──────────┘

I agree with using rx(pi/2) is more general, but using sx should be fine because it can be translated into the provided gate set if it is universal. In the context of measurement basis projection we often use ry(pi/2) and in that case I use ry gate with hard-coded transpiler config of optimization_level=1.

yaelbh commented 2 years ago

Done