Quantum Resource Manager and Compiler Infrastructure (QRM&CI) 0.1.0
BackendWrapper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2026 MQSS Maintainers
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 */
7
12
13#pragma once
14
15#include "mqss/Protocol.hpp"
18#include "qrmci/Error.h"
19
20#include <MQSSCIInterfaces/MQSSCompiler.h>
21#include <algorithm>
22#include <cstddef>
23#include <cstdint>
24#include <expected>
25#include <iterator>
26#include <string>
27#include <string_view>
28#include <utility>
29#include <vector>
30
31namespace mqss::submitter {
32class Device;
33} // namespace mqss::submitter
34
35namespace mqss::qrmci::test {
36class BackendBuilder;
37} // namespace mqss::qrmci::test
38
39namespace mqss::qrmci {
40
52
53public:
55 BackendWrapper() = default;
57 BackendWrapper(const BackendWrapper &) = default;
64
81 [[nodiscard]] static std::expected<BackendWrapper, Error>
82 fromSubmitter(const mqss::submitter::Device &device,
83 std::string_view dispatchQueue = "");
84
98 [[nodiscard]] static std::expected<BackendWrapper, Error>
99 fromPublishedStatus(const mqss::Backend &backend);
100
105 [[nodiscard]] mqss::Backend toBackend() const;
106
109 [[nodiscard]] bool isOnline() const noexcept;
110
115 [[nodiscard]] bool canRun(const mqss::QuantumTask &task) const;
116
122 [[nodiscard]] std::expected<CompilerTarget, Error> compilerTarget() const;
123
126 [[nodiscard]] const std::string &getName() const noexcept { return name; }
129 [[nodiscard]] std::uint32_t getNumQubits() const noexcept {
130 return numQubits;
131 }
132
134 [[nodiscard]] mqss::BackendStatus getStatus() const noexcept {
135 return status;
136 }
137
139 [[nodiscard]] const std::vector<std::string> &
140 getInstructions() const noexcept {
141 return instructions;
142 }
143
146 [[nodiscard]] const std::vector<std::pair<std::uint32_t, std::uint32_t>> &
147 getQubitConnectivity() const noexcept {
148 return qubitConnectivity;
149 }
150
152 [[nodiscard]] const std::vector<mqss::CircuitFormat> &
153 getSupportedCircuitFormats() const noexcept {
154 return supportedCircuitFormats;
155 }
156
159 [[nodiscard]] const std::string &getQueueName() const noexcept {
160 return queueName;
161 }
162
163private:
172 explicit BackendWrapper(const mqss::Backend &backend);
173
174 friend class mqss::qrmci::test::BackendBuilder;
175
176 std::string name;
177 std::uint32_t numQubits{};
178 mqss::BackendType type{};
179 mqss::BackendStatus status{};
180 std::uint32_t queueLength{};
181 float currentLoad{};
182 std::string queueName;
183 std::vector<std::string> instructions;
184 std::vector<std::pair<std::uint32_t, std::uint32_t>> qubitConnectivity;
185 std::vector<mqss::CircuitFormat> supportedCircuitFormats;
186};
187} // namespace mqss::qrmci
The one policy that decides whether a task is directly submittable or compilable for a backend,...
Pure translations between the submitter, mqss protocol and mqss-ci enumerations: status,...
The error type every std::expected in QRM&CI's public interfaces carries.
bool canRun(const mqss::QuantumTask &task) const
Check whether this backend can run a given task.
BackendWrapper & operator=(const BackendWrapper &)=default
Copy-assign a BackendWrapper.
const std::vector< std::string > & getInstructions() const noexcept
Get the instructions supported by the backend.
bool isOnline() const noexcept
Check whether this backend is currently able to accept tasks.
static std::expected< BackendWrapper, Error > fromPublishedStatus(const mqss::Backend &backend)
Build a validated snapshot from a published backend-status message.
static std::expected< BackendWrapper, Error > fromSubmitter(const mqss::submitter::Device &device, std::string_view dispatchQueue="")
Read a backend's capabilities from a live device.
BackendWrapper(const BackendWrapper &)=default
Copy-construct a BackendWrapper.
BackendWrapper(BackendWrapper &&)=default
Move-construct a BackendWrapper.
std::uint32_t getNumQubits() const noexcept
Get the number of qubits supported by the backend.
std::expected< CompilerTarget, Error > compilerTarget() const
Find the one compiler target this backend's supported circuit formats make available,...
BackendWrapper()=default
Default-construct an empty BackendWrapper.
mqss::Backend toBackend() const
Build a backend-status message from this snapshot, for publication to other QRM&CI processes.
const std::vector< std::pair< std::uint32_t, std::uint32_t > > & getQubitConnectivity() const noexcept
Get the qubit connectivity of the backend.
BackendWrapper & operator=(BackendWrapper &&)=default
Move-assign a BackendWrapper.
const std::string & getQueueName() const noexcept
Get the backend's dispatch queue name.
mqss::BackendStatus getStatus() const noexcept
Get the backend status.
const std::vector< mqss::CircuitFormat > & getSupportedCircuitFormats() const noexcept
Get the circuit formats supported by the backend.
const std::string & getName() const noexcept
Get the backend name.
One deterministic compilation target: the mqss-ci ResultFormat the compiler must be asked to emit,...
A failure reported by a QRM&CI operation: a kind the caller can act on, plus a human-readable detail ...
Definition Error.h:29