Overview

Algorithms translate a Problems into circuits, run those circuits (through the state-vector engine or an ExecutionRuntime), and return typed, serializable results.

Uniform lifecycle

Every built-in algorithm follows the base contract from Algorithm:

from microquantum import SearchProblem
from microquantum.algorithms import GroverSearch

problem = SearchProblem(num_qubits=2, target=[1])
algorithm = GroverSearch.from_problem(problem)
diagnostics = algorithm.validate(problem)   # list[str], [] when valid
result = algorithm.solve(problem, runtime=None)

solve accepts an optional ExecutionRuntime — when one is provided every circuit evaluation (prepare -> compile -> submit -> collect) is routed through the MQ-04 pipeline; otherwise the internal state-vector engine is used directly.

Result types

Results are *Result dataclasses subclassing AlgorithmResult (or its companion typed containers). Each carries the algorithm name, the solved problem, the outcome, optimizer info and free-form config / execution_metadata / native payloads. All serialize through to_dict() / to_json().

Classic-convention algorithms

A few older algorithms (AdaptVQE, VQD, oracles) still expose the classic compute_minimum_eigenvalue() / run() entry points, but they return the same serializable result shapes.