torc 0.20.7

Workflow management system
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
# HPC Profiles Reference

Complete reference for HPC profile system and CLI commands.

## Overview

HPC profiles contain pre-configured knowledge about High-Performance Computing systems, enabling
automatic Slurm scheduler generation based on job resource requirements. Torc supports built-in
profiles, custom profiles in your config file, and **dynamic Slurm profiles** generated by querying
the current cluster.

## CLI Commands

### `torc hpc list`

List all available HPC profiles.

```bash
torc hpc list [OPTIONS]
```

**Options:**

| Option                  | Description                      |
| ----------------------- | -------------------------------- |
| `-f, --format <FORMAT>` | Output format: `table` or `json` |

**Output columns:**

- **Name**: Profile identifier used in commands
- **Display Name**: Human-readable name
- **Partitions**: Number of configured partitions
- **Detected**: Whether current system matches this profile (includes dynamic Slurm)

---

### `torc hpc detect`

Detect the current HPC system.

```bash
torc hpc detect [OPTIONS]
```

**Options:**

| Option                  | Description                      |
| ----------------------- | -------------------------------- |
| `-f, --format <FORMAT>` | Output format: `table` or `json` |

Returns the detected profile name. If no built-in or custom profile matches but Slurm is available,
it returns a dynamic Slurm profile.

---

### `torc hpc show`

Display detailed information about an HPC profile.

```bash
torc hpc show <PROFILE> [OPTIONS]
```

**Arguments:**

| Argument    | Description                                                 |
| ----------- | ----------------------------------------------------------- |
| `<PROFILE>` | Profile name (e.g., `kestrel`) or `slurm` for auto-detected |

**Options:**

| Option                  | Description                      |
| ----------------------- | -------------------------------- |
| `-f, --format <FORMAT>` | Output format: `table` or `json` |

---

### `torc hpc partitions`

List partitions for an HPC profile.

```bash
torc hpc partitions [PROFILE] [OPTIONS]
```

**Arguments:**

| Argument    | Description                                                      |
| ----------- | ---------------------------------------------------------------- |
| `[PROFILE]` | Profile name (e.g., `kestrel`, `slurm`). Auto-detects if omitted |

---

### `torc hpc match`

Find partitions matching resource requirements.

```bash
torc hpc match [OPTIONS] [PROFILE]
```

**Arguments:**

| Argument    | Description                               |
| ----------- | ----------------------------------------- |
| `[PROFILE]` | Profile to use (auto-detected if omitted) |

**Options:**

| Option                  | Description                                   |
| ----------------------- | --------------------------------------------- |
| `--cpus <N>`            | Required CPU cores                            |
| `--memory <SIZE>`       | Required memory (e.g., `64g`, `512m`)         |
| `--walltime <DURATION>` | Required walltime (e.g., `02:00:00`, `30:00`) |
| `--gpus <N>`            | Required GPUs                                 |
| `-f, --format <FORMAT>` | Output format: `table` or `json`              |

**Memory format:** `<number><unit>` where unit is `k`, `m`, `g`, or `t` (case-insensitive).

**Walltime formats** (Slurm-compatible):

- `MM` (minutes only, e.g., `30`)
- `MM:SS` (e.g., `30:00`)
- `HH:MM:SS` (e.g., `04:00:00`)
- `D-HH:MM:SS` (e.g., `1-00:00:00`)

---

### `torc hpc generate`

Generate an HPC profile configuration from the current Slurm cluster.

```bash
torc hpc generate [OPTIONS]
```

**Options:**

| Option                  | Description                                          |
| ----------------------- | ---------------------------------------------------- |
| `--name <NAME>`         | Profile name (defaults to cluster name or hostname)  |
| `--display-name <NAME>` | Human-readable display name                          |
| `-o, --output <FILE>`   | Output file path (prints to stdout if not specified) |
| `--skip-stdby`          | Skip standby partitions (names ending in `-stdby`)   |

**How it works:**

1. Queries `sinfo` to get partition names, CPUs, memory, time limits, and GRES
2. Queries `scontrol show partition` for each partition to get additional details
3. Parses GRES strings to extract GPU count and type
4. Generates hostname-based detection pattern from current hostname
5. Outputs TOML configuration ready to add to your config file

**Example:**

