Concluding my GSoC ’22 project

Shreyas Pradhan
4 min readSep 11, 2022

--

This is the concluding blog post for my project — qutip-qip as a qiskit backend. It contains a summary of what I did during Google Summer of Code ’22 with the organisation QuTiP (under NumFOCUS). Thanks to my mentors — Boxi Li and Alex Pitchford for all your help throughout this project.

You can find my work in qutip-qip‘s github repository under the qiskit/ folder.

For more details, you can view the contents of the two pull requests that tracked my progress throughout this project: github/qutip/qutip-qip#155 and github/qutip/qutip-qip#159.

A Summary of my project

I created the qiskit sub-package in qutip-qip which can be used to run a circuit created inqiskit on a qutip-qip based backend. This allows us to utilise the gate-level optimisation and functionality from qiskit while using the simulation features provided by qutip-qip like simulating noisy devices.

functionality: The major part of the project involved coding up the backends. This code can be found in folder — github/qutip/qutip-qip/src/qutip_qip/qiskit .

A summary of my implementation of the backends— First, I had to first design a converter that converts a circuit from qiskit to a circuit in qutip-qip. After running this converted circuit in qutip-qip, I designed a parser which converts the qutip-qip result to a qiskit compatible result. I also implemented methods that allow us to change subspaces, which was used in the different physical models in the pulse-level simulation.

tests: Other than the actual functionality, a very important part of the project was to write the tests, to ensure the backends work correctly, in the future, even after major changes. The tests can be found in the file — github/qutip/qutip-qip/tests/test_qiskit.py .

documentation: This includes the docstrings within the code and a user guide to help introduce this sub-package. It is part of qutip-qip‘s documentation.

The backends

Two types of qutip-qip based backends were were made in this project. The QiskitCircuitSimulator uses the CircuitSimulator for gate-level simulation. The other backend — the QiskitPulseSimulator can be used to run a qiskit circuit on either of the LinearSpinChain, CircularSpinChain or DispersiveCavityQED processor models.

Here is an example of what running a circuit using the backends looks like:

Let’s see what the gate-level simulation looks like:

from qiskit import QuantumCircuitcirc = QuantumCircuit(2,2)
circ.h(0)
circ.h(1)
circ.measure(0,0)
circ.measure(1,1)

We created a circuit in qiskit. Let’s simulate it using our backends now.

from qutip_qip.qiskit import QiskitCircuitSimulator
backend = QiskitCircuitSimulator()
job = backend.run(circ)
result = job.result()

This backend converts and simulates the circuit at gate-level.

The result is ready and is in qiskit compatible format. Hence, we can use functions from qiskit to analyse it.

from qiskit.visualization import plot_histogram
plot_histogram(result.get_counts())
Results after simulation.

Let’s also have a look at the pulse simulators. In this case, we can connect the circuit to different physical models in qutip-qip. This allows us to model systems closer to reality.

Some physical models in qutip-qip like the DispersiveCavityQED use more than the number of qubits in the original circuit to simulate. I designed methods to convert these higher-qubit systems back into our original circuit’s subsystem and also the other way around.

from qutip_qip.device import CircularSpinChain
processor = CircularSpinChain(num_qubits=2, t1=0.3)
pulse_circ = QuantumCircuit(2,2)
pulse_circ.h(0)
pulse_circ.h(1)
noisy_backend = QiskitPulseSimulator(processor)
noisy_job = noisy_backend.run(pulse_circ)
noisy_result = noisy_job.result()

An important feature of physical devices is noise. We have used a noisy backend above to demostrate how noise can affect the results.

plot_histogram(noisy_result.get_counts())
Result after simulation with noise.

We can see that the result is not equiprobable (which is what we would expect without noise). It is biased towards 0 for both the qubits. This is because we used an amplitude damping noise on both of them. We can experiment in a similar way with different types of physical models and differents types of noise.

You can refer the qutip-qip documentation for complete details on using this sub-package.

Scope for contribution to this sub-package

Even though my project ended with the above mentioned functionalities, there is scope for things to be added to this sub-package. While I plan to continue working on qutip-qip even after project has officially ended, you can contribute to qutip-qipas well by working on the below mentioned functionalities or any other part of qutip as well of course.

Additional backends — Support for the SCQubits and OptPulseProcessor models.

Qiskit-Pulse — Currently, qiskit circuits can be run on the backends. Support for pulse-level instructions directly from qiskit (made using Qiskit-Pulse) to be simulated on the pulse backends can be added.

Blogs

You can also have a look at the blogs I made during the project. Here are the links to them:

--

--