Introduction
Interested in learning how to program quantum computers? Then check out our Qiskit textbook Introduction to Quantum Computing with Qiskit.
In this tutorial we will explore the effects of T1 relaxation on IBM quantum computers in Qiskit.
What is T1 relaxation time?
Current superconducting qubits are very susceptible to decoherence due to its external environment. One example of decoherence is thermal relaxation.
Also known as T1 relaxation time this is where a qubits state to decays from |1〉to |0〉within a certain amount of time.
The effects of T1 relaxation can be seen very easily with the following steps:
Initialise the qubit to |1〉using a Pauli-X gate
Add a delay to the circuit
Measure the qubits state
The longer the delay the more measurements there will be for |0〉 due to thermal relaxation.
Implementation
In Qiskit T1 relaxation can be observed very easily by with the following steps:
Step 1: Initialise the quantum and classical registers
The first step is to initialise the registers. Our circuit will consist of two registers. A quantum register that holds our qubit and a classical register that holds the bit used to hold the qubits state.
In Qiskit the registers can be initialized using the following code:
q = QuantumRegister(1,'q') c = ClassicalRegister(1,'c')
Step 2: Create the circuit
The next step is to create the circuit. This consists of a Pauli-X gate that is applied to the circuit followed by a delay of 200.79 microseconds. This is the T1 relaxation time for the IBMQ Armonk device that is used in this tutorial.
After the delay a measurement is applied to the qubit.
circuit = QuantumCircuit(q,c) circuit.x(q[0]) circuit.delay(200.79, unit="us") # Delay of 200.79 microseconds circuit.measure(q[0],c[0]) #Measuring the qubit
Step 3: Transpile the circuit
The next step is to transpile the circuit. This is done so that the scheduling method can be set so that the delay will be implemented.
transpiled_circ = transpile(circuit, backend, scheduling_method='alap')
Step 4: Execute the circuit on the backend device
Where nshots is the amount of times the circuit is ran and the backend is the ibmq_armonk device.
nShots = 8192 job = execute(transpiled_circ, backend, shots=nShots) job_monitor(job)
Step 5: Get the results
The final step is to get the results back and print them!
counts = job.result().get_counts() print("With delay: ",counts)
How to run the program
Copy and paste the code below in to a python file
Enter your API token in the IBMQ.enable_account('Insert API token here') part
Save and run
Note: To get an API key sign up to IBM Q Experience and get your token here: https://quantum-computing.ibm.com/account
Code
from qiskit import QuantumRegister, ClassicalRegister from qiskit import QuantumCircuit, execute,IBMQ from qiskit.tools.monitor import job_monitor from qiskit import transpile IBMQ.enable_account('ENTER API KEY HERE') provider = IBMQ.get_provider(hub='ibm-q') backend = provider.get_backend('ibmq_armonk') q = QuantumRegister(1,'q') c = ClassicalRegister(1,'c') def withoutDelay(): circuit = QuantumCircuit(q,c) circuit.x(q[0]) circuit.measure(q[0],c[0]) #Measuring the qubit nShots = 8192 job = execute(circuit, backend, shots=nShots) job_monitor(job) counts = job.result().get_counts() print("No delay: ",counts) def withDelay(): circuit = QuantumCircuit(q,c) circuit.x(q[0]) circuit.delay(200.79, unit="us") # Delay of 200.79 microseconds circuit.measure(q[0],c[0]) #Measuring the qubit transpiled_circ = transpile(circuit, backend, scheduling_method='alap') nShots = 8192 job = execute(transpiled_circ, backend, shots=nShots) job_monitor(job) counts = job.result().get_counts() print("With delay: ",counts) withoutDelay() withDelay()