-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Profiling example (link to wandb report) (#64)
* Add experiment config, md link to wandb report * wildcard import to defined * removed no_op network dependency, algorithm.network convention * Update docs/profiling_test.py Co-authored-by: Fabrice Normandin <[email protected]> * Update docs/profiling_test.py Co-authored-by: Fabrice Normandin <[email protected]> * Update docs/profiling_test.py Co-authored-by: Fabrice Normandin <[email protected]> * Update docs/profiling_test.py Co-authored-by: Fabrice Normandin <[email protected]> * Update docs/profiling_test.py Co-authored-by: Fabrice Normandin <[email protected]> * pre-commit modifications * Update docs/profiling_test.py Co-authored-by: Fabrice Normandin <[email protected]> * Fix pre-commit issues Signed-off-by: Fabrice Normandin <[email protected]> --------- Signed-off-by: Fabrice Normandin <[email protected]> Co-authored-by: Fabrice Normandin <[email protected]>
- Loading branch information
1 parent
402b177
commit 7c34f38
Showing
5 changed files
with
138 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<iframe src="https://wandb.ai/cesar-valdez-mcgill-university/ResearchTemplate/reports/Profiling--Vmlldzo5NDI1MjU0" style="border:none;height:1024px;width:100%"></iframe> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import shutil | ||
|
||
import hydra.errors | ||
import pytest | ||
from omegaconf import DictConfig | ||
|
||
from project.conftest import ( # noqa: F401 | ||
accelerator, | ||
algorithm_config, | ||
algorithm_network_config, | ||
command_line_arguments, | ||
datamodule_config, | ||
devices, | ||
experiment_dictconfig, | ||
num_devices_to_use, | ||
overrides, | ||
) | ||
from project.experiment import setup_experiment | ||
from project.utils.hydra_utils import resolve_dictconfig | ||
|
||
|
||
@pytest.mark.skipif(not shutil.which("sbatch"), reason="Needs to be run on a SLURM cluster") | ||
@pytest.mark.parametrize( | ||
"command_line_arguments", | ||
[ | ||
# Instrumenting your code -baseline | ||
""" | ||
experiment=profiling \ | ||
algorithm=example \ | ||
trainer.logger.wandb.name="Baseline" \ | ||
trainer.logger.wandb.tags=["Training","Baseline comparison","CPU/GPU comparison"] | ||
""", | ||
# Identifying potential bottlenecks - baseline | ||
""" | ||
experiment=profiling\ | ||
algorithm=no_op\ | ||
trainer.logger.wandb.name="Baseline without training" \ | ||
trainer.logger.wandb.tags=["No training","Baseline comparison"] | ||
""", | ||
# Identifying potential bottlenecks - num_workers multirun | ||
pytest.param( | ||
""" | ||
-m experiment=profiling \ | ||
algorithm=no_op \ | ||
trainer.logger.wandb.tags=["1 CPU Dataloading","Worker throughput"] \ | ||
datamodule.num_workers=1,4,8,16,32 | ||
""", | ||
marks=pytest.mark.xfail( | ||
reason="LexerNoViableAltException error caused by the -m flag", | ||
raises=hydra.errors.OverrideParseException, | ||
strict=True, | ||
), | ||
), | ||
# Identifying potential bottlenecks - num_workers multirun | ||
pytest.param( | ||
""" | ||
-m experiment=profiling \ | ||
algorithm=no_op \ | ||
resources=cpu \ | ||
trainer.logger.wandb.tags=["2 CPU Dataloading","Worker throughput"] \ | ||
hydra.launcher.timeout_min=60 \ | ||
hydra.launcher.cpus_per_task=2 \ | ||
hydra.launcher.constraint="sapphire" \ | ||
datamodule.num_workers=1,4,8,16,32 | ||
""", | ||
marks=pytest.mark.xfail( | ||
reason="LexerNoViableAltException error caused by the -m flag", | ||
raises=hydra.errors.OverrideParseException, | ||
strict=True, | ||
), | ||
), | ||
# Identifying potential bottlenecks - fcnet mnist | ||
""" | ||
experiment=profiling \ | ||
algorithm=example \ | ||
algorithm/network=fcnet \ | ||
datamodule=mnist \ | ||
trainer.logger.wandb.name="FcNet/MNIST baseline with training" \ | ||
trainer.logger.wandb.tags=["CPU/GPU comparison","GPU","MNIST"] | ||
""", | ||
# Throughput across GPU types | ||
""" | ||
experiment=profiling \ | ||
algorithm=example \ | ||
resources=one_gpu \ | ||
hydra.launcher.gres='gpu:a100:1' \ | ||
hydra.launcher.cpus_per_task=4 \ | ||
datamodule.num_workers=8 \ | ||
trainer.logger.wandb.name="A100 training" \ | ||
trainer.logger.wandb.tags=["GPU comparison"] | ||
""", | ||
# Making the most out of your GPU | ||
pytest.param( | ||
""" | ||
-m experiment=profiling \ | ||
algorithm=example \ | ||
datamodule.num_workers=8 \ | ||
datamodule.batch_size=32,64,128,256 \ | ||
trainer.logger.wandb.tags=["Batch size comparison"]\ | ||
'++trainer.logger.wandb.name=Batch size ${datamodule.batch_size}' | ||
""", | ||
marks=pytest.mark.xfail( | ||
reason="LexerNoViableAltException error caused by the -m flag", | ||
raises=hydra.errors.OverrideParseException, | ||
strict=True, | ||
), | ||
), | ||
], | ||
indirect=True, | ||
) | ||
def test_notebook_commands_dont_cause_errors(experiment_dictconfig: DictConfig): # noqa | ||
# check for any errors related to OmegaConf interpolations and such | ||
config = resolve_dictconfig(experiment_dictconfig) | ||
# check for any errors when actually instantiating the components. | ||
_experiment = setup_experiment(config) | ||
# Note: Here we don't actually do anything with the objects. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# @package _global_ | ||
|
||
defaults: | ||
- override /datamodule: imagenet | ||
- override /algorithm: example | ||
- override /trainer/logger: wandb | ||
|
||
trainer: | ||
min_epochs: 1 | ||
max_epochs: 2 | ||
limit_train_batches: 30 | ||
limit_val_batches: 2 | ||
num_sanity_val_steps: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters