NWQLib¶
NWQLib applies quantum algorithms to scientific problems. You state the problem and choose a method, and NWQLib returns the computed quantity with the method, its resource counts and what is known about its error.
| Your scientific problem | Methods and first example |
|---|---|
Linear dynamics, du/dt = -A u |
LCHS, first result |
| Eigenvalues or phases of an operator | Lanczos, GCiM / ADAPT, QPE |
| Ground-state energy estimate of a molecule | GCiM / ADAPT chemistry inputs |
A linear system, Ax=b |
QLS |
| Optimization over a box | QHD |
| Optimization over a box with equality or inequality constraints | QHD augmented Lagrangian |
| The expectation of an observable | Expectation |
NWQLib requires Python 3.12 or later. Install it with the local Aer simulator:
python -m pip install "nwqlib[aer]"
Install and first result lists the other extras. This complete cell solves a two-coordinate linear differential equation:
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 nine-qubit Aer calculation returns the physical vector, including its scale and phase. Its finite approximation does not certify total error. Replace A, the initial state and the time to use your own input. Install and first result checks this answer against an independent reference and shows a finer construction.
Continue your workflow¶
| What you want to do | Where to start |
|---|---|
| Choose a problem and output | Choose a problem and output |
| Find a worked example for your problem | Examples and the method guides |
| Compare methods for the same scientific problem | Plan, compare and solve |
| Supply an operator or state | Supply inputs |
| Estimate qubits, gates and shots, or check device fit | Estimate resources, Check device fit and run time |
| Estimate what an algorithm would cost at 80 to 100 system qubits | Resource estimation notebook |
| Check a result against a reference or tolerance | Check accuracy and verify a result |
| Run on a backend or continue an interrupted run | Run on a backend, Continue an interrupted run |
| Save results and reanalyze observations | Save, load and reanalyze results |
| Run your own circuit or compare your own method | Run your own circuit |
| Use the command line or look up parameters | Use the command line, API reference |
| Learn what Problem, Method, Plan, Run and Result are | How NWQLib works |
| Compare NWQLib with other quantum packages | Why NWQLib |
| Understand limitations | Limitations and open work, the method's guide |
| 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 |
Each method guide defines its scientific quantities and assumptions and states what its results do not establish. References lists the cited literature.