diff --git a/README.md b/README.md index d13db28c..d47ae982 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,34 @@ with SlurmClusterExecutor(cache_directory="./cache") as exe: future_lst = [exe.submit(calc, i) for i in range(1, 4)] print([f.result() for f in future_lst]) ``` + +### Find the right approach for your application +executorlib offers three ways to bring Python functions to an HPC cluster. Which one fits best depends on how long a +single calculation runs compared to the time it waits in the queue, how many calculations there are, whether they need +the same or different resources, and whether your cluster prefers a few large allocations or many small jobs: + +| | One job per call | Workers submitted as jobs | Calls inside one allocation | +|---|---|---|---| +| **Executor** | `SlurmClusterExecutor` | `SlurmClusterExecutor(block_allocation=True)` | `SlurmJobExecutor` | +| **Run time per call** | minutes to days | seconds to minutes | seconds to hours | +| **Number of calls** | limited by the number of jobs the cluster allows per user | many | many | +| **Resources** | defined for every call | the same for all calls | defined for every call, within the allocation | +| **Waiting in the queue** | for every call | once per worker | once for the allocation | +| **The cluster prefers** | small jobs | small jobs, backfill or overflow partitions | large allocations | +| **Log out and come back later** | yes, the results are stored in the cache | no, the Python process has to keep running | no, the Python process runs inside the allocation | +| **Lost calculations** | rerun only the failed calls, the others are loaded from the cache | resubmitted automatically with `restart_limit` | resubmitted automatically with `restart_limit` and `block_allocation=True` | +| **Communication** | file system | sockets | sockets | +| **User stories** | [Story 1: long-running functions](https://executorlib.readthedocs.io/en/latest/story-1-submit-and-reconnect.html)
[Story 3: pandas DataFrames](https://executorlib.readthedocs.io/en/latest/story-3-pandas-dataframes.html)
[Story 4: MPI simulation codes](https://executorlib.readthedocs.io/en/latest/story-4-couple-mpi-simulation-codes.html)
[Story 5: mpi4py functions](https://executorlib.readthedocs.io/en/latest/story-5-mpi4py-functions.html)
[Story 6: multi-resource pipeline](https://executorlib.readthedocs.io/en/latest/story-6-multi-resource-pipeline.html)
[Story 8: recover failed jobs](https://executorlib.readthedocs.io/en/latest/story-8-recover-failed-jobs.html)
[Story 12: document and share](https://executorlib.readthedocs.io/en/latest/story-12-document-and-share.html) | [Story 13: overflow queue](https://executorlib.readthedocs.io/en/latest/story-13-overflow-queue-workers.html) | [Story 2: parameter study](https://executorlib.readthedocs.io/en/latest/story-2-parameter-study.html)
[Story 9: expensive setup once](https://executorlib.readthedocs.io/en/latest/story-9-expensive-setup-once.html)
[Story 11: adaptive workflows](https://executorlib.readthedocs.io/en/latest/story-11-adaptive-workflows.html) | + +The run times are rules of thumb: the longer the queue waits on your cluster, the longer a calculation has to run to +justify its own job. Whether a calculation is a Python function or an external executable makes no difference for the +choice - [Story 4](https://executorlib.readthedocs.io/en/latest/story-4-couple-mpi-simulation-codes.html) wraps MPI-parallel executables and +[Story 5](https://executorlib.readthedocs.io/en/latest/story-5-mpi4py-functions.html) MPI-parallel Python functions, both work with every approach. What counts +is the run time and the resources of a single call. The approaches can also be combined: +[Story 10: fan out inside jobs](https://executorlib.readthedocs.io/en/latest/story-10-fan-out-inside-jobs.html) submits one job per campaign, which then distributes many calls inside its allocation. The +`FluxClusterExecutor` and the `FluxJobExecutor` follow the same pattern for the [flux framework](https://flux-framework.org). +To develop a workflow before using the cluster, start with [Story 7: prototype then scale](https://executorlib.readthedocs.io/en/latest/story-7-prototype-then-scale.html). + Each user story starts from a challenge you are likely to face on an HPC cluster and solves it end-to-end, introducing the features of executorlib as you need them: 1. [Submit a long-running function and come back later](https://executorlib.readthedocs.io/en/latest/story-1-submit-and-reconnect.html) - submit @@ -114,10 +142,13 @@ name: | [`FluxClusterExecutor`](https://executorlib.readthedocs.io/en/latest/2-hpc-cluster.html#flux) | HPC login node or Flux instance | `flux submit` | long-running functions; disconnecting and reconnecting | | [`FluxJobExecutor`](https://executorlib.readthedocs.io/en/latest/3-hpc-job.html#flux) | inside a Flux allocation | `flux run` | high-throughput execution of many short functions | -The **Cluster** executors submit each Python function as an individual job and communicate via the file system, so the -Python process which created the executor can be closed and the results reloaded later. The **Job** executors run inside -an existing allocation and communicate via sockets, which has lower overhead and is the better choice for many short -function calls. +By default the **Cluster** executors submit each Python function as an individual job and communicate via the file +system, so the Python process which created the executor can be closed and the results reloaded later. With +`block_allocation=True` they instead submit long-lived worker jobs, which execute many Python functions and communicate +via sockets. The **Job** executors run inside an existing allocation and communicate via sockets, which has lower +overhead and is the better choice for many short function calls. The table in the +section *Find the right approach for your application* above compares these approaches and links the matching user +stories. To set up the submission of Python functions on a new SLURM cluster, the [executorlib-cluster-setup](https://executorlib.readthedocs.io/en/latest/2-hpc-cluster.html#setup-with-claude-code) skill for [Claude Code](https://docs.claude.com/en/docs/claude-code/overview) analyses the cluster and generates a tested,