Skip to content

Commit 6a253a7

Browse files
added a new qos resolver (#2)
1 parent bf9cc37 commit 6a253a7

File tree

9 files changed

+39
-9
lines changed

9 files changed

+39
-9
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ For example, if you want to use the gpu_p2 partition, you would need to do:
4545
hydra-submitit-launch my_app.py dev hydra.launcher.setup=null hydra.launcher.partition=gpu_p2
4646
```
4747

48+
In order to change the timeout on the SLURM job to for example 10 hours, you would need to do:
49+
```
50+
hydra-submitit-launch my_app.py base +hydra.launcher.hours=10
51+
```
52+
This will automatically select the right qos for you.
4853

4954
## References
5055
- Hydra: https://hydra.cc/docs/intro/

conf/config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fake_param: 4

example_app.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import hydra
2+
3+
from omegaconf import OmegaConf
4+
5+
6+
@hydra.main(config_path='conf', config_name='config')
7+
def example_main(cfg):
8+
print(OmegaConf.to_container(cfg, resolve=True))
9+
10+
if __name__ == '__main__':
11+
example_main()
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
defaults:
22
- dev
33

4-
cpus_per_task: 40
5-
gpus_per_node: 4
4+
gpus_per_node: 4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
defaults:
22
- t3
33

4-
cpus_per_task: 40
5-
gpus_per_node: 4
4+
gpus_per_node: 4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
defaults:
22
- t4
33

4-
cpus_per_task: 40
5-
gpus_per_node: 4
4+
gpus_per_node: 4

hydra_plugins/jz_hydra_submitit_launcher/hydra/launcher/base.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ timeout_min: 60
55
gpus_per_node: 1
66
tasks_per_node: 1
77
gres: "gpu:${hydra.launcher.gpus_per_node}"
8-
qos: qos_gpu-dev
8+
qos: ${qos_from_hours:${hours}}
99
cpus_per_gpu: 10
10+
cpus_per_task: ${cpu_from_gpu:${hydra.launcher.gpus_per_node},${hydra.launcher.cpus_per_gpu}}
1011
gpus_per_task: ${hydra.launcher.gpus_per_node}
1112
additional_parameters:
1213
account: ${oc.env:IDRPROJ}@gpu
1314
distribution: "block:block"
1415
hint: nomultithread
1516
time: "${hours}:00:00"
1617
setup:
17-
- "#SBATCH -C v100-32g"
18+
- "#SBATCH -C v100-32g"
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
defaults:
22
- base
33

4+
qos: qos_gpu-dev
45
additional_parameters:
56
time: "2:00:00"
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
11
from omegaconf import OmegaConf
22

3-
OmegaConf.register_new_resolver("multiply10", lambda x: x * 10)
3+
4+
def time_to_qos(timeout_hour):
5+
timeout_hour = int(timeout_hour)
6+
if timeout_hour > 20:
7+
qos = 't4'
8+
elif timeout_hour > 2:
9+
qos = 't3'
10+
else:
11+
qos = 'dev'
12+
13+
qos = f'qos_gpu-{qos}'
14+
return qos
15+
16+
OmegaConf.register_new_resolver("qos_from_hours", time_to_qos, replace=True)
17+
OmegaConf.register_new_resolver("cpu_from_gpu", lambda x,y: x*y, replace=True)

0 commit comments

Comments
 (0)