kitqat is a toolkit of utilities and algorithms built on top of the QAT module for quantum computing research and development. The code can be run on the open-source myQLM simulator. The usage with the custom Qaptiva appliance is mostly untested.
If you would like to use the code, a possible way is to install it through git is by using
pip install git+ssh://git@github.com/tigerjack/kitqat.git
You can additionally install myQLM with
pip install 'kitqat[myqlm] @ git+ssh://git@github.com/tigerjack/kitqat.git'
The reason to make myqlm an optional dependency is that the kitqat library
can also be run on the QLM machines.
If you would like to test the code and you do not have access to a QLM, you can install the open source myQLM.
The best way to install the code would be through pyenv and the pyenv-virtualenv. Refer to their guides on how to install them. After both of them are installed, you can run.
pyenv install 3.12.9
pyenv virtualenv 3.12.9 myqlm_env
where 3.12.9 is the python version used for this code and myqlm_env is the
name of the virtual environment (you can change whatever name you like). You can
also try for different python version, but the code has not been tested with
them. You can check the python versions available for myQLM on their
documentation.
Then, you can install myQLM inside the environment by launching
pyenv activate myqlm_env
pip install myqlm
pip install nptyping sympy
pip install paramaterized
pip install jupyter
Then, you can clone this repository and activate the environment.
cd <SOME_DIR>
git clone https://github.com/tigerjack/kitqat.git
cd kitqat
pyenv activate myqlm_env
where <SOME_DIR> can be whatever directory you want this repository to be
contained in.
galois is used to double-check
field operations.
sympy is only
used in testing to automatically compute the RREF of a matrix and compare the
results against our implementation. parameterized is used in order to have
parameterized testing; this is a legacy feature coming from unittest, and all
new code uses pytest built-in methods instead. jupyter is required to launch
notebooks.
- The actual code is under
kitqat. examplesdirectory contains some experiments that have been made.testdirectory contains all the tests for all the implemented routines.
The tests can be run using pytest (all tests) or
pytest -sv test/qatext/qroutines/walk/test_update_reversible0.py
(only a specific test case, replacing module name
with the actual name of the module).
When launching tests, you can provide some optional environment variables
LOG_LEVEL, with values equal to the names provided by Python logging utilities. E.g.LOG_LEVEL=DEBUG python -m unittest test.test_qroutine_rref.SLOW_TEST_ON=1to enable also time consuming testsREVERSIBLE_ON=1to enable the reversible simulator for circuits made only of reversible gates. Keep it on.QLM_ON=1to use the QLM instead of myQLMSIMULATOR, to pass the name of a simulator. For myQLM, thepylinalgandclinalgsimulators are available, and the latter is the default one. For QLM, there are a variety of available simulators depending on the version.
This project uses a two-stage development model: internal development in a private repository, followed by public release on GitHub.
- External contributors can submit pull requests on GitHub. All public contributions are licensed under the Apache License 2.0.
- Internal contributors must follow the internal development policy described in docs/CONTRIBUTING.md.
Significant contributions will be acknowledged in CONTRIBUTORS or release notes.
Part of the code presented here was used in the results of many of my articles. Check my website if you are interested.
-
Core infrastructure
- Reversible simulator
- ProgramWrapper and QRoutineWrapper objects (
kitqat.qatmgmt) - Helper functions for Gate, Observable, Result and Sample objects (
kitqat.qatmgmt)
-
State preparation
-
Quantum walk (
kitqat.qroutines.walk) -
Encoding classical data
-
Integer arithmetic (
kitqat.qroutines.arith)- Cuccaro arithmetic
- Adder/subtractor
- Different length registers
- Comparator
- No overflow
- Little/big endian
- No carry in
- TKK arithmetic
- Adder
- Subtractor
- Comparator
- No carry in
- Different length registers
- No overflow
- Little/big endian
- Perriello arithmetic
- 2-bit adder
- 2-bit comparator
- Cuccaro arithmetic
-
Arithmetic over finite fields (
kitqat.qroutines.algebraic)- GF(2ⁿ)
- Basic arithmetic (multiplication, schoolbook reduction)
- Adders (Cuccaro-style, TKK-style, QFT-based)
- Toom-Cook / Karatsuba multiplication
- Field inversion (Fermat's little theorem)
- GF(p)
- Barrett reduction
- Kaliski inversion
- Montgomery multiplication (
kitqat.qroutines.montgomery)
- GF(2ⁿ)
-
Linear algebra (
kitqat.qroutines.linalg) -
Cryptography (
kitqat.qroutines.crypto)- DES Sbox (Kwan) link
-
Data structures (
kitqat.qroutines.datastructure) -
Combinatorial circuits (
kitqat.qroutines)- Sorting network (
sorting) - Benes network (
hamming_weight_generate)
- Sorting network (
-
Hamming weight (
kitqat.qroutines)- Compute Hamming weight of a qubit subset (
hamming_weight_compute) - Generate Dicke states / check Hamming weight (
hamming_weight_generate)
- Compute Hamming weight of a qubit subset (
-
Quantum register management (
kitqat.qroutines.qregs_mgmt)- Register reversal
- Register rotation (left/right)
- Data initialisation (bitstring, bitarray, int)
- Matrix initialisation with row/column swap
-
Classical benchmarks (
bin/,test/classical_ref/)- Reference implementations for GF(2ⁿ) and GF(p) arithmetic
- Benchmark metrics (gate count, Toffoli count, depth)
- Benchmark inversions