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
without constructing either the full Hamiltonian matrix or its exponential. Each Pauli word is applied directly to the dense state vector, and a Lanczos–Krylov method approximates the matrix-exponential action in a much smaller subspace.
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(ham, psi)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
Evolution is serial by default.
Set num_threads to a positive integer to use that many OpenMP threads, or to "auto" to use the CPU count reported by the operating system:
evolved_psi = ql.evolve(ham, psi, num_threads="auto")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 dev mode and run Python tests with:
pip install -e .[dev]
pytest -v
