Quantum Resource Manager and Compiler Infrastructure (QRM&CI) 0.1.0
mqss::qrmci::BackendWrapper Class Reference

A snapshot of one backend's capabilities: name, qubit count, status, supported instructions, qubit connectivity and circuit formats. More...

Public Member Functions

 BackendWrapper ()=default
 Default-construct an empty BackendWrapper.
 BackendWrapper (const BackendWrapper &)=default
 Copy-construct a BackendWrapper.
 BackendWrapper (BackendWrapper &&)=default
 Move-construct a BackendWrapper.
BackendWrapper & operator= (const BackendWrapper &)=default
 Copy-assign a BackendWrapper.
BackendWrapper & operator= (BackendWrapper &&)=default
 Move-assign a BackendWrapper.
mqss::Backend toBackend () const
 Build a backend-status message from this snapshot, for publication to other QRM&CI processes.
bool isOnline () const noexcept
 Check whether this backend is currently able to accept tasks.
bool canRun (const mqss::QuantumTask &task) const
 Check whether this backend can run a given task.
std::expected< CompilerTarget, Error > compilerTarget () const
 Find the one compiler target this backend's supported circuit formats make available, in CircuitFormatPolicy's fixed priority order.
const std::string & getName () const noexcept
 Get the backend name.
std::uint32_t getNumQubits () const noexcept
 Get the number of qubits supported by the backend.
mqss::BackendStatus getStatus () const noexcept
 Get the backend status.
const std::vector< std::string > & getInstructions () const noexcept
 Get the instructions supported by the backend.
const std::vector< std::pair< std::uint32_t, std::uint32_t > > & getQubitConnectivity () const noexcept
 Get the qubit connectivity of the backend.
const std::vector< mqss::CircuitFormat > & getSupportedCircuitFormats () const noexcept
 Get the circuit formats supported by the backend.
const std::string & getQueueName () const noexcept
 Get the backend's dispatch queue name.

Static Public Member Functions

static std::expected< BackendWrapper, Error > fromSubmitter (const mqss::submitter::Device &device, std::string_view dispatchQueue="")
 Read a backend's capabilities from a live device.
static std::expected< BackendWrapper, Error > fromPublishedStatus (const mqss::Backend &backend)
 Build a validated snapshot from a published backend-status message.

Friends

class mqss::qrmci::test::BackendBuilder

Detailed Description

A snapshot of one backend's capabilities: name, qubit count, status, supported instructions, qubit connectivity and circuit formats.

The snapshot is read either from a live device through mqss::submitter::Device or from an mqss::Backend status message, and it answers the three questions the pipeline asks of a backend: whether it is online, whether it can run a given task, and which compiler result format to target for it. It is a value with no setters – refreshing a backend means building a new snapshot.

Definition at line 51 of file BackendWrapper.h.

Member Function Documentation

◆ canRun()

bool mqss::qrmci::BackendWrapper::canRun ( const mqss::QuantumTask & task) const
nodiscard

Check whether this backend can run a given task.

Parameters
taskThe task to check.
Returns
True if the backend has enough qubits and supports a circuit format compatible with the task's circuit file type.

◆ compilerTarget()

std::expected< CompilerTarget, Error > mqss::qrmci::BackendWrapper::compilerTarget ( ) const
nodiscard

Find the one compiler target this backend's supported circuit formats make available, in CircuitFormatPolicy's fixed priority order.

Returns
The compiler target to compile for, or an UnsupportedFormat error if none of this backend's formats is a compiler output.

◆ fromPublishedStatus()

std::expected< BackendWrapper, Error > mqss::qrmci::BackendWrapper::fromPublishedStatus ( const mqss::Backend & backend)
staticnodiscard

Build a validated snapshot from a published backend-status message.

The one way a published status becomes a BackendWrapper outside test code, so production can never schedule onto a backend whose status was malformed. Required routing strings (name, dispatch queue) must be non-empty; the three wire enum families (type, status, circuit formats) each normalize an enumerator this build does not know to their *_UNSPECIFIED value rather than propagating an out-of-range value, the same way mapProtoCircuitFormat() already did for circuit formats alone.

