Validation Suite

The cases and what they check are described in Validation Gallery.

Validation suite: textbook problems with known answers.

Every case solves a small open-quantum-system problem whose answer is known independently of this library (a closed formula, an exactly solvable rate equation, a higher-accuracy reference solve, or QuTiP) and reports one number: how far the solver is from that answer, next to the tolerance it must meet.

Run the suite and write a report with:

oqs validate --output-dir validation-report

or from Python:

import openquantumsim.validation as validation
report = validation.run_validation()
print(report.to_markdown())

The same cases back tests/physics/test_validation_suite.py, so a release cannot pass its tests without also passing its validation report.

class openquantumsim.validation.ValidationCase(name, title, category, solver, reference, metric, tolerance, run)[source]

Bases: object

One problem with a known answer.

Parameters:
  • name (str)

  • title (str)

  • category (str)

  • solver (str)

  • reference (str)

  • metric (str)

  • tolerance (float)

  • run (Callable[[], tuple[float, str]])

class openquantumsim.validation.ValidationOutcome(case, status, measured, wall_time, detail='')[source]

Bases: object

Result of running one ValidationCase.

Parameters:
  • case (ValidationCase)

  • status (str)

  • measured (float | None)

  • wall_time (float)

  • detail (str)

property passed: bool

Whether the case met its tolerance.

class openquantumsim.validation.ValidationReport(outcomes, environment)[source]

Bases: object

Outcomes of a validation run together with the environment it ran in.

Parameters:
property passed: bool

Whether no case failed or errored. Skipped cases do not fail.

counts()[source]

Number of cases per status.

Return type:

dict[str, int]

to_dict()[source]

Return a JSON-serialisable description of the report.

Return type:

dict[str, Any]

to_markdown()[source]

Render the report as a Markdown document.

Return type:

str

write(output_dir)[source]

Write validation_report.md and .json; return both paths.

Parameters:

output_dir (str | Path)

Return type:

tuple[Path, Path]

exception openquantumsim.validation.ValidationSkipped[source]

Bases: Exception

A case could not run because an optional dependency is missing.

openquantumsim.validation.run_validation(names=None, *, progress=None)[source]

Run the validation cases and collect a report.

names restricts the run to the given case names. progress is called with each outcome as soon as it is available.

Parameters:
Return type:

ValidationReport

openquantumsim.validation.validation_cases()[source]

Return every validation case, in report order.

Return type:

list[ValidationCase]