Quantum Resource Manager and Compiler Infrastructure (QRM&CI) 0.1.0
Daemon.h File Reference
Include dependency graph for Daemon.h:

Typedefs

using mqss::qrmci::TaskScheduler = mqss::scheduler::Scheduler<mqss::QuantumTask>
 The scheduler every daemon that submits work runs its tasks through.

Functions

void mqss::qrmci::installTerminationHandlers ()
 Register SIGINT and SIGTERM handlers that set terminationRequested.
std::expected< Config, Error > mqss::qrmci::initializeDaemon ()
 Bring a daemon process up: install the SIGINT/SIGTERM handlers, assemble the configuration, and make the daemon logger the process-wide default.
std::expected< mqss::submitter::Device, Error > mqss::qrmci::openConfiguredDevice (const SubmitterConfig &config)
 Open the QDMI device config names.
std::expected< void, Error > mqss::qrmci::registerOwnDevice (const mqss::submitter::Device &device, BackendRegistry &backends, std::string_view dispatchQueue="")
 Read this process's own device and register it, so the daemon has a backend to schedule onto before its work loop starts.
std::optional< mqss::Backend > mqss::qrmci::refreshOwnDeviceStatus (const mqss::submitter::Device &device, BackendRegistry &backends, PublicationThrottle &throttle, std::string_view dispatchQueue="")
 Re-read this process's own device and refresh its registry entry, if throttle has a publish slot due.
void mqss::qrmci::logRegisteredBackends (const BackendRegistry &backends)
 Log every registered backend and its capabilities at info level.
std::expected< void, Error > mqss::qrmci::selectCompileAndSchedule (mqss::QuantumTask &task, const BackendRegistry &backends, mqss::mqssci::MQSSCompiler &compiler, TaskScheduler &scheduler, BackendSelectionPolicy policy=BackendSelectionPolicy::LowestName)
 Select a backend for task, compile it for that backend, and hand it to scheduler.
std::expected< void, Error > mqss::qrmci::compileAndSchedule (mqss::QuantumTask &task, const BackendRegistry &backends, mqss::mqssci::MQSSCompiler &compiler, TaskScheduler &scheduler)
 Compile task for the backend it was already assigned and hand it to scheduler.

Variables

constinit std::atomic< bool > mqss::qrmci::terminationRequested {false}
 Set to true once SIGINT or SIGTERM has been received.

Detailed Description

The scaffolding every QRM&CI daemon entrypoint shares: process bring-up, opening the configured QDMI device, and the compile-and-schedule stage.

Definition in file Daemon.h.

Typedef Documentation

◆ TaskScheduler

using mqss::qrmci::TaskScheduler = mqss::scheduler::Scheduler<mqss::QuantumTask>

The scheduler every daemon that submits work runs its tasks through.

Definition at line 33 of file Daemon.h.

Function Documentation

◆ compileAndSchedule()

std::expected< void, Error > mqss::qrmci::compileAndSchedule ( mqss::QuantumTask & task,
const BackendRegistry & backends,
mqss::mqssci::MQSSCompiler & compiler,
TaskScheduler & scheduler )
nodiscard

Compile task for the backend it was already assigned and hand it to scheduler.

Parameters
taskThe task to compile, mutated in place. Its scheduled QPU names the backend to compile for.
backendsThe registry the scheduled QPU is looked up in.
compilerThe compiler to compile with.
schedulerThe scheduler to hand the compiled task to.
Returns
Nothing on success, a NoBackendAvailable error if the scheduled QPU is not registered with this process, or the compiler's own error.

◆ initializeDaemon()

std::expected< Config, Error > mqss::qrmci::initializeDaemon ( )
nodiscard

Bring a daemon process up: install the SIGINT/SIGTERM handlers, assemble the configuration, and make the daemon logger the process-wide default.

Returns
The assembled configuration, or the ConfigError explaining why it could not be assembled. Nothing is logged and no logger is installed on failure; the caller reports it and exits.

◆ installTerminationHandlers()

