We have been asked to measure relaxation and dephasing times T1 and T2 on the IBM Q using the composer only, Qiskit not allowed. I am a bit confused about the way to do so. Can someone explain the idea behind and how to implement the measurement in QASM?
2 Answers
I cannot give you a complete answer(I am not too familiar with the IBM quantum tools) however I might be able to give you a few hints from a NMR/EPR perspective.
In magnetic resonance T2 is commonly measured by generating a spin coherence, and refocusing at progressively longer times then measuring a spin echo.
In quantum gate language that would be: prepare in state $|0\rangle$, Hadamard gate, $X$ or $Y$ gate, Hadamard gate, measure. And progressively add identity operations between the $H-X$ and $X-H$. Alternatively you can add progressively more $X$ gates and only measure at the odd numbered ones. Though I suppose the latter method would introduce gate errors into your measurement.
And T1 in magnetic resonance is usually measured by an inversion recovery: so prepare qubit in state $|0\rangle$, invert with $X$ or $Y$, and measure at progressively longer delays by using identity operations as delays.
Let's start with measuring circuits. With the link to user245427's answer, you should construct following circuits in composer:
T1 (relaxation time)
T1 is constant connected with spontaneous relaxation from state $|1\rangle$ to state $|0\rangle$. So first apply $X$ gate on a qubit to change its state from $|0\rangle$ to $|1\rangle$, then apply a few $I$ gates to make a delay and then measure results. Record a probability of measuring state $|1\rangle$ (i.e. relaxation did not occur).
T2 (dephasing time)
T2 is connected with change in phase, for example state $|+\rangle$ changes spontaneously to $|-\rangle$. To prepare $|+\rangle$ apply $H$ gate on qubit in state $|0\rangle$. Then apply several $I$ gates to make a delay. After that apply again $H$ gate and do measurement. Record probability of measuring state $|0\rangle$ (i.e. phase change did not occur).
T1 and T2 calculation
Both decoherence processes are described by exponential decay law:
$$ P(t) = \mathrm{e}^{-\frac{t}{T}} $$
where $T$ is either T1 or T2 constant, $t$ is time between setting qubit to either state $|1\rangle$ for T1 or $|+\rangle$ for T2 and its measurement. Having probabilities that a qubit is in state either $|1\rangle$ and $|+\rangle$ and knowing $t$ you can easily calculate
$$ T = -\frac{t}{\ln P(t)}. $$
Although it is not problem to construct such circuits on IBM Q, I realized that the problem is how to obtain time $t$. After simulation you get results with time the simulation actually run on a quantum processor. It seems logical to divide this time with number of shots to get length of one shot and hence $t$. I did so on Melbourne processor but it seems that some other operations take place among shots which lengthen time $t$. As a result you can not get actual time $t$. If you put length of simulation to the formula above, resulting T1 is in order of milliseconds which does not make sense.