Skip to main content

qitesse

PyPI Version License Python Versions

qitesse is a high-throughput CPU backend for repeated evaluation of parameterized quantum circuits.

qitesse is built upon qitesse-sim, the high-performance CPU-based state-vector execution engine for quantum circuits, fully built in Rust.

This PyPI module provides a Python interface designed for hybrid quantum algorithms, repeated circuit evaluation, backend integration, and low-overhead CPU execution from Python.

Features

  • Rust-based CPU statevector simulator with a Python API
  • One-off circuit execution through Gate and Circuit
  • Compiled parameterized circuits through CircuitSpec, Parameter, and CompiledCircuit
  • Reusable zero-copy parameter buffers through ParamBuffer and ParamBatchBuffer
  • Expectation-value workflows for Pauli observables and Hamiltonians
  • Batch expectation execution for parameter sweeps and optimizer loops
  • Gradient APIs for compiled circuits via parameter-shift evaluation
  • Reusable ExecutionContext buffers for repeated scalar execution
  • Full statevector output for both one-off and compiled execution paths
  • Mid-circuit measure, reset, and barrier operations
  • Custom unitary operations with Gate.unitary(...)
  • Controlled custom unitaries with Gate.controlled_unitary(...)
  • Common single-, two-, and multi-qubit gates
  • Read the Docs documentation with autogenerated API reference pages

Installation

qitesse requires Python 3.8+. Install it via pip:

pip install qitesse

Or install from source:

git clone https://github.com/OsamaMIT/qitesse.git

pip install maturin

maturin develop --release

To run examples:

python examples/h_example.py

python examples/qft._example.py

python examples/custom_unitary.py

Documentation

The documentation is now set up for Read the Docs with automatic API generation.

To add a new public class to the API docs, add it once in docs/api/index.rst. Sphinx will generate the class page and include its methods and attributes automatically.

Current Capabilities

qitesse currently has two main usage modes:

  1. General-purpose simulation with Gate and Circuit for one-off execution.
  2. Compiled execution with CircuitSpec and CompiledCircuit for repeated parameterized workloads.

The compiled path currently supports:

  • reusable zero-copy parameter buffers
  • scalar expectation evaluation
  • batched expectation evaluation
  • scalar gradients
  • batched gradients
  • reusable execution contexts
  • statevector inspection when needed

The simulator path currently supports:

  • standard single-qubit gates
  • controlled and multi-qubit gates
  • custom unitaries
  • measurement, reset, and barrier operations

Compiled Circuits

import numpy as np
import qitesse

spec = qitesse.CircuitSpec(2)
theta = spec.param("theta")

spec.ry(0, theta)
spec.cx(0, 1)

compiled = spec.compile()
observable = qitesse.Observable.pauli_z(1)

value = compiled.expectation(np.array([0.4], dtype=np.float32), observable)
gradient = compiled.gradient(np.array([0.4], dtype=np.float32), observable)
value_again, grad_again = compiled.value_and_gradient(
    np.array([0.4], dtype=np.float32),
    observable,
)
state = compiled.statevector(np.array([0.4], dtype=np.float32))

params_batch = np.array([[0.1], [0.2], [0.3]], dtype=np.float32)
values = compiled.batch_expectation(params_batch, observable)
grads = compiled.batch_gradient(params_batch, observable)

context = compiled.execution_context()
value_again = context.expectation(compiled, np.array([0.5], dtype=np.float32), observable)
grad_again = context.gradient(compiled, np.array([0.5], dtype=np.float32), observable)

This execution path is intended for repeated evaluation of the same circuit structure with different parameter values.

Backend Integration

The compiled execution path is the primary integration surface for higher-level libraries.

The intended backend pattern is:

  1. Translate a framework circuit into CircuitSpec
  2. Compile once per circuit structure
  3. Keep parameters in contiguous numpy.float32 arrays
  4. Call expectation, batch_expectation, gradient, or value_and_gradient

For sequential scalar calls, reuse compiled.execution_context() to keep internal buffers alive.

For sweeps, minibatches, or optimizer batches, prefer batch_expectation(...) and batch_gradient(...) instead of looping in Python.

Supported Gates

Single-qubit gates:

  • i
  • x
  • y
  • z
  • h
  • s
  • sdg
  • t
  • tdg
  • rx
  • ry
  • rz
  • p / phase
  • u

Two-qubit gates:

  • cnot / cx
  • cy
  • cz
  • ch
  • swap
  • iswap
  • crx
  • cry
  • crz
  • cp / cphase
  • cu

Three-qubit and larger:

  • ccx / toffoli
  • cswap / fredkin
  • mcx
  • mcz
  • mcp / mcphase
  • controlled_unitary

Circuit operations:

  • measure
  • reset
  • barrier

Custom unitaries:

import numpy as np
import qitesse

hadamard = np.array([[1, 1], [1, -1]], dtype=np.complex64) / np.sqrt(2)

circuit = qitesse.Circuit([
    qitesse.Gate.unitary([0], hadamard),
    qitesse.Gate.controlled_unitary([0], [1], hadamard),
])

state = circuit.run(2)

Use run_with_measurements(num_qubits) if the circuit contains measurement gates and you want the observed bit values back.

Planned Features

  • Additional simulation backends

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository
  2. Create a new branch (feature-branch)
  3. Commit your changes and open a pull request

License

This project is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for qitesse 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qitesse 0.2.0
File Size Uploaded Provenance Actions
qitesse-0.2.0.tar.gz 32.2 kB With provenance Details for qitesse-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for qitesse 0.2.0
File Interpreter ABI Platform Actions
qitesse-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details for qitesse-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Total release size: 524.1 kB

Release files / qitesse-0.2.0.tar.gz

Download URL qitesse-0.2.0.tar.gz
Size 32.2 kB
Tags Source
SHA-256 checksum
How to use checksums
027073b282a9989bd71602f5643aa753e9f1282442a480e1a0b2204e5d9ee187
BLAKE2b-256 checksum
How to use checksums
cc33c94af5b1fe270d2f0b2a4b9ac1386eee6e38a895b08cbfa960401f49dcd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 6, 2026.

Transparency log

Release files / qitesse-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL qitesse-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 491.9 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
03e8f1c65ceb3e746ef32d0949ed7d5742dc2e4fdc4b5e9a05b473ef9aef6993
BLAKE2b-256 checksum
How to use checksums
8b87b6febada9a8be18a39f12db83749233dd6957082c00ea5c150c90421c1d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 6, 2026.

Transparency log

Security for qitesse 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for qitesse-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page