Skip to content

Bandit Profiling Gist

Joseph Lee edited this page Nov 4, 2024 · 15 revisions

Run bandit with sweeps over n_cpu's. Note the -m flag to enable sweeping:
python run.py -m experiment.upload=true experiment.tag=cpu_profile run.steps=1000 run.n_runs=2000 run.n_jobs=1,2,3,4,5,6,7,8

image

Run austin profiler on multiprocessing child procs with output piped to flamegraph. Note the -C flag to enable profiling child processes:

austin -C -i 1ms python run.py run.steps=1000 run.n_runs=20 | sed '/^#/d' | ~/projects/FlameGraph/flamegraph.pl --countname=μs > test.svg

image image image

Instantiating objects with Hydra

By default, the parameters passed to the target are either primitives (int, float, bool etc) or OmegaConf containers (DictConfig, ListConfig). OmegaConf containers have many advantages over primitive dicts and lists, including convenient attribute access for keys, duck-typing as instances of dataclasses or attrs classes, and support for variable interpolation and custom resolvers. If the callable targeted by instantiate leverages OmegaConf's features, it will make sense to pass DictConfig and ListConfig instances directly to that callable.

That being said, in many cases it's desired to pass normal Python dicts and lists, rather than DictConfig or ListConfig instances, as arguments to your callable. You can change instantiate's argument conversion strategy using the convert parameter. Supported values are:

"none" : Default behavior, Use OmegaConf containers
"partial" : Convert OmegaConf containers to dict and list, except Structured Configs.
"all" : Convert everything to primitive containers

image

image

image

image
image image

fstrings in debug logging statements are not lazy.

image
image image

image


image
Clone this wiki locally