Skip to content

tigerjack-quantum/kitqat

Repository files navigation

kitqat

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.

Usage

Installation

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.

Testing libraries

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.

Structure

  • The actual code is under kitqat.
  • examples directory contains some experiments that have been made.
  • test directory contains all the tests for all the implemented routines.

Tests

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=1 to enable also time consuming tests
  • REVERSIBLE_ON=1 to enable the reversible simulator for circuits made only of reversible gates. Keep it on.
  • QLM_ON=1 to use the QLM instead of myQLM
  • SIMULATOR, to pass the name of a simulator. For myQLM, the pylinalg and clinalg simulators are available, and the latter is the default one. For QLM, there are a variety of available simulators depending on the version.

Contributing

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.

Authors and citations

Part of the code presented here was used in the results of many of my articles. Check my website if you are interested.

List of utilities implemented / to be implemented

  • Core infrastructure

    • Reversible simulator
    • ProgramWrapper and QRoutineWrapper objects (kitqat.qatmgmt)
    • Helper functions for Gate, Observable, Result and Sample objects (kitqat.qatmgmt)
  • State preparation

    • Dicke state
    • Quantum circuits for general multi-qubit gates: link
    • Quantum-state preparation with universal gate decompositions: link
    • Quantum Networks for generating arbitrary quantum states: link
  • Quantum walk (kitqat.qroutines.walk)

  • Encoding classical data

    • Classical bitstring encoding
    • Binary Index eXtractor (BIX) link
    • Vertex Binary Encoding (VBE) TODO link
    • Basis encoding link
    • Amplitude encoding link
    • Angle encoding link
    • Higher order embedding link
    • Variational/trained embedding link
  • 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
  • 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)
  • Linear algebra (kitqat.qroutines.linalg)

    • Gauss-Jordan elimination link
    • Column permutations link
  • Cryptography (kitqat.qroutines.crypto)

    • DES Sbox (Kwan) link
  • Data structures (kitqat.qroutines.datastructure)

    • Sorted array insertion/deletion link
    • Sorted array low-width insertion/deletion TODO link
    • Array existence check link
  • Combinatorial circuits (kitqat.qroutines)

    • Sorting network (sorting)
    • Benes network (hamming_weight_generate)
  • Hamming weight (kitqat.qroutines)

    • Compute Hamming weight of a qubit subset (hamming_weight_compute)
    • Generate Dicke states / check Hamming weight (hamming_weight_generate)
  • 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

About

A toolkit of quantum utilities and algorithms built on top of myQLM's QAT framework.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages