|
| 1 | +# Running Iris on SLURM |
| 2 | + |
| 3 | +This guide covers a practical Iris workflow on SLURM-managed GPU clusters. It is written to stay generic across clusters while matching the provided Iris scripts and working well on clusters where: |
| 4 | + |
| 5 | +- GPU nodes are scheduled with SLURM |
| 6 | +- Docker is available on compute nodes, but not necessarily on login nodes |
| 7 | +- fast local storage such as `/scratch` is preferred for builds and test output |
| 8 | + |
| 9 | +## What the provided SLURM script assumes |
| 10 | + |
| 11 | +The repository includes `scripts/run_core_tests_slurm.sh`, a batch wrapper for running `scripts/run_core_tests.sh`. |
| 12 | + |
| 13 | +It **assumes the container image already exists**. It does **not** build `iris-dev` for you. |
| 14 | + |
| 15 | +By default, the script: |
| 16 | + |
| 17 | +- requests 1 node with 4 GPUs |
| 18 | +- expects a Docker image named `iris-dev` |
| 19 | +- stages the repository into node-local storage when available |
| 20 | +- installs Iris in editable mode inside the container |
| 21 | +- runs `scripts/run_core_tests.sh` |
| 22 | +- copies the per-test logs back to `$HOME/slurm-logs/iris-core-tests-<jobid>/` |
| 23 | + |
| 24 | +If the image is missing, the job fails fast with an explicit error. |
| 25 | + |
| 26 | +## Fresh-clone workflow |
| 27 | + |
| 28 | +### 1. Clone the repository on shared storage |
| 29 | + |
| 30 | +Clone Iris somewhere visible from both the login node and the compute nodes. |
| 31 | + |
| 32 | +```bash |
| 33 | +git clone https://github.com/ROCm/iris.git |
| 34 | +cd iris |
| 35 | +``` |
| 36 | + |
| 37 | +If your cluster provides both shared storage and node-local scratch, keep the source tree on shared storage and let jobs copy into scratch for execution. |
| 38 | + |
| 39 | +### 2. Request an interactive GPU allocation |
| 40 | + |
| 41 | +If Docker is only available on worker nodes, first allocate a node and enter it. |
| 42 | + |
| 43 | +```bash |
| 44 | +salloc --nodes=1 --gres=gpu:4 --time=02:00:00 |
| 45 | +srun --pty $SHELL |
| 46 | +``` |
| 47 | + |
| 48 | +Adjust GPUs, walltime, partition, account, memory, and CPU count to match your site policy. |
| 49 | + |
| 50 | +### 3. Build the Iris Docker image on the allocated node |
| 51 | + |
| 52 | +```bash |
| 53 | +cd /path/to/iris |
| 54 | +./docker/build.sh |
| 55 | +``` |
| 56 | + |
| 57 | +This builds the default image name, `iris-dev`. |
| 58 | + |
| 59 | +If you want a custom image name: |
| 60 | + |
| 61 | +```bash |
| 62 | +./docker/build.sh my-iris-image |
| 63 | +``` |
| 64 | + |
| 65 | +You can verify that the image exists with: |
| 66 | + |
| 67 | +```bash |
| 68 | +docker image inspect iris-dev |
| 69 | +``` |
| 70 | + |
| 71 | +### 4. Submit the batch job |
| 72 | + |
| 73 | +From the repository root: |
| 74 | + |
| 75 | +```bash |
| 76 | +sbatch scripts/run_core_tests_slurm.sh |
| 77 | +``` |
| 78 | + |
| 79 | +If you built a custom image: |
| 80 | + |
| 81 | +```bash |
| 82 | +sbatch --export=ALL,IMAGE_NAME=my-iris-image scripts/run_core_tests_slurm.sh |
| 83 | +``` |
| 84 | + |
| 85 | +## Important note about node-local images |
| 86 | + |
| 87 | +Some clusters store Docker images per node rather than in a shared registry-backed cache. In that setup, building `iris-dev` on one node does not guarantee that another node can see it. |
| 88 | + |
| 89 | +If your cluster behaves this way, either: |
| 90 | + |
| 91 | +1. build and submit on the same node, or |
| 92 | +2. pin the batch job to the node where the image was built, or |
| 93 | +3. rebuild the image on the target node |
| 94 | + |
| 95 | +For example, after building the image on a worker node: |
| 96 | + |
| 97 | +```bash |
| 98 | +NODE_NAME=$(hostname) |
| 99 | +sbatch -w "$NODE_NAME" scripts/run_core_tests_slurm.sh |
| 100 | +``` |
| 101 | + |
| 102 | +If your cluster has shared container storage, you can usually omit `-w`. |
| 103 | + |
| 104 | +## Monitoring the job |
| 105 | + |
| 106 | +Use normal SLURM tools: |
| 107 | + |
| 108 | +```bash |
| 109 | +squeue -j <jobid> |
| 110 | +sacct -j <jobid> |
| 111 | +``` |
| 112 | + |
| 113 | +By default, the batch script writes SLURM stdout/stderr to: |
| 114 | + |
| 115 | +```bash |
| 116 | +iris_core_tests_<jobid>.out |
| 117 | +``` |
| 118 | + |
| 119 | +in the directory where `sbatch` was invoked. |
| 120 | + |
| 121 | +The per-test logs are copied to: |
| 122 | + |
| 123 | +```bash |
| 124 | +$HOME/slurm-logs/iris-core-tests-<jobid>/ |
| 125 | +``` |
| 126 | + |
| 127 | +## Running interactively inside the container |
| 128 | + |
| 129 | +For development on an allocated node, you can also start the container manually: |
| 130 | + |
| 131 | +```bash |
| 132 | +./docker/run.sh iris-dev "$(pwd)" |
| 133 | +``` |
| 134 | + |
| 135 | +Then install Iris in editable mode: |
| 136 | + |
| 137 | +```bash |
| 138 | +pip install -e ".[dev]" |
| 139 | +``` |
| 140 | + |
| 141 | +This is useful when you want to debug failures before switching back to `sbatch`. |
| 142 | + |
| 143 | +## Running example programs under SLURM |
| 144 | + |
| 145 | +Many examples under `examples/` can be run directly with `python ... --num_ranks <N>` after Iris is installed in the container. |
| 146 | + |
| 147 | +The repository includes a generic example wrapper: |
| 148 | + |
| 149 | +```bash |
| 150 | +scripts/run_example_slurm.sh |
| 151 | +``` |
| 152 | + |
| 153 | +It stages the repository into node-local storage, installs Iris in the container, runs a chosen example script, and copies any `logs/` or `results/` directories back to: |
| 154 | + |
| 155 | +```bash |
| 156 | +$HOME/slurm-logs/iris-example-<jobid>/ |
| 157 | +``` |
| 158 | + |
| 159 | +### Generic usage |
| 160 | + |
| 161 | +Submit any repo-relative example script and pass the example arguments after it: |
| 162 | + |
| 163 | +```bash |
| 164 | +sbatch scripts/run_example_slurm.sh <example_script> [example args...] |
| 165 | +``` |
| 166 | + |
| 167 | +For example: |
| 168 | + |
| 169 | +```bash |
| 170 | +sbatch scripts/run_example_slurm.sh examples/00_load/load_bench.py --num_ranks 4 |
| 171 | +sbatch scripts/run_example_slurm.sh examples/13_flash_decode/example_run.py --num_ranks 4 |
| 172 | +``` |
| 173 | + |
| 174 | +### Example: `examples/14_all_gather_gemm` |
| 175 | + |
| 176 | +This example directory provides both a pull-model and push-model entrypoint. |
| 177 | + |
| 178 | +Pull model: |
| 179 | + |
| 180 | +```bash |
| 181 | +sbatch scripts/run_example_slurm.sh \ |
| 182 | + examples/14_all_gather_gemm/example_run_pull.py \ |
| 183 | + --num_ranks 4 |
| 184 | +``` |
| 185 | + |
| 186 | +Push model: |
| 187 | + |
| 188 | +```bash |
| 189 | +sbatch scripts/run_example_slurm.sh \ |
| 190 | + examples/14_all_gather_gemm/example_run_push.py \ |
| 191 | + --num_ranks 4 |
| 192 | +``` |
| 193 | + |
| 194 | +If your image is node-local, build on a worker node first and optionally pin the submission to that node: |
| 195 | + |
| 196 | +```bash |
| 197 | +NODE_NAME=$(hostname) |
| 198 | +sbatch -w "$NODE_NAME" scripts/run_example_slurm.sh \ |
| 199 | + examples/14_all_gather_gemm/example_run_pull.py \ |
| 200 | + --num_ranks 4 |
| 201 | +``` |
| 202 | + |
| 203 | +Use a rank count that matches the GPUs allocated to the job. |
| 204 | + |
| 205 | +### Custom image or install method |
| 206 | + |
| 207 | +```bash |
| 208 | +sbatch --export=ALL,IMAGE_NAME=my-iris-image scripts/run_example_slurm.sh \ |
| 209 | + examples/14_all_gather_gemm/example_run_pull.py \ |
| 210 | + --num_ranks 4 |
| 211 | +``` |
| 212 | + |
| 213 | +```bash |
| 214 | +sbatch --export=ALL,INSTALL_METHOD=install scripts/run_example_slurm.sh \ |
| 215 | + examples/14_all_gather_gemm/example_run_pull.py \ |
| 216 | + --num_ranks 4 |
| 217 | +``` |
| 218 | + |
| 219 | +## Customizing the provided batch wrapper |
| 220 | + |
| 221 | +The provided script is intentionally conservative and is meant for a 4-GPU core-test workflow. |
| 222 | + |
| 223 | +Common customizations: |
| 224 | + |
| 225 | +### Use a different image name |
| 226 | + |
| 227 | +```bash |
| 228 | +sbatch --export=ALL,IMAGE_NAME=my-iris-image scripts/run_core_tests_slurm.sh |
| 229 | +``` |
| 230 | + |
| 231 | +### Store copied logs elsewhere |
| 232 | + |
| 233 | +```bash |
| 234 | +sbatch --export=ALL,PERSIST_LOG_ROOT=$HOME/my-iris-logs scripts/run_core_tests_slurm.sh |
| 235 | +``` |
| 236 | + |
| 237 | +### Use a different scratch location |
| 238 | + |
| 239 | +If your cluster does not use `/scratch`, point the job at another fast workspace: |
| 240 | + |
| 241 | +```bash |
| 242 | +sbatch --export=ALL,WORK_ROOT=/path/to/local/workdir scripts/run_core_tests_slurm.sh |
| 243 | +``` |
| 244 | + |
| 245 | +### Change SLURM resources |
| 246 | + |
| 247 | +Either edit the `#SBATCH` lines in `scripts/run_core_tests_slurm.sh`, or override them at submission time: |
| 248 | + |
| 249 | +```bash |
| 250 | +sbatch --gres=gpu:4 --time=04:00:00 --cpus-per-task=32 scripts/run_core_tests_slurm.sh |
| 251 | +``` |
| 252 | + |
| 253 | +The current wrapper is designed around 4 GPUs. Since `scripts/run_core_tests.sh` includes 1, 2, 4, and 8-rank configurations, the wrapper automatically skips 8-rank cases when only 4 GPUs are visible. |
| 254 | + |
| 255 | +## Troubleshooting |
| 256 | + |
| 257 | +### `Docker image iris-dev not found` |
| 258 | + |
| 259 | +Build the image first: |
| 260 | + |
| 261 | +```bash |
| 262 | +./docker/build.sh |
| 263 | +``` |
| 264 | + |
| 265 | +If the image was built on another worker node, submit to that same node or rebuild locally. |
| 266 | + |
| 267 | +### `docker` is not available on the login node |
| 268 | + |
| 269 | +Request an interactive allocation and build from inside the worker node: |
| 270 | + |
| 271 | +```bash |
| 272 | +salloc --nodes=1 --gres=gpu:4 --time=02:00:00 |
| 273 | +srun --pty $SHELL |
| 274 | +./docker/build.sh |
| 275 | +``` |
| 276 | + |
| 277 | +### The job should run from fast local storage |
| 278 | + |
| 279 | +The provided wrapper already stages the repository into node-local storage when possible. If your cluster uses a different path than `/scratch`, set `WORK_ROOT` when submitting. |
| 280 | + |
| 281 | +### I need an Apptainer-based workflow instead |
| 282 | + |
| 283 | +Iris also includes Apptainer support: |
| 284 | + |
| 285 | +```bash |
| 286 | +./apptainer/build.sh |
| 287 | +./apptainer/run.sh |
| 288 | +``` |
| 289 | + |
| 290 | +The provided `scripts/run_core_tests_slurm.sh` wrapper is Docker-based, so use the Apptainer scripts directly or create a cluster-specific batch wrapper around them. |
0 commit comments