⚠️ DISCONTINUATION OF PROJECT - This project will no longer be maintained by Intel. Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project. Intel no longer accepts patches to this project. If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the open source software community, please create your own fork of this project.
mat2qubit
is a Python package for converting matrix operators into a Pauli operator representation. Single particles/subsystems as well as interacting particles (e.g. many-body Hamiltonians) may be processed. More formally, the code takes sums of tensor products of arbitrarily sized matrices, and maps them to sums of Pauli products with a chosen encoding. The code assumes trivial (i.e. bosonic etc) commutation, meaning that it cannot be used for fermionic particles.
The package can be used to implement different encodings for which there are often depth-space tradeoffs or other resource tradeoffs (see references below). The built-in encodings include standard binary, Gray code, unary (one-hot), and block unary. User-defined embeddings may be added by modifying integer2bit.py
. This package is a partial implementation of the "discrete quantum intermediate representation" (DQIR) developed in reference [2] below.
Mathematical and theoretical details can be found in the following references. If you use the code, please cite an appropriate subset of these.
- Sawaya, NPD. mat2qubit: A lightweight pythonic package for qubit encodings of vibrational, bosonic, graph coloring, routing, scheduling, and general matrix problems. arXiv:2205.09776 (2022).
- Sawaya, NPD, Menke, T, Kyaw, TH, Johri, S, Aspuru-Guzik, A and Guerreschi, GG. npj Quantum Information, 6(49) (2020).
- Sawaya, NPD, Schmitz, AT, and Hadfield, S. arXiv preprint arXiv:2203.14432 (2022).
Please see the two files in the examples/
directory for worked examples of Bose-Hubbard model, chemical vibrations, classical linear algebra, spin-s models, graph coloring, traveling salesperson problem, and machine scheduling.
Intel Labs 2020 - 2022. Contact: nicolas.sawaya@intel.com
We recommend one of two installation options:
python setup.py bdist_wheel
pip install dist/*.whl
In your .bash_profile
include the path to the mat2qubit
directory in PATH
and PYTHONPATH
.
If you'd like to contribute, please install with dev dependencies:
python -m pip install '.[dev]'
To ease the pain of keeping the code style consistent, you can use pre-commit, with the provided .pre-commit-config.yaml
file.
In order to run tests please run:
python -m unittest mat2qubit/*_TEST.py