```bash
# Generate profile from current cluster
torc hpc generate

# Output:
# [client.hpc.custom_profiles.mycluster]
# display_name = "Mycluster"
# detect_hostname = ".*\\.mycluster\\.edu"
#
# [[client.hpc.custom_profiles.mycluster.partitions]]
# name = "compute"
# cpus_per_node = 64
# memory_mb = 256000
# max_walltime_secs = 172800
# ...
```

**Fields extracted automatically:**

- Partition name, CPUs per node, memory (MB), max walltime (seconds)
- GPU count and type from GRES (e.g., `gpu:a100:4`)
- Shared node support from OverSubscribe setting

**Fields that may need manual adjustment:**

- `requires_explicit_request`: Defaults to `false`; set to `true` for partitions that shouldn't be
  auto-selected
- `description`: Not available from Slurm; add human-readable descriptions
- `gpu_memory_gb`: Not available from Slurm; add if known

---

### `torc slurm generate`

Generate Slurm schedulers for a workflow based on job resource requirements.

```bash
torc slurm generate [OPTIONS] --account <ACCOUNT> <WORKFLOW_FILE>
```

**Arguments:**

| Argument          | Description                                                |
| ----------------- | ---------------------------------------------------------- |
| `<WORKFLOW_FILE>` | Path to workflow specification file (YAML, JSON, or JSON5) |

**Options:**

| Option                | Description                                          |
| --------------------- | ---------------------------------------------------- |
| `--account <ACCOUNT>` | Slurm account to use (required)                      |
| `--profile <PROFILE>` | HPC profile to use (auto-detected if not specified)  |
| `-o, --output <FILE>` | Output file path (prints to stdout if not specified) |
| `--no-actions`        | Don't add workflow actions for scheduling nodes      |
| `--force`             | Overwrite existing schedulers in the workflow        |

**Generated artifacts:**

1. **Slurm schedulers**: One for each unique resource requirement
2. **Job scheduler assignments**: Each job linked to appropriate scheduler
3. **Workflow actions**: `on_workflow_start`/`schedule_nodes` actions (unless `--no-actions`)

**Scheduler naming:** `<resource_requirement_name>_scheduler`

---

## Built-in Profiles

### NLR Kestrel

**Profile name:** `kestrel`

**Detection:** Environment variable `NREL_CLUSTER=kestrel`

**Partitions:**

| Partition  | CPUs | Memory  | Max Walltime | GPUs    | Notes                               |
| ---------- | ---- | ------- | ------------ | ------- | ----------------------------------- |
| `debug`    | 104  | 240 GB  | 1h           | -       | Quick testing                       |
| `short`    | 104  | 240 GB  | 4h           | -       | Short jobs                          |
| `standard` | 104  | 240 GB  | 48h          | -       | General workloads                   |
| `long`     | 104  | 240 GB  | 240h         | -       | Extended jobs                       |
| `medmem`   | 104  | 480 GB  | 48h          | -       | Medium memory                       |
| `bigmem`   | 104  | 2048 GB | 48h          | -       | High memory                         |
| `shared`   | 104  | 240 GB  | 48h          | -       | Shared node access                  |
| `hbw`      | 104  | 240 GB  | 48h          | -       | High-bandwidth memory, min 10 nodes |
| `nvme`     | 104  | 240 GB  | 48h          | -       | NVMe local storage                  |
| `gpu-h100` | 2    | 240 GB  | 48h          | 4x H100 | GPU compute                         |

**Node specifications:**

- **Standard nodes**: 104 cores (2x Intel Xeon Sapphire Rapids), 240 GB RAM
- **GPU nodes**: 4x NVIDIA H100 80GB HBM3, 128 cores, 2 TB RAM

---

## Configuration

### Custom Profiles

> **Don't see your HPC?** Please
> [request built-in support]https://github.com/NatLabRockies/torc/issues so everyone benefits. See
> the [Custom HPC Profile Tutorial]./custom-hpc-profile.md for creating a profile while you wait.

Define custom profiles in your Torc configuration file:

```toml
# ~/.config/torc/config.toml

[client.hpc.custom_profiles.mycluster]
display_name = "My Cluster"
description = "Description of the cluster"
detect_env_var = "CLUSTER_NAME=mycluster"
detect_hostname = ".*\\.mycluster\\.org"
default_account = "myproject"

[[client.hpc.custom_profiles.mycluster.partitions]]
name = "compute"
cpus_per_node = 64
memory_mb = 256000
max_walltime_secs = 172800
shared = false

[[client.hpc.custom_profiles.mycluster.partitions]]
name = "gpu"
cpus_per_node = 32
memory_mb = 128000
max_walltime_secs = 86400
gpus_per_node = 4
gpu_type = "A100"
shared = false
```

