Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion demo/qrmi/etc/slurm/qrmi_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
"QRMI_PASQAL_CLOUD_PROJECT_ID": "",
"QRMI_PASQAL_CLOUD_AUTH_TOKEN": ""
}
},
{
"name": "PASQAL_LOCAL",
"type": "pasqal-local",
"environment": {
"QRMI_URL": "http://localhost:4207"
}
}
]
}
}
12 changes: 12 additions & 0 deletions demo/qrmi/jobs/run_local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

#SBATCH --job-name=pasqal_job
#SBATCH --output=/data/job_%j.out
#SBATCH --error=/data/job_%j.out
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --qpu=PASQAL_LOCAL

# Your script goes here
source /shared/pyenv/bin/activate
python /shared/qrmi/examples/pulser_backend/pasqal/send_pasqal_job_local.py
9 changes: 9 additions & 0 deletions demo/qrmi/slurm-docker-cluster/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@ If you are building locally for development it may be easier to build the QRMI f
[root@c1 /]# make
```

For pasqal-local resources make sure to build the spank plugin with munge support:
```bash
[root@c1 /]# cd /shared/spank-plugins/plugins/spank_qrmi
[root@c1 /]# mkdir build
[root@c1 /]# cd build
[root@c1 /]# cmake -DENABLE_MUNGE=ON ..
[root@c1 /]# make
```


5. Creating qrmi_config.json

Expand Down
26 changes: 22 additions & 4 deletions plugins/spank_qrmi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ endif()
# -DQRMI_ROOT=/path/to/qrmi Use local QRMI code.
# unset/empty QRMI_ROOT Fetch QRMI via ExternalProject on GitHub (default).
set(QRMI_ROOT "" CACHE PATH "Path to local qrmi checkout; leave empty to fetch from GitHub")
# Option to enable/disable Munge (required for pasqal-local usage)
option(ENABLE_MUNGE "Enable Munge support for Pasqal Local client" OFF)

if(ENABLE_MUNGE)
message(STATUS "Building QRMI with Munge support")
set(QRMI_BUILD_CMD cargo build --release --features munge)
else()
message(STATUS "Building QRMI WITHOUT Munge support")
set(QRMI_BUILD_CMD cargo build --release)
endif()

# -------------------------
# QRMI build type local vs GitHub
Expand All @@ -47,7 +57,7 @@ if(NOT "${QRMI_ROOT}" STREQUAL "")
SOURCE_DIR "${QRMI_SOURCE_DIR}"
PREFIX "${CMAKE_BINARY_DIR}/deps"
CONFIGURE_COMMAND ""
BUILD_COMMAND cargo build --release
BUILD_COMMAND ${QRMI_BUILD_CMD}
BUILD_IN_SOURCE 1
INSTALL_COMMAND ""
BUILD_BYPRODUCTS
Expand All @@ -62,7 +72,7 @@ else()
GIT_TAG main
PREFIX ${CMAKE_BINARY_DIR}/deps
CONFIGURE_COMMAND ""
BUILD_COMMAND cargo build --release
BUILD_COMMAND ${QRMI_BUILD_CMD}
BUILD_IN_SOURCE 1
INSTALL_COMMAND ""
BUILD_BYPRODUCTS
Expand Down Expand Up @@ -102,12 +112,20 @@ add_library (spank_qrmi MODULE spank_qrmi.c buf.c strbuf.c)
add_dependencies(spank_qrmi QRMI)
set_target_properties (spank_qrmi PROPERTIES PREFIX "" SUFFIX "" OUTPUT_NAME "spank_qrmi.so")


if(ENABLE_MUNGE)
find_library(MUNGE_LIB NAMES munge REQUIRED)
set(MUNGE_LINK_LIB ${MUNGE_LIB})
else()
set(MUNGE_LINK_LIB "")
endif()

target_link_libraries(spank_qrmi
PRIVATE dl pthread m ${QRMI_SOURCE_DIR}/target/release/libqrmi.a
PRIVATE dl pthread m ${MUNGE_LINK_LIB} ${QRMI_SOURCE_DIR}/target/release/libqrmi.a
)
target_include_directories(spank_qrmi
PRIVATE ${QRMI_SOURCE_DIR}
)
target_compile_options(spank_qrmi
PRIVATE -Wall -Wextra -Werror -O2 -pedantic -Wconversion -Wwrite-strings -Wfloat-equal
)
)
24 changes: 24 additions & 0 deletions plugins/spank_qrmi/spank_qrmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,30 @@ int slurm_spank_init_post_opt(spank_t spank_ctxt, int argc, char **argv) {
return SLURM_ERROR;
}

/*
* Set environment variable for slurm job ID and UID.
*/
uid_t job_uid;
if (spank_get_item(spank_ctxt, S_JOB_UID, &job_uid) != ESPANK_SUCCESS) {
slurm_error("%s, unable to get job UID", plugin_name);
return SLURM_ERROR;
}
char uid_str[16];
snprintf(uid_str, sizeof(uid_str), "%u", job_uid);
spank_setenv(spank_ctxt, "QRMI_JOB_UID", uid_str, OVERWRITE);
setenv("QRMI_JOB_UID", uid_str, 1);

uint32_t job_id;
if (spank_get_item(spank_ctxt, S_JOB_ID, &job_id) != ESPANK_SUCCESS) {
slurm_error("%s, unable to get job ID", plugin_name);
return SLURM_ERROR;
}
char id_str[12];
snprintf(id_str, sizeof(id_str), "%u", job_id);
spank_setenv(spank_ctxt, "QRMI_JOB_ID", id_str, OVERWRITE);
setenv("QRMI_JOB_ID", id_str, 1);


spank_setenv(spank_ctxt, "SLURM_JOB_QPU_RESOURCES", "", OVERWRITE);
spank_setenv(spank_ctxt, "SLURM_JOB_QPU_TYPES", "", OVERWRITE);

Expand Down
1 change: 1 addition & 0 deletions plugins/spank_qrmi/spank_qrmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define _SPANK_QRMI_H

#include "buf.h"
#include "qrmi.h"
#include "strbuf.h"

#define OVERWRITE 1
Expand Down