Skip to content

Commit 7143a9b

Browse files
authored
Merge pull request #405 from datamol-io/hydra-integration
Hydra Integration
2 parents e733ec9 + 2d675f7 commit 7143a9b

File tree

16 files changed

+435
-34
lines changed

16 files changed

+435
-34
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
[![code-check](https://github.com/datamol-io/graphium/actions/workflows/code-check.yml/badge.svg)](https://github.com/datamol-io/graphium/actions/workflows/code-check.yml)
2020
[![doc](https://github.com/datamol-io/graphium/actions/workflows/doc.yml/badge.svg)](https://github.com/datamol-io/graphium/actions/workflows/doc.yml)
2121
[![codecov](https://codecov.io/gh/datamol-io/graphium/branch/main/graph/badge.svg?token=bHOkKY5Fze)](https://codecov.io/gh/datamol-io/graphium)
22+
[![hydra](https://img.shields.io/badge/Config-Hydra_1.3-89b8cd)](https://hydra.cc/)
2223

2324
A deep learning library focused on graph representation learning for real-world chemical tasks.
2425

@@ -78,6 +79,27 @@ To learn how to train a model, we invite you to look at the documentation, or th
7879

7980
If you are not familiar with [PyTorch](https://pytorch.org/docs) or [PyTorch-Lightning](https://pytorch-lightning.readthedocs.io/en/latest/), we highly recommend going through their tutorial first.
8081

82+
## Running an experiment
83+
We have setup Graphium with `hydra` for managing config files. To run an experiment go to the `expts/` folder. For example, to benchmark a GCN on the ToyMix dataset run
84+
```bash
85+
python main_run_multitask.py dataset=toymix model=gcn
86+
```
87+
To change parameters specific to this experiment like switching from `fp16` to `fp32` precision, you can either override them directly in the CLI via
88+
```bash
89+
python main_run_multitask.py dataset=toymix model=gcn trainer.trainer.precision=32
90+
```
91+
or change them permamently in the dedicated experiment config under `expts/hydra-configs/toymix_gcn.yaml`.
92+
Integrating `hydra` also allows you to quickly switch between accelerators. E.g., running
93+
```bash
94+
python main_run_multitask.py dataset=toymix model=gcn accelerator=gpu
95+
```
96+
automatically selects the correct configs to run the experiment on GPU.
97+
To use a config file you built from scratch you can run
98+
```bash
99+
python main_run_multitask.py --config-path [PATH] --config-name [CONFIG]
100+
```
101+
Thanks to the modular nature of `hydra` you can reuse many of our config settings for your own experiments with Graphium.
102+
81103
## License
82104

83105
Under the Apache-2.0 license. See [LICENSE](LICENSE).

env.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@ dependencies:
7171

7272
- pip:
7373
- lightning-graphcore # optional, for using IPUs only
74+
- hydra-core>=1.3.2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type: cpu
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type: gpu
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
type: ipu
2+
ipu_config:
3+
- deviceIterations(5) # IPU would require large batches to be ready for the model.
4+
- replicationFactor(16)
5+
# - enableProfiling("graph_analyser") # The folder where the profile will be stored
6+
# - enableExecutableCaching("pop_compiler_cache")
7+
- TensorLocations.numIOTiles(128)
8+
- _Popart.set("defaultBufferingDepth", 128)
9+
- Precision.enableStochasticRounding(True)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# @package _global_
2+
3+
architecture:
4+
task_heads:
5+
tox21:
6+
last_activation: none
7+
8+
datamodule:
9+
args:
10+
batch_size_training: 200
11+
batch_size_inference: 200
12+
featurization_n_jobs: 4
13+
num_workers: 4
14+
15+
predictor:
16+
optim_kwargs: {}
17+
loss_fun:
18+
tox21: bce_logits_ipu
19+
metrics_every_n_steps: 300
20+
torch_scheduler_kwargs:
21+
max_num_epochs: &max_epochs 300
22+
23+
trainer:
24+
trainer:
25+
precision: 32
26+
accumulate_grad_batches: 1
27+
max_epochs: *max_epochs
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# @package _global_
2+
3+
accelerator:
4+
float32_matmul_precision: medium
5+
6+
architecture:
7+
task_heads:
8+
tox21:
9+
last_activation: none
10+
11+
datamodule:
12+
args:
13+
batch_size_training: 200
14+
batch_size_inference: 200
15+
featurization_n_jobs: 4
16+
num_workers: 4
17+
18+
predictor:
19+
optim_kwargs: {}
20+
loss_fun:
21+
tox21: bce_logits_ipu
22+
metrics_every_n_steps: 300
23+
torch_scheduler_kwargs:
24+
max_num_epochs: &max_epochs 300
25+
26+
trainer:
27+
trainer:
28+
accumulate_grad_batches: 1
29+
max_epochs: *max_epochs
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# @package _global_
2+
3+
datamodule:
4+
args:
5+
ipu_dataloader_training_opts:
6+
mode: async
7+
max_num_nodes_per_graph: 44 # train max nodes: 20, max_edges: 54
8+
max_num_edges_per_graph: 80
9+
ipu_dataloader_inference_opts:
10+
mode: async
11+
max_num_nodes_per_graph: 44 # valid max nodes: 51, max_edges: 118
12+
max_num_edges_per_graph: 80
13+
# Data handling-related
14+
batch_size_training: 50
15+
batch_size_inference: 50
16+
17+
predictor:
18+
optim_kwargs:
19+
loss_scaling: 1024
20+
21+
trainer:
22+
trainer:
23+
accumulate_grad_batches: 4

0 commit comments

Comments
 (0)