Skip to main content

NWQLib: Northwest Quantum Library

PyPI Python License Documentation DOI

NWQLib applies quantum algorithms to scientific problems. You state the problem and choose a method, and NWQLib plans the construction, runs it on the backend you choose and returns the result with its resource counts and what is known about its error. Circuits are built with Qiskit.

Documentation: https://pnnl.github.io/NWQLib/

Installation

NWQLib requires Python 3.12 or later. Install the package with the local Aer simulator:

python -m pip install "nwqlib[aer]"

The base package depends on NumPy 2.5.2 or later, SciPy 1.18.1 or later, SymPy 1.14.0 or later and Pydantic 2.13.5 or later, below 3. The extras aer, qiskit, ibm, ionq, nexus, chemistry, tensor, qasm and nwqec require Qiskit 2.5.2 or later. The validated CI environment in docs/ENVIRONMENT_LOCK.txt uses Python 3.12.14, Qiskit 2.5.2 and Qiskit Aer 0.17.2.

The base package, python -m pip install nwqlib, describes the methods, accepts numerical inputs, plans LCHS with its default settings and supports classical evaluation with execution="classical" for LCHS, QLS, QCELS, SPE, RFE, RWPE, QHD, Expectation, Lanczos, FixedGCIM and ADAPT within their supported numerical-input and method-option domains. Classical evaluation that expands a circuit-defined initial or trial state also requires Qiskit. Building circuits needs the qiskit extra, and running them needs the extra of the chosen backend (aer, ibm, ionq, nexus), each of which includes Qiskit. For example, python -m pip install "nwqlib[aer,notebook,chemistry]" adds the example notebooks and the molecular Hamiltonian builder, and python -m pip install "nwqlib[ibm]" adds IBM Runtime. Install and first result lists every extra, and Choose a backend explains what each backend supports. To work on NWQLib itself, see Set up, test and build.

First result

To solve du/dt = -A u with a small physical input:

from nwqlib import LinearDynamics, solve
from nwqlib.algorithms import LCHS

problem = LinearDynamics(
    A=[[0.4, 0.15], [0.05, 0.25]],
    initial_state=[1.0, 0.0],
    time=0.1,
)
result = solve(problem, method=LCHS())
print(result.solution)
[ 0.96006038-1.54102084e-12j -0.00513885+3.61167323e-13j]

The default returns an approximation of the physical solution using nine qubits in total. Install and first result compares it with an independent reference and shows how to change the approximation. Each method accepts its own input forms and conversions, which its algorithm guide describes.

The example notebooks solve complete scientific problems from input to result, error and circuit cost: molecular ground-state energy, a linear system, linear dynamics and optimization. One more notebook estimates the resources of a linear system, heat flow, two spin chains and a GCiM trial basis at 80 to 100 system qubits, where the largest circuit, LCHS for heat flow, has 109 qubits in total. It also estimates one QHD step on a three-variable grid of 32 points per variable, which takes 96 qubits in the one-hot encoding. The examples guide points you to the notebook that matches your problem. The mathematics page states the bounds, resource formulas and error budgets that NWQLib uses, each with its proof or source and the code that implements it.

Choose a task

Task Read
Install and get a first result Install and first result, examples
Learn what Problem, Method, Plan, Run and Result are How NWQLib works
Choose a problem and output Choose a problem and output
Compare NWQLib with other quantum packages Why NWQLib
Compare methods and inspect results Plan, compare and solve
Supply operators and states Supply inputs
Estimate resources and check device fit Estimate resources, Check device fit and run time
Check a result against a reference or tolerance Check accuracy and verify a result
Run locally or submit to a provider Run on a backend, Choose a backend
Save results or continue an interrupted run Save, load and reanalyze results, Continue an interrupted run
Run your own circuit or compare your own method Run your own circuit, Add a method
List methods or use the command line Use the command line
Look up a signature API reference
Check known defects in Qiskit and other dependencies, and how NWQLib handles them Dependency issues
Trace code to its paper, equation and reason Code tour, references
Find the bound, resource formula or error budget behind a result, its proof or source, and its code Mathematics
Maintain NWQLib Set up, test and build, contribution policy, Contributing

Each method's tests are in tests/, in files named after the method, such as tests/test_lchs_*.py and tests/test_qls_*.py. The examples guide lists the notebook of each method.

Algorithms

Scientific task Methods
Normalized expectation of a finite real Pauli sum Expectation
Energy estimates from moments or a chosen subspace Chebyshev Lanczos (arXiv:2208.00567v4), fixed and adaptive GCiM (fixed arXiv:2212.09205v1, adaptive arXiv:2312.07691v3)
Phase or energy estimation QPE: QCELS, RWPE, SPE and RFE (QCELS arXiv:2211.11973v2, RWPE arXiv:2208.04526v1, SPE arXiv:2110.12071v2, RFE arXiv:2209.11322v3)
Time-independent linear dynamics LCHS (arXiv:2312.03916v2)
Linear systems QLS: QSVT inverse polynomial (qsvt_inverse, the default) and the Dalzell kernel shortcut (shortcut_native_svp, shortcut_dilation) (QSVT arXiv:1806.01838v1, Dalzell arXiv:2406.12086v2)
Box-constrained optimization QHD (arXiv:2303.01471v1)
Optimization over a box with equality or inequality constraints QHD augmented Lagrangian (arXiv:2605.12066v1)

