Quantum Resource Manager and Compiler Infrastructure (QRM&CI) 0.1.0
CircuitFormatPolicy.h File Reference
Include dependency graph for CircuitFormatPolicy.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  mqss::qrmci::CompilerTarget
 One deterministic compilation target: the mqss-ci ResultFormat the compiler must be asked to emit, the exact protocol CircuitFormat that output is submitted as, and the canonical task circuit-file type label a successfully compiled task should carry afterward. More...

Functions

mqss::CircuitFormat mqss::qrmci::mapTaskCircuitTypeToCircuitFormat (const std::string &format) noexcept
 Translate a task circuit type into its one direct circuit format, for no-modify submission or for a task's already-canonical circuit_file_type after a successful compilation.
std::expected< CompilerTarget, Error > mqss::qrmci::chooseCompilerTarget (std::span< const mqss::CircuitFormat > backendFormats)
 Choose the one compiler target a backend's supported circuit formats make available.
bool mqss::qrmci::canPrepareTaskForBackend (const mqss::QuantumTask &task, std::span< const mqss::CircuitFormat > backendFormats)
 Check whether a task can be prepared – directly submitted or compiled – for a backend supporting backendFormats.
std::expected< void, Error > mqss::qrmci::validateInputFormatIsSupportedCircuitFormat (std::string_view circuitFileFormat, std::span< const std::string_view > supportedInputFormats)
 Check that a task's circuit file format has a known mapping to one of the compiler's supported input formats.

Detailed Description

The one policy that decides whether a task is directly submittable or compilable for a backend, and which concrete circuit format and compiler result format that choice means.

Kept separate from ConstantsMapping.h: this is task/compiler/backend admission policy, not a translation between two enumerations.

Definition in file CircuitFormatPolicy.h.

Function Documentation

◆ canPrepareTaskForBackend()

bool mqss::qrmci::canPrepareTaskForBackend ( const mqss::QuantumTask & task,
std::span< const mqss::CircuitFormat > backendFormats )
nodiscard

Check whether a task can be prepared – directly submitted or compiled – for a backend supporting backendFormats.

A no_modify task must already resolve, via mapTaskCircuitTypeToCircuitFormat(), to one of backendFormats. Otherwise the task's circuit type must be a known compiler input format and backendFormats must yield a chooseCompilerTarget(). A task with no_modify=false and a non-compiler input therefore fails here, at admission, rather than later at compilation.

Parameters
taskThe task to check.
backendFormatsThe backend's own supported circuit formats.
Returns
True if the task is either directly submittable or compilable for a backend supporting backendFormats.

◆ chooseCompilerTarget()

std::expected< CompilerTarget, Error > mqss::qrmci::chooseCompilerTarget ( std::span< const mqss::CircuitFormat > backendFormats)
nodiscard

Choose the one compiler target a backend's supported circuit formats make available.

Checked in this fixed priority order – QASM2, QIRBASESTRING, QIRADAPTIVESTRING – never the module variants, since MQSS Compiler only ever returns textual bytes. The backend's own format list order has no effect on the outcome.

Parameters
backendFormatsThe backend's own supported circuit formats.
Returns
The one compiler target to compile for, or an UnsupportedFormat error if none of backendFormats is a compiler output.

◆ mapTaskCircuitTypeToCircuitFormat()

mqss::CircuitFormat mqss::qrmci::mapTaskCircuitTypeToCircuitFormat ( const std::string & format)
nodiscardnoexcept

Translate a task circuit type into its one direct circuit format, for no-modify submission or for a task's already-canonical circuit_file_type after a successful compilation.

An exhaustive, deterministic switch: qasm/qasm2 -> QASM2, qasm3 -> QASM3, qir/qirbase -> QIRBASESTRING, qiradaptive -> QIRADAPTIVESTRING, and quake/catalyst -> QIRBASESTRING for direct submission because these task circuit types have no distinct protocol wire-format enumerator.

Parameters
formatThe task circuit type to translate (e.g. "qasm3").
Returns
The matching mqss::CircuitFormat, or mqss::CircuitFormat::CIRCUIT_FORMAT_UNSPECIFIED if format has no known direct mapping.

◆ validateInputFormatIsSupportedCircuitFormat()

std::expected< void, Error > mqss::qrmci::validateInputFormatIsSupportedCircuitFormat ( std::string_view circuitFileFormat,
std::span< const std::string_view > supportedInputFormats )
nodiscard

Check that a task's circuit file format has a known mapping to one of the compiler's supported input formats.

Parameters
circuitFileFormatThe task's circuit file format.
supportedInputFormatsThe compiler's supported input formats.
Returns
Nothing on success, or an UnsupportedFormat error if circuitFileFormat is not a supported circuit format.