### Profile Override

Override settings for built-in profiles:

```toml
[client.hpc.profile_overrides.kestrel]
default_account = "my_default_account"
```

### Configuration Options

**`[client.hpc]` Section:**

| Option              | Type  | Description                             |
| ------------------- | ----- | --------------------------------------- |
| `profile_overrides` | table | Override settings for built-in profiles |
| `custom_profiles`   | table | Define custom HPC profiles              |

**Profile override options:**

| Option            | Type   | Description                            |
| ----------------- | ------ | -------------------------------------- |
| `default_account` | string | Default Slurm account for this profile |

**Custom profile options:**

| Option            | Type   | Required | Description                                       |
| ----------------- | ------ | -------- | ------------------------------------------------- |
| `display_name`    | string | No       | Human-readable name                               |
| `description`     | string | No       | Profile description                               |
| `detect_env_var`  | string | No       | Environment variable for detection (`NAME=value`) |
| `detect_hostname` | string | No       | Regex pattern for hostname detection              |
| `default_account` | string | No       | Default Slurm account                             |
| `partitions`      | array  | Yes      | List of partition configurations                  |

**Partition options:**

| Option                      | Type   | Required | Description                            |
| --------------------------- | ------ | -------- | -------------------------------------- |
| `name`                      | string | Yes      | Partition name                         |
| `cpus_per_node`             | int    | Yes      | CPU cores per node                     |
| `memory_mb`                 | int    | Yes      | Memory per node in MB                  |
| `max_walltime_secs`         | int    | Yes      | Maximum walltime in seconds            |
| `gpus_per_node`             | int    | No       | GPUs per node                          |
| `gpu_type`                  | string | No       | GPU model (e.g., "H100")               |
| `shared`                    | bool   | No       | Whether partition supports shared jobs |
| `min_nodes`                 | int    | No       | Minimum required nodes                 |
| `requires_explicit_request` | bool   | No       | Must be explicitly requested           |

---

## Resource Matching Algorithm

When generating schedulers, Torc uses this algorithm to match resource requirements to partitions:

1. **Filter by resources**: Partitions must satisfy:
   - CPUs >= required CPUs
   - Memory >= required memory
   - GPUs >= required GPUs (if specified)
   - Max walltime >= required runtime

2. **Exclude debug partitions**: Unless no other partition matches

3. **Prefer best fit**:
   - Partitions that exactly match resource needs
   - Non-shared partitions over shared
   - Shorter max walltime over longer

4. **Handle special requirements**:
   - GPU jobs only match GPU partitions
   - Respect `requires_explicit_request` flag
   - Honor `min_nodes` constraints

---

## Generated Scheduler Format

Example generated Slurm scheduler:

```yaml
slurm_schedulers:
  - name: medium_scheduler
    account: myproject
    nodes: 1
    mem: 64g
    walltime: 04:00:00
    gres: null
    partition: null  # Let Slurm choose based on resources
```

Corresponding workflow action:

```yaml
actions:
  - trigger_type: on_workflow_start
    action_type: schedule_nodes
    scheduler: medium_scheduler
    scheduler_type: slurm
    num_allocations: 1
```

---

## Runtime Format Parsing

Resource requirements use ISO 8601 duration format for runtime:

| Format   | Example   | Meaning            |
| -------- | --------- | ------------------ |
| `PTnH`   | `PT4H`    | 4 hours            |
| `PTnM`   | `PT30M`   | 30 minutes         |
| `PTnS`   | `PT3600S` | 3600 seconds       |
| `PTnHnM` | `PT2H30M` | 2 hours 30 minutes |
| `PnDTnH` | `P1DT12H` | 1 day 12 hours     |

Generated walltime uses `HH:MM:SS` format (e.g., `04:00:00`).

---

## See Also

- [Working with HPC Profiles]./hpc-profiles.md
- [Custom HPC Profile Tutorial]./custom-hpc-profile.md
- [Advanced Slurm Configuration]./slurm.md
- [Resource Requirements]../../core/reference/resources.md
- [Configuration Reference]../../core/reference/configuration.md