Skip to content
Draft
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
12 changes: 12 additions & 0 deletions demo/qrmi/jobs/run_cudaq_pasqal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

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

source /shared/pyenv/bin/activate

srun python /shared/qrmi/examples/qrmi/python/cudaq/pasqal.py
2 changes: 1 addition & 1 deletion demo/qrmi/jobs/run_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

# Your script goes here
source /shared/pyenv/bin/activate
python /shared/qrmi/examples/pulser_backend/pasqal/send_pasqal_job_local.py
python /shared/qrmi/examples/pulser/pasqal/send_pasqal_job_local.py
7 changes: 4 additions & 3 deletions demo/qrmi/jobs/run_pulser_backend.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/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=FRESNEL
#SBATCH --qpu=EMU_FREE

# Your script goes here
source /shared/pyenv/bin/activate
srun python /shared/qrmi/examples/pulser_backend/pulser_backend.py
srun python /shared/qrmi/examples/pulser/pasqal/pulser_qrmi.py
11 changes: 11 additions & 0 deletions demo/qrmi/jobs/run_qpp_sampler.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

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

source /shared/pyenv/bin/activate
srun python /shared/qrmi/examples/qiskit_primitives/pasqal/sampler.py
25 changes: 22 additions & 3 deletions demo/qrmi/slurm-docker-cluster/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,26 @@ Options provided by plugins:
[root@login /]# sbatch /shared/spank-plugins/demo/qrmi/jobs/run_pulser_backend.sh
```

5. Checking primitive results
5. Running Pasqal Qiskit Provider `SamplerV2` job via QRMI

```bash
[root@login /]# sbatch /shared/spank-plugins/demo/qrmi/jobs/run_qpp_sampler.sh
```

Expected output in `/data/job_<id>.out` includes final counts, e.g.:
```text
{'100010': 10, '000100': 2, ...}
```

6. Running CUDA-Q Pasqal Cloud QRMI job

Requires additionally installing CUDA-Q with QRMI support.

```bash
[root@login /]# sbatch /shared/spank-plugins/demo/qrmi/jobs/run_cudaq_pasqal.sh
```

7. Checking primitive results

Once above scripts are completed, you must find `slurm-{job_id}.out` in the current directory.

Expand Down Expand Up @@ -243,8 +262,8 @@ For example,

### Running serialized jobs using the qrmi_task_runner Slurm Cluster

It is possible to run JSON-serialized jobs directly using a commandline utility called qrmi_task runner.
See [the docs](https://github.com/qiskit-community/qrmi/blob/main/bin/task_runner/README.md) for that tool for details.
It is possible to run JSON-serialized jobs directly using a commandline utility called `qrmi_task_runner`.
See [the docs](https://github.com/qiskit-community/qrmi/blob/main/python/qrmi/tools/task_runner/README.md) for that tool for details.

```bash
[root@login /]# sbatch /shared/spank-plugins/demo/qrmi/jobs/run_task.sh
Expand Down
10 changes: 1 addition & 9 deletions plugins/spank_qrmi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,8 @@ 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 ${MUNGE_LINK_LIB} ${QRMI_SOURCE_DIR}/target/release/libqrmi.a
PRIVATE dl pthread m ${QRMI_SOURCE_DIR}/target/release/libqrmi.a
)
Comment on lines 114 to 117

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert file

target_include_directories(spank_qrmi
PRIVATE ${QRMI_SOURCE_DIR}
Expand Down
33 changes: 11 additions & 22 deletions plugins/spank_qrmi/spank_qrmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,6 @@ static void acquired_resource_destroy(void *object);
static qpu_resource_t *_acquire_qpu(spank_t spank_ctxt, char *name, QrmiResourceType type);
static void _release_qpu(qpu_resource_t *res);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert file


/*
* @function _dump_environ
*
* Dumps all environment variables set for the current process.
*/
static void _dump_environ() {
char **s = environ;
int pid = (int)getpid();
int uid = (int)getuid();

slurm_debug("%s(%d, %d): environment variables ---", plugin_name, pid, uid);
for (; *s; s++) {
slurm_debug("%s(%d, %d): %s", plugin_name, pid, uid, *s);
}
}

/*
* @function _starts_with
*
Expand Down Expand Up @@ -192,7 +176,7 @@ int slurm_spank_init_post_opt(spank_t spank_ctxt, int argc, char **argv) {

if (g_qpu_names_opt == NULL) {
/* noop if this is not QPU job */
return SLURM_ERROR;
return SLURM_SUCCESS;
}

/*
Expand Down Expand Up @@ -329,8 +313,6 @@ int slurm_spank_init_post_opt(spank_t spank_ctxt, int argc, char **argv) {
spank_setenv(spank_ctxt, keybuf.buffer, envvar.value, KEEP_IF_EXISTS);
}

_dump_environ();

/*
* Acquire QPU resource.
*/
Expand Down Expand Up @@ -419,11 +401,15 @@ int slurm_spank_task_init(spank_t spank_ctxt, int argc, char **argv) {

char *optargp = NULL;
if (spank_option_getopt(spank_ctxt, &spank_qrmi_options[0], &optargp) != ESPANK_SUCCESS) {
/* if spank_qrmi plugin is not registered, simply returns an error. */
return SLURM_ERROR;
/* noop if this is not QPU job */
return SLURM_SUCCESS;
}
if (optargp == NULL) {
/* noop if this is not QPU job */
return SLURM_SUCCESS;
}
size_t optlen = strlen(optargp);
if ((optargp == NULL) || optlen == 0) {
if (optlen == 0) {
/* noop if this is not QPU job */
return SLURM_SUCCESS;
}
Expand Down Expand Up @@ -568,6 +554,9 @@ int slurm_spank_exit(spank_t spank_ctxt, int argc, char **argv) {
*/
static qpu_resource_t *_acquired_resource_create(char *name, QrmiResourceType type,
const char *token) {
if (token == NULL) {
return NULL;
}
/*
* use strcpy() to fix the error - ‘strncpy’ specified bound depends on the length of the
* source argument - caused by some C compilers.
Expand Down
Loading