Skip to content

Commit

Permalink
Fix minor
Browse files Browse the repository at this point in the history
  • Loading branch information
yhna940 committed Aug 31, 2023
1 parent c4a7e04 commit 4d71002
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/tune/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ python examples/tune/find_lr.py
Distributed data parallel tuning

```bash
torchrun -nnodes 1 -nproc_per_node 8 examples/tune/find_lr.py --launcher pytorch
torchrun --nnodes 1 --nproc_per_node 8 examples/tune/find_lr.py --launcher pytorch
```
6 changes: 3 additions & 3 deletions examples/tune/find_lr.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def forward(self, inputs, data_samples=None, mode='tensor'):

class ToyDataset(Dataset):
METAINFO = dict() # type: ignore
num_samples = 1000
num_samples = 100
data = torch.rand(num_samples, 2) * 10
label = 3 * data[:, 0] + 4 * data[:, 1] + torch.randn(num_samples) * 0.1

Expand Down Expand Up @@ -129,12 +129,12 @@ def main():
'optim_wrapper.optimizer.lr': {
'type': 'continuous',
'lower': 1e-5,
'upper': 1e-1
'upper': 1e-3
}
},
monitor='loss',
rule='less',
num_trials=32,
num_trials=16,
tuning_epoch=2,
searcher_cfg=dict(type='NevergradSearcher'),
)
Expand Down
3 changes: 2 additions & 1 deletion mmengine/tune/tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from mmengine.dist import (broadcast_object_list, init_dist, is_distributed,
is_main_process)
from mmengine.logging import MMLogger
from mmengine.runner import Runner
from ._report_hook import ReportingHook
from .searchers import HYPER_SEARCHERS, Searcher

Expand Down Expand Up @@ -241,6 +240,8 @@ def _run_trial(self) -> Tuple[Dict, float, Optional[Exception]]:
# 2. Once retrieved, the hyperparameters are broadcasted to all other
# processes ensuring every process has the same set of
# hyperparameters for this trial.
from mmengine.runner import Runner

if is_main_process():
hparams_to_broadcast = [self._searcher.suggest()]
else:
Expand Down

0 comments on commit 4d71002

Please sign in to comment.