Parameters
backendThe received backend status.
Returns
The validated wrapper, or a MessagingFailed error naming the invalid field.

◆ fromSubmitter()

std::expected< BackendWrapper, Error > mqss::qrmci::BackendWrapper::fromSubmitter ( const mqss::submitter::Device & device,
std::string_view dispatchQueue = "" )
staticnodiscard

Read a backend's capabilities from a live device.

A factory rather than a constructor because any of the five device property queries can fail, and a constructor has nowhere to report that – it could only leave behind a half-populated wrapper that still looks usable. The device ID is read too, but it is a plain accessor on Device rather than a fallible query.

Parameters
deviceThe device to read.
dispatchQueueThe queue tasks assigned to this backend should be sent to, carried through to getQueueName()/toBackend() for a caller that publishes this snapshot. Left empty for a caller that never publishes – fromPublishedStatus() still rejects an empty queue on the receiving end, so this default is only safe for a process that never sends its own status out.
Returns
The populated wrapper, or the first query failure, wrapped as Error::Kind::DeviceError.

◆ getInstructions()

const std::vector< std::string > & mqss::qrmci::BackendWrapper::getInstructions ( ) const
inlinenodiscardnoexcept

Get the instructions supported by the backend.

Returns
The supported instructions.

Definition at line 140 of file BackendWrapper.h.

◆ getName()

const std::string & mqss::qrmci::BackendWrapper::getName ( ) const
inlinenodiscardnoexcept

Get the backend name.

Returns
The backend name.

Definition at line 126 of file BackendWrapper.h.

◆ getNumQubits()

std::uint32_t mqss::qrmci::BackendWrapper::getNumQubits ( ) const
inlinenodiscardnoexcept

Get the number of qubits supported by the backend.

Returns
The number of qubits.

Definition at line 129 of file BackendWrapper.h.

◆ getQubitConnectivity()

const std::vector< std::pair< std::uint32_t, std::uint32_t > > & mqss::qrmci::BackendWrapper::getQubitConnectivity ( ) const
inlinenodiscardnoexcept

Get the qubit connectivity of the backend.

Returns
The qubit connectivity as a list of connected qubit index pairs.

Definition at line 147 of file BackendWrapper.h.

◆ getQueueName()

const std::string & mqss::qrmci::BackendWrapper::getQueueName ( ) const
inlinenodiscardnoexcept

Get the backend's dispatch queue name.

Returns
The name of the queue tasks assigned to this backend are sent to.

Definition at line 159 of file BackendWrapper.h.

◆ getStatus()

mqss::BackendStatus mqss::qrmci::BackendWrapper::getStatus ( ) const
inlinenodiscardnoexcept

Get the backend status.

Returns
The backend status.

Definition at line 134 of file BackendWrapper.h.

◆ getSupportedCircuitFormats()

const std::vector< mqss::CircuitFormat > & mqss::qrmci::BackendWrapper::getSupportedCircuitFormats ( ) const
inlinenodiscardnoexcept

Get the circuit formats supported by the backend.

Returns
The supported circuit formats.

Definition at line 153 of file BackendWrapper.h.

◆ isOnline()

bool mqss::qrmci::BackendWrapper::isOnline ( ) const
nodiscardnoexcept

Check whether this backend is currently able to accept tasks.

Returns
True if the backend's status counts as online.

◆ toBackend()

mqss::Backend mqss::qrmci::BackendWrapper::toBackend ( ) const
nodiscard

Build a backend-status message from this snapshot, for publication to other QRM&CI processes.

The inverse of BackendWrapper(const mqss::Backend &).

Returns
The backend status to publish.

◆ mqss::qrmci::test::BackendBuilder

friend class mqss::qrmci::test::BackendBuilder
friend

Definition at line 174 of file BackendWrapper.h.


The documentation for this class was generated from the following file: