Skip to content

Repository files navigation

Divi

Generate, parallelize, and execute quantum programs at scale.

PyPI Python Docs License Code style: black Checked with pyrefly


Divi is a Python library by Qoro Quantum for building and running quantum programs at scale. It handles circuit generation, job parallelization, and cloud execution — with built-in support for variational algorithms, custom workflows, and more — so you can focus on the quantum problem, not the plumbing.

Important

Divi is under active development. Expect breaking changes between minor versions.

Tip

Using Claude Code, Cursor, or another LLM coding agent? Divi is indexed on Context7 — point your agent at /qoroquantum/divi to pull current, version-specific Divi docs and snippets directly into its context.

⚡ At-Scale Example

For the shortest introduction, start with the five-minute tutorial.

pip install qoro-divi

Nightly Builds

To install the latest development build (published daily from main):

pip install qoro-divi --pre

Split a graph into quantum-sized MaxCut problems, solve the partitions, and stitch their candidates into a global solution:

import networkx as nx

from divi.backends import MaestroSimulator
from divi.qprog import BeamSearchStrategy
from divi.qprog.optimizers import ScipyOptimizer, ScipyMethod
from divi.qprog.problems import GraphPartitioningConfig, MaxCutProblem
from divi.qprog.workflows import PartitioningProgramEnsemble

graph = nx.barbell_graph(4, 0)
problem = MaxCutProblem(
    graph,
    config=GraphPartitioningConfig(
        max_n_nodes_per_cluster=4,
        partitioning_algorithm="kernighan_lin",
    ),
)

backend = MaestroSimulator()
ensemble = PartitioningProgramEnsemble(
    problem=problem,
    n_layers=1,
    backend=backend,
    optimizer=ScipyOptimizer(method=ScipyMethod.COBYLA),
    max_iterations=10,
    seed=42,
)

ensemble.run()
cut, _ = ensemble.aggregate_results(
    strategy=BeamSearchStrategy(beam_width=3, n_partition_candidates=5)
)
print(f"Cut edges: {nx.cut_size(graph, cut)}")
print(f"Circuits executed: {ensemble.total_circuit_count}")

PartitioningProgramEnsemble handles decomposition, parallel execution, and candidate aggregation while each partition remains small enough for the chosen backend.

🌐 Cloud Execution with Qoro Service

Run the same workflow on Qoro's cloud platform by swapping only the backend:

from divi.backends import QoroService

backend = QoroService()  # reads QORO_API_KEY from .env or environment

Get started for free → Sign up at dash.qoroquantum.net and receive $100 worth of credits to run your first quantum programs on our cloud.

🤖 divi-ai: AI Coding Assistant

Ask questions about Divi directly in your terminal — no API keys, no internet required after setup.

pip install qoro-divi[ai]
divi-ai

Answers questions about Divi APIs, generates code examples, and explains concepts — powered by a local LLM that runs entirely on your machine. See the full documentation for model options and usage.

🧩 Key Features

Feature Description
VQE & QAOA Built-in variational algorithms with pluggable ansätze and optimizers
Circuit Pipelines Expand → execute → reduce pattern for complex circuit workflows
Program Ensembles Parallel execution of multiple quantum programs with automatic scheduling, over one round or many adaptive ones
Flexible Backends MaestroSimulator for local simulation, QiskitSimulator for Qiskit-native noise models, QoroService for cloud execution
Execution Config Control bond dimension, simulator type, and simulation method per job
Live Reporting Real-time dashboards and convergence tracking via callbacks

🏗️ Architecture

divi/
├── qprog/        # Quantum programs: VQE, QAOA, base classes, optimizers
├── backends/     # Execution backends: MaestroSimulator, QiskitSimulator, QoroService
├── circuits/     # MetaCircuit templates and Circuit instances
├── pipeline/     # Circuit pipeline stages (expand, execute, reduce)
├── hamiltonians  # Molecular Hamiltonian generation
├── reporting/    # Live reporting and visualization callbacks
└── ai/           # Offline documentation chatbot (divi-ai)

📚 Documentation

Algorithm guides, execution guides, and API reference: divi.readthedocs.io

Hands-on examples are in the tutorials/ folder.

Contributing

Contributions are welcome! See CONTRIBUTING.md for development setup, testing, and code style guidelines.

📄 License

Apache 2.0 — see LICENSE for details.

About

A Python library to automate generating, parallelizing, and executing quantum programs.

Topics

Resources

Code of conduct

Contributing

Stars

23 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages