NQI C2QA project to simulate hybrid boson-qubit systems within QisKit.
We recommend installing bosonic-qiskit in a virtual environment. If using the uv
package manager, skip this step as uv will automatically make the environment for you.
python3 -m venv venv
source venv/bin/activateThe easiest way to install bosonic-qiskit is through PyPi:
pip install bosonic-qiskitSource code installation of bosonic-qiskit for development is possible
git clone https://github.com/C2QA/bosonic-qiskit.git
cd bosonic-qiskit
pip install --group dev -e .
pre-commit installThe above script does the following:
- The bosonic-qiskit library is installed in editable mode with developer requirements from
pyproject.toml, which includes tools such aspytest,flake8,black, andpre-committo aid in satisfying code style and format requirements. - The tool
pre-commitis installed which automatically runsflake8andblackupon thegit commitcommand.
If using the uv package manager, instead run
uv tool install pre-commit
git clone https://github.com/C2QA/bosonic-qiskit.git
cd bosonic-qiskit
uv sync --dev
pre-commit installAny changes or additions to bosonic-qiskit must be black and flake8 compliant. These tools can be run manually, however with pre-commit these tools automatically check for code style compliance when commiting code.
If black shows non-compliant code formatting, changes must be be manually made and altered files must be recommitted.
The Bosonic Qiskit software has not been extensively tested with different versions of its dependencies; however, some success has been achieved with both newer and older versions of Qiskit. Do note that some features require newer versions. For example, the noise modelling requires Qiskit v0.34.2+. Using older versions will cause ModuleNotFoundError at runtime.
Jupyter Notebook tutorials can be found in the tutorials folder. JupyterLab is a dependency found in the dev dependencies of pyproject.toml, so after installing and activating the virtual environment, to run the tutorials simply start Jupyter with jupyter lab and then navigate to the desired tutorial.
See our paper presented at IEEE HPEC 2022 on arXiv for more information on using bosonic-qiskit.
The code is structured to separate generation of the operator matrices from creating instances of QisKit Gate.
The first step in adding a new gate is to develop software to build a unitary operator matrix. These matrices must be unitary in order for QisKit to simulate them. Non unitary matrices will fail during simulation. Existing operator matrices are built in the CVOperators class found in operators.py. Included in CVOperators are functions to build the bosonic creation and annihilation operators based on a provided cutoff. The order of the data in your operators must match the order of the qumodes (QisKit qubits) sent in as QisKit gate parameters found in circuit.py, as described next.
Once you've written software to build the operator matrix, a new function is added to the CVCircuit class found in circuit.py. This class extends the QisKit QuantumCircuit class to add the bosonic gates available in this library. The previously defined operators are parameterized by user input, as needed, and appended to the QuantumCircuit as unitary gates. The CVCircuit class includes functions to easily make your new gates conditional based on a control qubit.
See examples of software building new gates in the previously mentioned operators.py and circuit.py. Examples using the library's gates can be found in both the PyTest test cases and Jupyter Notebook tutorials folders
Current gates available for simulation are documented at Github pages