Browse the glossary using this index

Special | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | ALL
Picture of Yee Wei Law

QuTiP (Quantum Toolbox in Python): setup

by Yee Wei Law - Sunday, 23 June 2024, 8:58 AM
 

There is no shortage of quantum computing frameworks/toolkits, including Google’s Cirq, Rigetti’s Forest SDK (including pyQuil), Microsoft’s Q#-based Quantum Development Kit, IBM’s Qiskit, Quipper, QuTiP, ETHZ’s Silq, Cambridge Quantum Computing’s tket.

We shall use Qiskit because 1️⃣ it is among the most well-established (see Google Trends), and 2️⃣ it comes with rich learning resources.

  • Qiskit is an open-source Python-based SDK created by IBM for working with quantum computers at the level of pulses, circuits, and application modules.

We shall also use QuTiP, because while Qiskit is popular for quantum computing, QuTiP offers more features for quantum-dynamical simulations.

  • Simplistically speaking, Qiskit is more for computer scientists, whereas QuTiP is more for physicists.
  • Unlike Qiskit, which uses quantum circuits (QuantumCircuit) as the main building blocks, QuTiP uses “quantum objects” (QObj).

Watch an introduction to QuTiP:

Using Qiskit and QuTiP means we are using Python but there are so many resources for learning Python it should not be an issue for a Bachelor/Master student to pick it up along the way.

Even though the relevant computer pools will provide you with the required software, you need to install the software on your own computer(s) anyway, because you will not be able to finish any of the practicals within the allocated time.

The allocated time is only for you to get enough supervision so that you can complete the remainder of the practical on your own.

Our strategy here is to first install QuTiP, then Qiskit.

The operating system of choice for many computer scientists and cryptograhers is Linux, but the setup guide here is only applicable to Windows, because UniSA computer pools have only Windows.

Follow the instructions below (derived from the official instructions) to set up QuTiP:

  1. Install the Python distribution Miniconda, or Anaconda if you prefer installing more packages upfront.

    Upon successful installation of 64-bit Conda (short for “Miniconda/Anaconda”), you will see folder “Anaconda3 (64-bit)” on your Start menu, and under the folder, menu item “Anaconda Prompt (miniconda3)” 👈 Click this menu item to get a Conda command prompt.

    In the command prompt, run command to update Conda to the latest version:

    conda update conda
  2. Upon successful update of conda, in command line, create a conda environment called cyber (which can otherwise be any name you fancy):

    conda create -n cyber

    Environment is an essential feature of Conda for creating sandboxes for prototyping, development and experimentation. Read this guide to get a better understanding of Conda environments, including how to create/activate/list/deactivate/remove environments.

    Upon successful creation of the environment cyber, activate it:

    conda activate cyber
  3. Add the channel conda-forge to the list of channels (to be sure, keeping defaults at the highest priority) and install the necessary packages:

    conda config --append channels conda-forge
    conda install qutip pytest jupyterlab jupyterlab-git ipywidgets jupyterlab_widgets nodejs `
    seaborn numba numexpr pandas pandoc sympy
  4. Above, the backtick (`) is the line continuation character in PowerShell.

    Among the packages just installed,

    • pytest is for automating testing of Python code (e.g., of QuTiP).
    • jupyterlab is the JupyterLab package that will provide our graphical user interface (GUI).
    • jupyterlab-git is for version-controlling Jupyter notebooks.
    • ipywidgets and jupyterlab_widgets are libraries of Jupyter widgets.
    • nodejs is cross-platform Javascript runtime environment useful for JupyterLab.
    • seaborn is a Python data visualization library based on matplotlib.
    • numpy is not shown above, but is automatically installed with qutip. This is the fundamental package for scientific computing with Python.
    • numba is a just-in-time compiler that translates a subset of Python and NumPy code into fast machine code.
    • numexpr is for accelerating numerical evaluation of expressions in NumPy.
    • scipy is not shown above, but is automatically installed with qutip. This complements numpy for scientific computing with Python.
    • pandas is a data analysis library.
    • pandoc is a versatile document converter.
    • sympy is a versatile computer algebra system for symbolic computing.
    • pip is not shown above, but is a common dependency that is automatically installed by many other packages. It is a package installer for Python.

    Official Conda documentation discourages using pip and conda together, but we need pip for Qiskit later.

  5. Optional: Test your setup by running the official unit tests in a Python shell:

    import qutip.testing
    qutip.testing.run()

    These tests are computationally intensive and can slow down your computer dramatically. For reference, on a Intel Core i9-9880H CPU with 32 GB RAM, the tests take between 35 and 40 minutes.

  6. Continue to installation of Qiskit.
Tags: