Simple objective optimization orchestration for Slurm clusters
Project description
slurptuna – Run Optuna on Slurm (HPC hyperparameter optimization made simple)
Run Optuna hyperparameter optimization on Slurm clusters without writing sbatch scripts or managing distributed workers.
Running Optuna on a Slurm cluster (HPC) is not straightforward. slurptuna provides a simple way to run Optuna on Slurm with minimal setup.
In practice, running Optuna on Slurm clusters usually means:
- writing and managing
sbatchjob arrays - coordinating distributed Optuna trials
- aggregating results across workers
While Optuna supports distributed optimization, integrating it with Slurm typically requires custom orchestration.
slurptuna removes that overhead by handling job submission, parallel execution,
and result aggregation automatically.
Install
pip install slurptuna
Or with uv:
uv add slurptuna
Usage
Here is a minimal example of running Optuna on Slurm using slurptuna:
(1) Write your loss function in a script
# my_model.py
from datetime import timedelta
from slurptuna import ExecutionMode, loss, optimize_run
@loss(
name="my_model",
parameter_space={"alpha": (0.0, 1.0), "beta": (0.0, 1.0)},
)
def my_model(params, seed, context):
return abs(params["alpha"] - 0.3) + abs(params["beta"] - 0.7)
if __name__ == "__main__":
result = optimize_run(
my_model,
mode=ExecutionMode.DISTRIBUTED,
n_trials=20,
n_seeds=400,
chunk_size=20,
worker_time_limit=timedelta(minutes=30),
)
print(result.best_params)
# best params and best value are also written to runs/my_model_v0001/summary.json
(2) Submit your script as a long-running controller job on Slurm:
sbatch run_controller.sh my_model.py
run_controller.sh:
#!/bin/bash
#SBATCH --job-name=slurptuna-controller
#SBATCH --time=04:00:00
#SBATCH --cpus-per-task=1
#SBATCH --mem=4G
source .venv/bin/activate
python "$1"
The controller submits and monitors chunk/reduce array jobs automatically — you just wait for the result.
Docs
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file slurptuna-0.0.2.tar.gz.
File metadata
- Download URL: slurptuna-0.0.2.tar.gz
- Upload date:
- Size: 66.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56fa2af6b4d140649dfd2c581b4df2ca4183909c6a801d933f54fe3379bd55b1
|
|
| MD5 |
16426b1ec121f48bd2a976bfb450a7f1
|
|
| BLAKE2b-256 |
21d101fa7c3ce5733c2a5c26de7d1e3f6564a2374d4184c7c0a69481228056c8
|
Provenance
The following attestation bundles were made for slurptuna-0.0.2.tar.gz:
Publisher:
publish.yml on younesStrittmatter/slurptuna
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
slurptuna-0.0.2.tar.gz -
Subject digest:
56fa2af6b4d140649dfd2c581b4df2ca4183909c6a801d933f54fe3379bd55b1 - Sigstore transparency entry: 1155182614
- Sigstore integration time:
-
Permalink:
younesStrittmatter/slurptuna@8dab20d54532828582f9c0b71d024b15942787b3 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/younesStrittmatter
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8dab20d54532828582f9c0b71d024b15942787b3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file slurptuna-0.0.2-py3-none-any.whl.
File metadata
- Download URL: slurptuna-0.0.2-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6ee1a8608f9d78563e0dd881380701b25e10ff988111ff3f8f6848c24d550fa
|
|
| MD5 |
c65dd27d2565bcd5388030f36414eeb4
|
|
| BLAKE2b-256 |
c26ec2ac94ce0c212022da29039c36c736a956cedf06b226db45b760b5473417
|
Provenance
The following attestation bundles were made for slurptuna-0.0.2-py3-none-any.whl:
Publisher:
publish.yml on younesStrittmatter/slurptuna
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
slurptuna-0.0.2-py3-none-any.whl -
Subject digest:
e6ee1a8608f9d78563e0dd881380701b25e10ff988111ff3f8f6848c24d550fa - Sigstore transparency entry: 1155182615
- Sigstore integration time:
-
Permalink:
younesStrittmatter/slurptuna@8dab20d54532828582f9c0b71d024b15942787b3 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/younesStrittmatter
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8dab20d54532828582f9c0b71d024b15942787b3 -
Trigger Event:
release
-
Statement type: