This directory contains runnable Python examples demonstrating Divi's capabilities. Each example is self-contained and can be run independently.
To run any example, point Python at the file from the repo root:
python tutorials/optimization/qaoa_graph_problems.pyTutorials that use get_backend() from _backend.py accept these CLI flags:
| Flag | Backend | Description |
|---|---|---|
--local-qiskit (default) |
QiskitSimulator |
Local Qiskit Aer simulation |
--local-maestro |
MaestroSimulator |
Local Maestro orchestration |
--cloud-maestro |
QoroService |
Qoro cloud backend |
--force-sampling |
— | Disable exact expectation values; use shot-based sampling instead |
python tutorials/optimization/qaoa_graph_problems.py --local-qiskit
python tutorials/optimization/qaoa_graph_problems.py --cloud-maestro
python tutorials/optimization/qaoa_graph_problems.py --local-qiskit --force-samplingtutorials/
├── optimization/ QAOA / PCE / partitioning on QUBO and graph problems
├── routing/ Constraint-Enhanced QAOA on TSP and CVRP
├── chemistry/ VQE on molecular Hamiltonians
├── dynamics/ Hamiltonian time evolution and trajectories
├── error_mitigation/ ZNE / QuEPP wrapped around a VQA loop
├── visualization/ Loss-landscape and parameter-space analysis tools
├── advanced/ BYO circuits, custom optimization, checkpointing
└── backends/ Qoro cloud and Qiskit backend integration
Two scaling axes: solver choice (QAOA vs PCE) and problem size (single program vs partitioned ensemble).
qubo_qaoa_vs_pce.py— Solving the same QUBO with QAOA and PCE side by sideqaoa_hubo.py— QAOA for Higher-Order Binary Optimization (HUBO) problemsqaoa_partitioning.py— Partition a large problem into many sub-programs (graph, QUBO, and edge-based entry points)qaoa_graph_problems.py— QAOA on max clique and max-weight matchingqaoa_qdrift.py— QAOA with QDrift randomized Trotterizationiterative_qaoa.py— Iterative QAOA with parameter interpolation vs standard QAOA
ce_qaoa_routing.py— Constraint-Enhanced QAOA on TSP (grid search → parameter transfer → repair) and CVRP (one-hot vs binary encoding, qubit projections, VRP file parser)
vqe_h2_molecule.py— VQE on H2: basic run plus grouping-strategy and shot-allocation comparisonsvqe_hyperparameter_sweep.py— Hyperparameter sweeps across multiple molecules
time_evolution.py— Hamiltonian time evolution: probabilities, observables, multi-observable groups, QDrift, and trajectories over many time points
error_mitigation.py— VQE with Zero Noise Extrapolation (ZNE) and probabilistic error amplification
viz_qaoa_pce_comparison.py— Compare QAOA and PCE loss landscapes: 1D scans, 2D scans, PCA scans with trajectory overlayviz_advanced_analysis.py— Interpolation scans, Hessian eigenvalue analysis, Fourier power spectra, gradient overlays, 3D surface plots, NEB minimum-energy paths
Escape hatches for users who need to step outside the built-in algorithm classes: run circuits without a QuantumProgram, plug your own circuit into a VQA loop, or save and resume long-running optimizations.
standalone_pipeline.py— One-shot execution of PennyLane / Qiskit circuits throughCircuitPipelinedirectly (noQuantumProgramwrapper, no optimization loop)custom_vqa.py— Full variational optimization over a user-supplied parametric circuit viaCustomVQAcheckpointing.py— Save and resume optimization runs
qasm_thru_service.py— Submit raw QASM circuits to the Qoro cloudcharacterize_maxcut_qubo.py— Skip optimization via the Qoro Characterization Servicebackend_properties_conversion.py— Converting QiskitBackendPropertiesto aBackendV2
All examples require Divi to be installed:
pip install qoro-diviFor comprehensive documentation and detailed explanations, see the User Guide.
When adding new examples:
-
Drop the file into the folder that matches its primary topic (or open a new folder if it's a genuinely new category that maps to a user-guide page).
-
Keep examples focused and self-contained.
-
Add clear docstrings explaining the example's purpose.
-
Include expected output in comments.
-
Update this README with a brief description under the right folder section.
-
Register in
_ci_runner.py: All tutorials are executed in CI to catch regressions — if a code change breaks a tutorial, the pipeline fails. To keep CI fast, tutorials run with reduced parameters (fewer iterations, smaller problems, lower shots). The runner copies tutorials to a temp directory, applies string patches, and runs them in parallel with per-tutorial timeouts.Every non-underscore
.pyfile must appear in exactly one of these three lists (validated at startup), keyed by its path relative totutorials/(e.g."optimization/qaoa_hubo.py"):SKIP— tutorials that cannot run in CI (e.g. need API keys)NO_PATCHES— tutorials that run as-is (shots capped byDIVI_CI_MAX_SHOTS)TUTORIALS— tutorials that need source patches (e.g. fewer iterations, smaller problems) and/or custom timeouts