QiliSDK is an open-source Python framework for designing and executing analog, digital, and hybrid quantum algorithms. Its modular structure unifies circuit-based and Hamiltonian-based workflows within a single API. It provides high-level abstractions for gates, circuits, Hamiltonians, and optimizers, while remaining fully backend-agnostic allowing a seamless switch between CPU, GPU, or QPU execution.
QiliSDK is available via PyPI:
pip install qilisdkFor other installaton options, see the docs.
Here are just a few examples to get you started, for tutorials and full documentation, please see the docs.
To create a simple quantum circuit:
from qilisdk.digital import Circuit, H, RX, CNOT
circuit = Circuit(2) # Create a circuit with 2 qubits
circuit.add(H(0)) # Apply Hadamard on qubit 0
circuit.add(RX(1, theta=3.14)) # Apply RX rotation on qubit 1
circuit.add(CNOT(0, 1)) # Add a CNOT gate between qubit 0 and 1To create a linear interpolation between an initial and final Hamiltonian:
from qilisdk.analog import Schedule, X, Z
from qilisdk.core import Interpolation
initial_hamiltonian = - X(0) - X(1)
final_hamiltonian = Z(0) + Z(1) + 0.5 * Z(0) * Z(1)
schedule = Schedule(
hamiltonians={"driver": initial_hamiltonian, "problem": final_hamiltonian},
coefficients={
"driver": {(0.0, 10.0): lambda t: 1 - t / 10.0},
"problem": {(0.0, 10.0): lambda t: t / 10.0},
},
dt=0.5,
interpolation=Interpolation.LINEAR,
)This section covers how to set up a local development environment for qilisdk, run tests, enforce code style, manage dependencies, and contribute to the project. We use a number of tools to maintain code quality and consistency:
- uv for dependency management and packaging.
- ruff for linting and code formatting.
- ty for language server and static type checking.
- towncrier for automated changelog generation.
For instructions on how to compile from source and set up the development environment, see the docs. Following those instructions will setup a virtual environment (venv) in which you can run all other development tools (e.g. tests, linting).
We use pytest for the test suite. Once you have your venv set up, run the Python unit tests using:
pytest tests/unit_pythonTo run the integration tests (bigger tests which use the full QiliSDK stack and might take a bit longer):
pytest tests/integrationTo run the CUDA, qutip, and SpeQtrum backend tests, install the optional extras first (e.g., uv sync --all-groups --extra all-cu13).
To run the C++ tests, you first need to recompile with C++ testing enabled:
uv sync --reinstall -Ccmake.define.tests=ONThe C++ testing suite can then be ran using:
./tests/unit_cpp/test_cppWe enforce code style and best practices using ruff. ruff handles:
- Lint checks (similar to flake8, pylint).
- Formatting (similar to black or isort).
- Automated fixes for certain issues.
To check linting:
ruff checkTo automatically fix lint issues (where possible):
ruff check --fixTo automatically format your code:
ruff format(We recommend running ruff check --fix and ruff format before committing any changes.)
To check the C++ code, compile with the tidy flag:
uv pip install -v -e ./ -Ccmake.build-type=Debug -Ccmake.define.tidy=ONThis will run clang-tidy as well as a number of C++ compiler flags for debugging. For this you will need clang-tidy installed, which can be done on Debian/Ubuntu with:
sudo apt-get install clang-tidyIt may also throw an error about not being able to find omp.h, if so, try:
sudo apt-get install libomp-devWe use ty for static type checking. This helps ensure our code is type-safe and maintainable.
ty check(We encourage developers to annotate new functions, classes, and methods with type hints.)
For ease of use there are also a number of scripts in the scripts/ directory. Each of these generates a .log file with the same name as the script (checks.sh generates checks.log and so on).
To run all pre-commit checks (e.g. linting/tests):
bash scripts/checks.shTo check all of the code blocks in the documentaton:
bash scripts/docs.shTo generate a full coverage report of all code, run:
bash scripts/cov.shThis will generate a html file which you can open in your browser to see which lines (in both the C++ and Python) are covered by the tests. We aim for 100% coverage!
We manage our changelog using towncrier. Instead of editing CHANGELOG.md directly, each pull request includes a small news fragment file in the changes/ directory describing the user-facing changes.
For example, if you create a PR with id #123 adding a new feature, you add:
changes/123.feature.rst
Inside this file, you briefly describe the new feature:
Added a new `cool_feature` in the `qilisdk.backends` module.Instead of manually creating the file, you can run:
towncrier create --no-editWhen we cut a new release, we update the version in pyproject.toml file and run:
towncrierThis aggregates all the news fragments into the CHANGELOG.md under the new version and removes the used fragments.
We welcome contributions! Here’s the workflow:
- Fork this repository and create a feature branch.
- Write your changes (code, docs, or tests).
- Add a news fragment (if applicable) in
changes/describing the user-facing impact. - Run the following checks locally:
ruff check --fix ruff format ty check pytest tests
- Commit and push your branch to your fork.
pre-commitwill also run the checks automatically. - Open a Pull Request against the
mainbranch here.
Our CI will run tests, linting, and type checks. Please make sure your branch passes these checks before requesting a review.
This project is licensed under the Apache License.
- Thanks to all the contributors who help develop qilisdk!
- uv for making dependency management smoother.
- ruff, ty, and towncrier for their amazing tooling.
Feel free to open issues or pull requests if you have questions or contributions. Happy quantum coding!