Each method reports the quantity it obtained and any accuracy conditions that remain unresolved. Each method is checked on small cases against independent references, and Limitations and open work lists what has been checked for each method and its current limitations. The resource-estimation notebook runs no circuit. A projected energy, a local statistical interval or a completed simulation does not by itself establish the full requested scientific claim. State preparation, block encoding, LCU, QSP/QSVT and evolution subroutines have their own API reference pages.

Backend support

Backend Runs where Tested against the live service
Aer Locally Not applicable
NWQ-Sim Locally, with the NWQ-Sim build described in its guide. CPU execution, and continuing a run after Python exits, were tested on macOS and Linux with that build Not applicable
Slurm NWQ-Sim on your cluster, with explicit site configuration No. Scheduler and site-configuration handling is tested offline. Site allocation, MPI and GPU execution are not tested
IBM Runtime IBM Quantum service No. SDK calls and result handling are tested offline. Live accounts, queues and QPUs are not tested
IonQ IonQ service No. Circuit conversion and result handling are tested offline. QPUs are not tested
Quantinuum Nexus Nexus H2 service No. Conversion, remote-job handling and results are tested offline. Nexus needs a pandas dependency exception and has no per-request timeout

A backend runs a method only when it supports that method's circuits and readout. Choose a backend gives the details.

Citation

If you use NWQLib in your work, please cite it through its Zenodo record, which resolves to the latest version:

@software{nwqlib,
  author  = {Zheng, Muqing and Liu, Chenxu and Song, Zhixin and Wu, Zeguan and Li, Xiangyu and Li, Mingze and Bauman, Nicholas P. and Stein, Samuel A. and M{\"u}lmenst{\"a}dt, Johannes and Chen, Yousu and Wiebe, Nathan and Li, Ang and Kowalski, Karol},
  title   = {NWQLib},
  year    = {2026},
  version = {1.0.2},
  doi     = {10.5281/zenodo.23074265},
  url     = {https://github.com/pnnl/NWQLib}
}

The references page lists the papers behind each algorithm and subroutine, with the equations NWQLib implements.

Authors and Developers

For questions, bug reports or collaboration, contact Muqing Zheng (muqing.zheng@pnnl.gov).

Affiliations are those at the time of contribution.

  • Muqing Zheng, Pacific Northwest National Laboratory
  • Chenxu Liu, Pacific Northwest National Laboratory
  • Zhixin Song, Pacific Northwest National Laboratory and Georgia Institute of Technology
  • Zeguan Wu, Pacific Northwest National Laboratory and University of Pittsburgh
  • Xiangyu Li, Pacific Northwest National Laboratory
  • Mingze Li, Pacific Northwest National Laboratory
  • Nicholas P. Bauman, Pacific Northwest National Laboratory
  • Samuel A. Stein, Pacific Northwest National Laboratory
  • Johannes Mülmenstädt, Pacific Northwest National Laboratory
  • Yousu Chen, Pacific Northwest National Laboratory
  • Nathan Wiebe, Pacific Northwest National Laboratory and University of Toronto
  • Ang Li, Pacific Northwest National Laboratory and University of Washington
  • Karol Kowalski, Pacific Northwest National Laboratory

Acknowledgements

This work was supported by Pacific Northwest National Laboratory's Quantum Algorithms and Architecture for Domain Science (QuAADS) Laboratory Directed Research and Development (LDRD) Initiative. This material is based upon work supported by the U.S. Department of Energy, Office of Science, National Quantum Information Science Research Centers, Quantum Science Center (QSC). The Pacific Northwest National Laboratory is operated by Battelle for the U.S. Department of Energy under Contract DE-AC05-76RL01830.

NWQLib is released under the BSD 2-Clause License, given in LICENSE. Information release number PNNL-SA-227989.

Metadata

Release files for nwqlib 1.0.2

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

Source distribution (sdist)

Source distribution for nwqlib 1.0.2
File Size Uploaded
nwqlib-1.0.2.tar.gz 5.9 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for nwqlib 1.0.2
File Interpreter ABI Platform
nwqlib-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 8.1 MB

Release files / nwqlib-1.0.2.tar.gz

Download URL nwqlib-1.0.2.tar.gz
Size 5.9 MB
Tags Source
SHA-256 checksum
How to use checksums
be4572de612b547f7ff6083f56f86acd9de8d8163bb2626c8b55543d7f449f3b
BLAKE2b-256 checksum
How to use checksums
7ca37d97acf3a3d785a1b97e3950360ffc164aa8f9650cc7494b9060528fc02a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 7, 2026.

Transparency log

Release files / nwqlib-1.0.2-py3-none-any.whl

Download URL nwqlib-1.0.2-py3-none-any.whl
Size 2.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
0ef32e3fef3c801aeba24d159cca4b78fc7fcd91f198b74c45cce143b19d9f89
BLAKE2b-256 checksum
How to use checksums
d1105c6f3f7bc587233cd0f6ece56bc125b28007554e7293ccb7de9aec52ec5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 7, 2026.

Transparency log
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