Pasqal-OCS integration
Copyright 2026 Pasqal, HPC Gridware GmbH and its contributors.
Go CLI for QRMI setup on Gridware Cluster Scheduler (GCS) and Open Cluster Scheduler (OCS).
In this workspace, the documented end-to-end path is OCS local validation with
Pasqal Cloud (EMU_FREE).
- End users:
- Submit jobs through OCS with
qsub -l qpu=EMU_FREE. - Start at:
docs/quickinstall-testing.md(sections 2 and 3).
- Submit jobs through OCS with
- Admins:
- Configure Gridware resource state and queue hooks.
- Start at:
docs/quickinstall-testing.md(primary admin runbook)setup-qrmi-supportsection below
- Developers:
- Work on adapter CLI and queue hook code.
- Start at:
src/cmd/gridware-adapter/main.gosrc/cmd/qrmi-ocs-prolog/main.c(legacy C hook)src/cmd/qrmi-ocs-epilog/main.c(legacy C hook)src/cmd/qrmi-ocs-prolog-go/main.go(Go port)src/cmd/qrmi-ocs-epilog-go/main.go(Go port)
qpu-resource
├── LICENSE
├── Makefile
├── README.md
├── consumable-issue.md
├── demo
│ └── qrmi
│ └── quickinstall.sh
├── docs
│ ├── plans/
│ └── quickinstall-testing.md
├── go.mod
├── go.sum
├── scripts
│ └── Dockerfile.hooks
├── src
│ ├── cmd
│ │ ├── gridware-adapter
│ │ │ └── main.go
│ │ ├── qrmi-ocs-epilog
│ │ │ └── main.c
│ │ ├── qrmi-ocs-epilog-go (Go port of the epilog hook)
│ │ │ └── main.go
│ │ ├── qrmi-ocs-prolog
│ │ │ └── main.c
│ │ └── qrmi-ocs-prolog-go (Go port of the prolog hook)
│ │ └── main.go
│ └── internal
│ ├── qrmi (cgo wrapper around libqrmi)
│ └── qrmiocs (scheduler-side plumbing, no cgo)
What is where:
src/cmd/gridware-adapter/main.go: adapter CLI (setup-qrmi-support,ensure-resource,configure-queue-hooks).src/cmd/qrmi-ocs-load-sensor/main.go: optional OCS Load Sensor for dynamic QPU readiness.src/cmd/qrmi-ocs-prolog/main.c: legacy OCS queue prolog hook (resource/env setup + acquire).src/cmd/qrmi-ocs-epilog/main.c: legacy OCS queue epilog hook (release + accounting fields).src/cmd/qrmi-ocs-prolog-go/main.go: Go port of the prolog hook (preferred for new deployments).src/cmd/qrmi-ocs-epilog-go/main.go: Go port of the epilog hook (preferred for new deployments).src/internal/qrmiocs: scheduler-side glue (env, paths, metadata TSV, RUST_LOG mapping). No cgo. Fully unit-tested.src/internal/qrmi: cgo wrapper aroundlibqrmi.so. Compiled only with-tags qrmi.scripts/Dockerfile.hooks: multi-stage Docker build that produces the Go hook binaries pluslibqrmi.so.Makefile:make build-go-hooks,make build-adapter,make test,make vet.docs/quickinstall-testing.md: admin runbook for quickinstall + validation.demo/qrmi/quickinstall.sh: runnable smoke commands for quick checks.go.modandgo.sum: Go module and dependency lock state.
The repository ships a Makefile that wraps the Docker-based build flows.
make build-adapter
# binary at bin/adapter/adapter
make build-load-sensor
# binary at bin/adapter/qrmi-ocs-load-sensorThe Go ports use cgo to link against libqrmi.so. The Docker build in
scripts/Dockerfile.hooks clones QRMI from upstream, builds the shared
library, then cgo-builds the Go binaries against it. Output is written
under bin/go-hooks/:
make build-go-hooks # builds against QRMI 0.26.3 by default
make build-go-hooks QRMI_REF=main # builds against QRMI mainOutputs in bin/go-hooks/:
qrmi-ocs-prologqrmi-ocs-epiloglibqrmi.so
The hook binaries embed rpath=$ORIGIN, so as long as libqrmi.so sits
beside them on the execution host they will resolve the library without
any LD_LIBRARY_PATH mangling.
The legacy C prolog/epilog under src/cmd/qrmi-ocs-prolog/ and
src/cmd/qrmi-ocs-epilog/ are kept until the Go ports are validated in
production. Build instructions for those are unchanged; see the
Build queue hooks section below.
make test # runs Go unit tests; no QRMI required (uses stub build)
make vetTwo C-harness tests in src/cmd/gridware-adapter
(TestPrologApplyBackendEnvUsesConfiguredValue,
TestEpilogStrictMetadataBehavior) compile the C hooks against qrmi.h.
Point QRMI_INCLUDE_DIR at a QRMI checkout, or check QRMI out next to this
repository (../qrmi). Without either, they fail with required path missing.
Admin prerequisite: run setup-qrmi-support once on the target OCS queue.
Submit a quick smoke job:
qsub -b y -terse -l qpu=EMU_FREE /bin/echo OCS_QRMI_OKFor a real Pasqal Cloud Pulser task, follow
docs/quickinstall-testing.md section 3.
Pasqal documents free emulator access in the Explorer Offer, including EMU_FREE:
Start from the portal:
Then get your project ID from the same "Join Pasqal Cloud" guide ("Find your project ID"), and configure credentials on submit/exec hosts:
mkdir -p ~/.pasqal
cat > ~/.pasqal/config <<'EOF'
username=<your_email>
password=<your_password_or_token_flow>
project_id=<your_project_id>
auth_endpoint=https://authenticate.pasqal.cloud/oauth/token
EOF
chmod 600 ~/.pasqal/configAdmin setup and verification details are in docs/quickinstall-testing.md.
The key operational model is:
- Scheduler resource:
qpuasSTRINGwith relop== - Consumable policy:
qpuis configured asNO(backend selector only) - Host assignment: one backend name per host (for example
qpu=EMU_FREE) - Optional capacity resource:
qpu_slotsasINT,<=,Consumable=JOB - Optional readiness resource:
qpu_readyasINT,<=,consumable=NO - Job request without Load Sensor:
-l qpu=<backend>(for example-l qpu=EMU_FREE) - Job request with Load Sensor:
-l qpu=<backend>,qpu_slots=1,qpu_ready=1
- Build and copy adapter binary to scheduler master (
/tmp/adapterin quickinstall flow). - Build and copy queue hooks +
libqrmi.soto scheduler master. - Run
setup-qrmi-supportto apply resource, host mapping, queue hooks, and reporting params in one command. - Verify
qsub -l qpu=<backend>succeeds.
Apply all required OCS-side QRMI setup in one command:
- ensure
qpucomplex entry (STRING,==,requestable=YES,consumable=NO) - set host
complex_valuesto one backend name per host - set queue
prologandepilog - ensure global
reporting_paramscontainsusage_patterns=qrmi:qrmi_*
The adapter installs the QRMI hooks as <hook-user>@<path> … $job_owner
procedures. OCS runs them as that account and passes the job owner's name.
--hook-user defaults to the cluster's admin_user from
$SGE_ROOT/$SGE_CELL/common/bootstrap, or root when it is none. The hooks
need that account for two reasons:
- They write the QRMI variables and the acquisition metadata into the job's
spool directory (
$SGE_JOB_SPOOL_DIR/environment), which OCS owns as its admin account. This applies to every QRMI resource type. - For Pasqal Local, the prolog opens a Warden session on behalf of the job
owner's UID and the epilog revokes it. Warden allows only administrators to
do that, so add the hook account's UID to Warden's
admin_users(0for root).
Because the hooks run privileged with the job's environment, they trust only the scheduler:
- The queue command starts them through
qrmi-ocs-launch(<hook-user>@<dir>/qrmi-ocs-launch --sge-root=… --sge-cell=… [--spool-root=…]… [--qmaster-port=…] [--execd-port=…] <hook> … $job_owner;--launchersets another path).setup-qrmi-supportwrites the launcher options from its ownSGE_ROOT,SGE_CELLand ports, and one--spool-rootfor the globalexecd_spool_dirand for each host-local override (qconf -sconf <host>). Run it again after setting a host-localexecd_spool_dir. The launcher is statically linked, so no dynamic loader reads the job's environment. It refuses to run, failing the job, whenLD_*orGLIBC_TUNABLESis set. Otherwise it changes to/and starts the hook with:JOB_ID,SGE_TASK_IDandSGE_JOB_SPOOL_DIRfrom OCS, validated (the spool directory must be the job's own…/active_jobs/<job>.<task>below one of the spool roots, without symbolic links);SGE_ROOT,SGE_CELLand the ports from its options;TZif it is a plain time zone name; a fixedPATH, the hook user'sHOMEand theClocale. Everything else is dropped:QRMI_*and<BACKEND>_QRMI_*settings, proxy and TLS trust variables,RUST_LOG(the hooks set it from--log-level), shell functions and the job owner'sHOME. The hooks repeat the loader check and the reset. Backend settings come only fromqrmi_config.jsonand the hook arguments. The hooks need no Pasqal Cloud credentials; the job reads the job owner's~/.pasqal/config. - The QRMI config path, the absolute
qstatpath (withqconfnext to it), the resource names and the log level are part of the administrator-owned queue command. - The prolog reads the job's hard request from
qstat -j(hard_resource_list, ormaster_hard_resource_listfor-scope master). Soft requests are ignored, and the backend must match the host'scomplex_values.
The launcher, hook binaries, qstat/qconf and their parent directories must
be writable only by administrators.
Exit codes follow OCS's prolog semantics: 0 when the job is set up or
requests no QPU, 100 (job error) when the request cannot be served, for
example a backend missing from qrmi_config.json, 99 (reschedule) when the
backend is temporarily unavailable, and 1 (queue error) only for host or
configuration problems. A failed release in the epilog is logged and recorded
in accounting (qrmi_release_failed), but the epilog still exits 0. OCS
deletes the job's spool directory after the job, so the epilog moves the
metadata file, which holds the acquisition token, to
<execd spool>/<host>/qrmi_failed_releases/<job>.<task>.tsv (directory mode
0700, owned by the hook user) for the administrator to release by hand.
./adapter setup-qrmi-support \
--hosts ocs-master,ocs-worker1,ocs-worker2 \
--host-value EMU_FREE \
--queue all.q \
--prolog /shared/gridware-adapter/bin/qrmi-ocs-prolog \
--epilog /shared/gridware-adapter/bin/qrmi-ocs-epilogOptional Load Sensor setup keeps capacity and readiness separate:
./adapter setup-qrmi-support \
--hosts ocs-master,ocs-worker1,ocs-worker2 \
--host-value PASQAL_LOCAL \
--queue all.q \
--prolog /shared/gridware-adapter/bin/qrmi-ocs-prolog \
--epilog /shared/gridware-adapter/bin/qrmi-ocs-epilog \
--enable-qpu-slots \
--qpu-slots-capacity 0 \
--enable-load-sensor \
--load-sensor-host ocs-master \
--load-sensor-path /shared/gridware-adapter/bin/qrmi-ocs-load-sensorUse --qpu-slots-capacity 0 for Warden-owned Pasqal Local slots. Use a
positive value only when OCS should own static host-local slot capacity.
For one statically configured backend shared by several hosts, add
--qpu-slots-scope global.
OCS stores load_sensor as an executable path. Put the configuration at
/etc/qrmi-ocs-load-sensor.yaml, or set QRMI_OCS_LOAD_SENSOR_CONFIG when
running the sensor manually. Load Sensor configuration:
load_sensor:
enabled: true
scope: global
resource_name: qpu_ready
slots_resource_name: qpu_slots
provider: warden
timeout_seconds: 3
warden:
base_url: http://127.0.0.1:8006
endpoint: /accessible
tls_verify: true
static:
ready: true
state_file: ""The static provider either returns static.ready or reads 0/1 from
static.state_file. It is a dummy readiness signal for paper/demo use and does
not represent Pasqal Cloud queue availability. The warden provider polls
GET /accessible, can report qpu_slots_available when Warden is configured
with qpu_slots_total, and fails closed on timeouts, HTTP errors, or malformed
responses.
The Load Sensor is an early scheduler filter only. The OCS prolog still calls
QRMI IsAccessible and Acquire, so a job can still be rejected at dispatch
time if another scheduler or user consumed the external QPU after OCS scheduled
the job.
For the Pasqal Local setup, including Warden, MUNGE, QRMI config, and the
readiness Load Sensor, see load_sensor.md.
Ensure the scheduler complex entry exists and set host complex_values.
Use STRING with one backend name per host:
./adapter ensure-resource \
--qconf qconf \
--hosts ocs-master,ocs-worker1,ocs-worker2 \
--host-value EMU_FREEIf hosts target different backends, run per host (or host group):
./adapter ensure-resource \
--hosts ocs-worker1 \
--host-value EMU_FREE
./adapter ensure-resource \
--hosts ocs-worker2 \
--host-value EMU_FREEConfigure prolog, epilog, and reporting_params.
./adapter configure-queue-hooks \
--queue all.q \
--prolog /shared/gridware-adapter/bin/qrmi-ocs-prolog \
--epilog /shared/gridware-adapter/bin/qrmi-ocs-epilogCompile against the QRMI C API (qrmi/qrmi.h) and shared library:
mkdir -p /shared/gridware-adapter/bin
gcc -Wall -Wextra -O2 \
-I/shared/qrmi \
-L/shared/qrmi/libqrmi-0.26.3 \
-Wl,-rpath,'$ORIGIN' \
-o /shared/gridware-adapter/bin/qrmi-ocs-prolog \
/shared/gridware-adapter/src/cmd/qrmi-ocs-prolog/main.c \
-lqrmi
gcc -Wall -Wextra -O2 \
-I/shared/qrmi \
-L/shared/qrmi/libqrmi-0.26.3 \
-Wl,-rpath,'$ORIGIN' \
-o /shared/gridware-adapter/bin/qrmi-ocs-epilog \
/shared/gridware-adapter/src/cmd/qrmi-ocs-epilog/main.c \
-lqrmi
cp /shared/qrmi/libqrmi-0.26.3/libqrmi.so /shared/gridware-adapter/bin/Hook behavior:
- Prolog reads granted scheduler resource, resolves one backend name, acquires QRMI token, and writes runtime variables into the job environment.
- Prolog reads the dispatched job's resource list from the administrator-configured
qstat -jcommand. - Acquisition metadata is stored only in the scheduler-owned job spool.
- Epilog reads acquisition metadata and releases tokens.
- Epilog expects exactly one metadata record; multiple records are treated as an error.
- Prolog publishes runtime
qrmi_*values in the job environment. - Epilog appends numeric
qrmi_*values into${SGE_JOB_SPOOL_DIR}/usageso they are captured byusage_patterns=qrmi:qrmi_*and appear inqacct/accounting JSON. - Typical runtime
qrmi_*variables from prolog:qrmi_resources: backend/resource names acquired by prolog.qrmi_resource_types: QRMI resource types for acquired backends.qrmi_prolog_status: prolog outcome (successorerror).
- Typical runtime error variable from prolog:
QRMI_PLUGIN_ERROR: prolog error text when a failure occurs.
- Typical accounting
qrmi_*fields inqacct/ accounting JSON:qrmi_acquired_count: number of acquired resources (published from epilog usage data).qrmi_release_total: number of non-empty metadata records seen before release handling (0or1in strict single-record mode).qrmi_release_success: number of successful releases in epilog.qrmi_release_failed: number of failed releases in epilog.qrmi_release_elapsed_seconds: epilog release-loop elapsed time.qrmi_epilog_status_code: epilog outcome as numeric code (1success,0error).
RUST_LOGcomes from--hook-log-level(names, or SGE debug levels mapped as2 -> error,3 -> info,4 -> debug,>=5 -> trace), not from the job environment.
This Gridware/OCS adapter mirrors core SPANK behavior in these areas:
- Loads backend settings from
qrmi_config.jsonand exports backend-prefixedQRMI_*variables. - Sets
RUST_LOGfrom the administrator's--hook-log-level. - Exports
QRMI_JOB_QPU_RESOURCESandQRMI_JOB_QPU_TYPESfor runtime compatibility. - Acquires in prolog and releases in epilog.
Intentional differences from Slurm SPANK:
- Single backend per job in this adapter model (
-l qpu=<backend>). - No comma-separated multi-backend request syntax.
- Keep queue hooks aligned with the single-backend scheduler model (
-l qpu=<backend>). - Use
make build-adapterandmake build-go-hooksfor the standard build flows; seeBuildabove. - Compile-check legacy C hook sources:
gcc -Wall -Wextra -fsyntax-only -I./qrmi src/cmd/qrmi-ocs-prolog/main.c
gcc -Wall -Wextra -fsyntax-only -I./qrmi src/cmd/qrmi-ocs-epilog/main.c- Run Go unit tests for the new hook plumbing without QRMI:
make test- Working on the cgo wrapper itself (
src/internal/qrmi)? Build with theqrmitag and the QRMI artifacts on hand:
CGO_ENABLED=1 \
CGO_CFLAGS="-I/path/to/qrmi" \
CGO_LDFLAGS="-L/path/to/qrmi -lqrmi -Wl,-rpath,\$ORIGIN" \
go build -tags qrmi ./src/cmd/qrmi-ocs-prolog-go- Runnable quickinstall demo commands:
demo/qrmi/quickinstall.sh - Full runbook:
docs/quickinstall-testing.md
- QRMI runtime config is expected at
/etc/qrmi/qrmi_config.jsonon submit and execution hosts. - OCS quickinstall containers should provide both
python3andpythoncommands.
Apache License 2.0. See LICENSE.