QuantumAlgoProtocol

class QuantumAlgoProtocol

Bases: Protocol

Protocol for quantum optimization algorithms.

Implement this protocol to define a custom algorithm compatible with any QuantumBaseClient subclass. A conforming class must declare acceptable_degrees, a Parameters class, and a static run() method.

Methods

__init__

run

Run the algorithm on the given model.

Attributes

Parameters

Configuration class for the algorithm.

acceptable_degrees

Polynomial degrees accepted by the algorithm's objective function.

__init__(*args, **kwargs)
static run(
sampler: SamplerProtocol[SamplingMeta_co, Any],
model: Model,
parameters: Any,
dry_run: Literal[False],
) CustomClientResultProtocol
static run(
sampler: SamplerProtocol[SamplingMeta_co, Any],
model: Model,
parameters: Any,
dry_run: Literal[True],
) None

Run the algorithm on the given model.

Parameters:
  • sampler (SamplerProtocol[SamplingMeta_co, Any]) – Backend sampler that executes quantum circuits.

  • model (Model) – The optimization model to solve.

  • parameters (Any) – Algorithm-specific configuration (e.g., QAOA.Parameters).

  • dry_run (bool) – If True, validate inputs without executing circuits and return None.

Returns:

The algorithm result, or None if dry_run is True.

Return type:

CustomClientResultProtocol | None

Parameters: Final[type]

Configuration class for the algorithm. Instances are passed to run() and to acceptable_degrees when it is a callable.

acceptable_degrees: Final[AcceptableDegrees | Callable[[Any], AcceptableDegrees]]

Polynomial degrees accepted by the algorithm’s objective function. Either a static AcceptableDegrees value, or a callable that takes a Parameters instance and returns one.