This repository contains the full source code for tket, a quantum SDK.
If you just want to use tket via Python, the easiest way is to install it with
pip
:
pip install pytket
For full API documentation, as well as a comprehensive user manual and a selection of example notebooks, please follow the links from the pytket main page.
In addition to the core pytket package there are pytket extension modules which allow pytket to interface with quantum devices and simulators. Some extensions also provide interoperability with other software libraries such as qiskit, cirq and pennylane.
For a list of available pytket extensions see the extensions index page.
These extensions are installed as separate python packages and the source code for each extension lives in its own github repository.
If you would like to build tket yourself and help to improve it, read on!
The codebase is split into two main projects:
- tket: the core functionality of tket, optimised for execution speed and implemented in C++.
- pytket: the Python interface of tket. This consists of
binder modules to tket (written in C++ and making use of
pybind11
to link to the tket shared library) and pure Python code that defines abstract interfaces used by the extension modules such as theBackend
andBackendResult
classes, as well as various other utilities.
The following compiler toolchains are used to build tket on the CI and are therefore known to work:
- Linux: gcc-11
- MacOS: apple-clang 14
- Windows: MSVC 19
It is recommended that you use these versions to build locally, as code may
depend on the features they support. The compiler version can be controlled by
setting CC
and CXX
in your environment (e.g. CC=gcc-11
and CXX=g++-11
),
or on Debian-based Linux systems using update-alternatives
.
You should also have Python (3.9, 3.10 or 3.11) and pip
installed. We use
cmake
and the package manager conan
to build tket and pytket. The latter can
be installed with pip
:
pip install conan
You will need at least cmake version 3.26, and conan version 2.
Generate a profile that matches your current machine, and add the required remote where some dependencies are stored:
conan profile detect
conan remote add tket-libs https://quantinuumsw.jfrog.io/artifactory/api/conan/tket1-libs --index 0
It is recommended that you also install ninja
and ccache
to speed up the
build process. For example with apt
on Debian/Ubuntu:
apt install ninja-build ccache
Homebrew on MacOS/Linux:
brew install ninja ccache
Chocolatey on Windows:
choco install ninja ccache
On MacOS/Linux:
- If installed,
ccache
is used automatically ninja
must either be set as the default Cmake generator using the following command:or be specified on a command-by-command basis by providing the argumentecho "tools.cmake.cmaketoolchain:generator = Ninja" >> $(conan config home)/global.conf
-c tools.cmake.cmaketoolchain:generator=Ninja
to conan
On Windows:
- Set
ninja
as generator as described above (less reliable than the defaultVisual Studio
generator) ccache
will be used automatically only when usingNinja
orMakefile
as the Cmake generator. It can also be used withVisual Studio
generators by setting the environment variableTKET_VSGEN_CCACHE_EXE
to the path of theccache
executable. Note: this must be the path to the actual binary, not a symlink or shim (as used by Chocolatey). If using Chocolatey to installccache
, you can find the path to the binary usingccache --shimgen-help
See the README in the libs
directory for instructions on
building and testing the utility libraries used by tket (for logging,
random-number generation and so on). This is not necessary if you just want to
build tket or pytket since the recipes or binaries will be automatically
downloaded from the above conan remote.
See the README in the tket
directory for instructions on
building and testing tket as a standalone C++ library.
See the README in the pytket
directory for instructions on
building and testing pytket.
Tket and pytket are available as a Nix flake, with support for Linux and Apple Silicon systems.
See the README in the nix-support
directory for instructions
on building and testing tket and pytket through Nix, and on how to use it within a Nix project.
The tket
(C++) API documentation (generated with doxygen
, and still rather
patchy) is available
here.
The pytket
(Python) API documentation is available
here.