void mqss::qrmci::installTerminationHandlers ( )
inline

Register SIGINT and SIGTERM handlers that set terminationRequested.

Called by initializeDaemon(), before constructing anything that should observe a clean shutdown.

Definition at line 45 of file Daemon.h.

◆ logRegisteredBackends()

void mqss::qrmci::logRegisteredBackends ( const BackendRegistry & backends)

Log every registered backend and its capabilities at info level.

Parameters
backendsThe registry to list.

◆ openConfiguredDevice()

std::expected< mqss::submitter::Device, Error > mqss::qrmci::openConfiguredDevice ( const SubmitterConfig & config)
nodiscard

Open the QDMI device config names.

The driver's QDMI version is detected from the driver itself, so nothing about it is declared here. An empty client token or device ID in the configuration means "unset" rather than "empty string", which is the one subtlety this wrapper exists to keep in a single place.

Parameters
configThe submitter configuration naming the driver and device.
Returns
The opened device, or a DriverUnavailable error explaining why it could not be opened.

◆ refreshOwnDeviceStatus()

std::optional< mqss::Backend > mqss::qrmci::refreshOwnDeviceStatus ( const mqss::submitter::Device & device,
BackendRegistry & backends,
PublicationThrottle & throttle,
std::string_view dispatchQueue = "" )

Re-read this process's own device and refresh its registry entry, if throttle has a publish slot due.

A device that cannot be read is a warning, not a fatal error: the entry's own time-to-live already governs how long a stale snapshot may stand, and a device that recovers is picked up on the next slot. Nothing is published from here either – a caller that publishes its status does so with the returned snapshot, so a failing device says nothing at all rather than announcing itself healthy.

Parameters
deviceThe device to re-read.
backendsThe registry holding this process's own entry.
throttleThe throttle pacing this process's own publication slots.
dispatchQueueThe queue tasks assigned to this backend should be sent to, forwarded to BackendWrapper::fromSubmitter(). Left empty for a process that never publishes its own status.
Returns
The refreshed status to publish, or nullopt if no slot was due or the device could not be read.

◆ registerOwnDevice()

std::expected< void, Error > mqss::qrmci::registerOwnDevice ( const mqss::submitter::Device & device,
BackendRegistry & backends,
std::string_view dispatchQueue = "" )
nodiscard

Read this process's own device and register it, so the daemon has a backend to schedule onto before its work loop starts.

Parameters
deviceThe device to read.
backendsThe registry to insert the device's status into.
dispatchQueueThe queue tasks assigned to this backend should be sent to, forwarded to BackendWrapper::fromSubmitter(). Left empty for a process that never publishes its own status.
Returns
Nothing on success, or the DeviceError explaining why the device could not be read – a daemon has nothing to offer if it cannot read its own device once, so the caller exits on failure.

◆ selectCompileAndSchedule()

std::expected< void, Error > mqss::qrmci::selectCompileAndSchedule ( mqss::QuantumTask & task,
const BackendRegistry & backends,
mqss::mqssci::MQSSCompiler & compiler,
TaskScheduler & scheduler,
BackendSelectionPolicy policy = BackendSelectionPolicy::LowestName )
nodiscard

Select a backend for task, compile it for that backend, and hand it to scheduler.

The standalone daemon's whole intake stage. task is left with its scheduled QPU assigned and its circuits compiled on success, and untouched past the point of failure otherwise.

Parameters
taskThe task to prepare, mutated in place.
backendsThe backends to choose from.
compilerThe compiler to compile with.
schedulerThe scheduler to hand the compiled task to.
policyThe rule for picking among several compatible backends.
Returns
Nothing on success, or the error from whichever step failed.

Variable Documentation

◆ terminationRequested

std::atomic<bool> mqss::qrmci::terminationRequested {false}
inlineconstinit

Set to true once SIGINT or SIGTERM has been received.

A daemon's main loop and CommunicationHandler::receive() both consult this to unwind promptly instead of finishing whatever bounded wait or drain they were already in.

Definition at line 39 of file Daemon.h.