1609928 : Help with parallelization for analysis script needed¶
Created: 2026-06-17T14:47:40Z - current status: new¶
Anonymized Summary & Solution¶
Issue¶
A researcher wants to efficiently run a Python-based ligand-detection tool (FoxSight) on a Slurm-managed HPC cluster (Maxwell), comparing its performance against other tools. The current implementation uses an SGE array job, but they need guidance on optimizing it for Slurm, particularly for parallel execution across multiple dataset comparisons.
Key points:
- The task involves processing many independent .ccp4 map files in parallel.
- Their current approach uses ProcessPoolExecutor (Python multiprocessing) within a single-node array job.
- They seek advice on whether Slurm supports concurrent multi-threaded tasks per node (like SGE does).
Summary¶
The user needs help adapting their existing array job + Python multiprocessing workflow from SGE to Slurm for efficient parallel processing on Maxwell.
Solution¶
- Slurm Array Jobs:
- Use
#SBATCH --array=<start>-<end>to distribute tasks across nodes (already correctly implemented). -
Each array task runs one
subprocesswrapper.pyinstance (good for isolation). -
Parallelism Within a Node:
- Unlike SGE, Slurm does allow multi-threading within a single array task.
- Modify the script to use
--ntasks-per-nodeand--cpus-per-taskto enable intra-node parallelism:bash #SBATCH --cpus-per-task=4 # Allocate 4 CPUs per task -
Adjust
nof-processesinsubprocesswrapper.pyto match--cpus-per-task. -
Optimizations:
- Replace
ProcessPoolExecutorwithThreadPoolExecutorif tasks are I/O-bound (but ensure thread safety). -
Avoid oversubscribing CPU cores (match
--cpus-per-taskto actual usage). -
Example Slurm Script: ```bash #!/bin/bash #SBATCH --partition=allcpu #SBATCH --time=12:00:00 #SBATCH --nodes=1 #SBATCH --cpus-per-task=4 # Enable 4-way parallelism per task #SBATCH --array=351-781 #SBATCH --output=slurm-%j_%a.out
unset LD_PRELOAD source /etc/profile.d/modules.sh module purge
echo "Task ${SLURM_ARRAY_TASK_ID} starts on $(hostname)" python3 subprocesswrapper.py \ --force \ --target-dir '[REDACTED]' \ --target-pattern './//*.ccp4' \ --job-id ${SLURM_ARRAY_TASK_ID} \ --nof-processes $SLURM_CPUS_PER_TASK \ # Dynamically set workers --log-file '[REDACTED]/results.log' ```
- Notes:
- Ensure
FoxSightbinaries are accessible via$PATH/$LD_LIBRARY_PATH. - Monitor resource usage with
sacctorseffto validate efficiency.
This approach balances inter-node distribution (via arrays) and intra-node parallelism (via --cpus-per-task), aligning with Slurm’s design.