quantlop is a Python package, backed by a native C++ core, for simulating the evolution of
quantum states under Hamiltonians expressed as weighted sums of Pauli words
quantlop computes the action
A dense Hamiltonian for
Install the latest release of the package directly from PyPI with:
pip install quantlopHere is a simple code example using quantlop native data structures:
import numpy as np
import quantlop as ql
num_qubits = 3
# define Hamiltonian in Pauli basis
pwords = [
ql.PauliWord(coeff=0.5, string="ZZI"),
ql.PauliWord(coeff=0.2, string="YIX"),
]
ham = ql.Hamiltonian(pwords=pwords)
# set initial state vector
psi = np.zeros(2**num_qubits, dtype=complex)
psi[0] = 1.0
# evolve state vector
evolved_psi = ql.evolve_higham(ham, psi)
# or
evolved_psi = ql.evolve_krylov(ham, psi)Both algorithms select their Taylor truncation or Krylov dimension automatically.
The default relative tolerance is 1e-9.
Smaller values generally improve accuracy at the cost of more computation.
The tolerance guides the internal approximation rather than measuring the
final error directly.
The library also provides class methods to import Hamiltonians directly from other quantum computing frameworks:
ql.Hamiltonian.from_pennylaneto build from PennyLaneHamiltonianobjectsql.Hamiltonian.from_qiskitto build from QiskitSparsePauliOpobjects
By default, evolution is serial. To enable multi-threading, pass a non-zero positive integer
as num_threads to request that many OpenMP threads. Passing "auto" selects the thread
count reported by the operating system.
evolved_psi = ql.evolve_higham(ham, psi, num_threads=4)The Python package is built with scikit-build-core, while the numerical C++ code is kept in the standalone quantlop_core CMake target.
See the Development section in the documentation for more details.
Build the project from source in editable mode and run Python tests with:
pip install -e .[dev,docs]
pytest -v




