Skip to content

Benchmark

Benchmark base class.

Benchmark

Bases: BenchmarkPipeline

Abstract base class for generator/executor/analyzer benchmarks.

Subclasses must define the following class-level attributes: - generator, executor, analyzer: classes used during run() to generate circuits, execute them, and analyze results. - supported_adapters: tuple of adapter names (empty tuple = no restriction). - category: a BenchmarkCategory instance describing the benchmark category.

Implementations must override validate_params(self, params) to validate benchmark-specific parameters.

Optionally override validate_context to perform context-specific checks.

The run() method performs the common workflow: validate inputs, instantiate components, execute the benchmark, optionally run analysis, and return a BenchmarkResult.

Helper methods: - _instantiate_component(): ensures a component is a class and a subclass of the expected type, then instantiates it with the current context. - _validate_attributes(): verifies all required class attributes and types at subclass definition time.

run

run() -> PipelineResult

Run the benchmark pipeline.

validate_adapter

validate_adapter(adapter_name: str) -> None

Validate that the adapter is supported.

validate_context

validate_context(context: RunContext) -> None

Validate the run context.

validate_params abstractmethod

validate_params(params: Dict[str, Any]) -> None

Validate benchmark parameters.