New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Engines 3.0 #1230
[WIP] Engines 3.0 #1230
Conversation
catalyst/engines/fairscale.py
Outdated
|
||
if SETTINGS.fairscale_required: | ||
from fairscale.nn import Pipe | ||
from fairscale.nn.data_parallel import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
N817 camelcase 'FullyShardedDataParallel' imported as acronym 'FSDP'
catalyst/utils/distributed.py
Outdated
@@ -35,6 +35,14 @@ def _is_ddp_wrapped(model: nn.Module) -> bool: | |||
|
|||
parallel_wrappers = parallel_wrappers + (apex_DDP,) | |||
|
|||
if SETTINGS.fairscale_required: | |||
from fairscale.nn.data_parallel import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
N817 camelcase 'FullyShardedDataParallel' imported as acronym 'FSDP'
catalyst/utils/distributed.py
Outdated
ShardedDataParallel as ShardedDDP, | ||
) | ||
|
||
parallel_wrappers = parallel_wrappers + (ShardedDDP, FSDP,) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
C819 trailing comma prohibited
examples/engines/fairscale_ddp.py
Outdated
from torch import nn, optim | ||
from torch.utils.data import DataLoader | ||
|
||
from catalyst import dl, utils |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
F401 'catalyst.utils' imported but unused
examples/engines/fairscale_ddp.py
Outdated
from catalyst.data import ToTensor | ||
|
||
|
||
class CustomRunner(dl.IRunner): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D101 Missing docstring in public class
examples/engines/fairscale_ddp.py
Outdated
super().__init__() | ||
self._logdir = logdir | ||
|
||
def get_engine(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
examples/engines/fairscale_ddp.py
Outdated
# return dl.SharedDataParallelFairScaleAMPEngine() | ||
return dl.FullySharedDataParallelFairScaleEngine() | ||
|
||
def get_loggers(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
examples/engines/fairscale_ddp.py
Outdated
} | ||
|
||
@property | ||
def stages(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
examples/engines/fairscale_pipe.py
Outdated
) | ||
return model | ||
|
||
def get_criterion(self, stage: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
examples/engines/fairscale_pipe.py
Outdated
def get_criterion(self, stage: str): | ||
return nn.CrossEntropyLoss() | ||
|
||
def get_optimizer(self, stage: str, model): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
examples/engines/fairscale_pipe.py
Outdated
def get_optimizer(self, stage: str, model): | ||
return optim.Adam(model.parameters(), lr=1e-3) | ||
|
||
def get_scheduler(self, stage: str, optimizer): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
examples/engines/fairscale_pipe.py
Outdated
def get_scheduler(self, stage: str, optimizer): | ||
return None | ||
|
||
def get_callbacks(self, stage: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
examples/engines/fairscale_pipe.py
Outdated
), | ||
} | ||
|
||
def handle_batch(self, batch): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
Hello @Scitator! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2021-06-13 14:21:23 UTC |
examples/engines/multi_gpu.py
Outdated
if SETTINGS.fairscale_required: | ||
E2E.update( | ||
{ | ||
"fs-pp": partial(dl.PipelineParallelFairScaleEngine, pipe_kwargs=dict(balance=[3, 4])), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
C408 Unnecessary dict call - rewrite as a literal.
# tested with `docker pull deepspeed/deepspeed:v031_torch17_cuda11` | ||
if SETTINGS.deepspeed_required: | ||
E2E.update( | ||
{"ds-ddp": dl.DistributedDataParallelDeepSpeedEngine,} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
E231 missing whitespace after ','
# tested with `docker pull deepspeed/deepspeed:v031_torch17_cuda11` | ||
if SETTINGS.deepspeed_required: | ||
E2E.update( | ||
{"ds-ddp": dl.DistributedDataParallelDeepSpeedEngine,} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
C819 trailing comma prohibited
) | ||
|
||
|
||
def conv_block(in_channels, out_channels, pool=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D103 Missing docstring in public function
return nn.Sequential(*layers) | ||
|
||
|
||
def resnet9(in_channels: int, num_classes: int, size: int = 16): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D103 Missing docstring in public function
+ " You can use download=True to download it" | ||
) | ||
with open(path, "rb") as infile: | ||
data = pickle.load(infile, encoding="latin1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
WPS442 Found outer scope names shadowing: data
|
||
return img, target | ||
|
||
def __len__(self) -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D105 Missing docstring in magic method
return False | ||
return True | ||
|
||
def download(self) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
return | ||
download_and_extract_archive(self.url, self.root, filename=self.filename, md5=self.tgz_md5) | ||
|
||
def extra_repr(self) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
@@ -207,11 +219,21 @@ def all_gather(data: Any) -> List[Any]: | |||
return data_list | |||
|
|||
|
|||
def ddp_sync_run(function: Callable): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D103 Missing docstring in public function
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
examples/engines/tmp.py
Outdated
from catalyst.data import ToTensor | ||
|
||
|
||
class CustomRunner(dl.IRunner): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D101 Missing docstring in public class
examples/engines/tmp.py
Outdated
super().__init__() | ||
self._logdir = logdir | ||
|
||
def get_engine(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
examples/engines/tmp.py
Outdated
def get_engine(self): | ||
return dl.DistributedDataParallelEngine() | ||
|
||
def get_loggers(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
examples/engines/tmp.py
Outdated
} | ||
|
||
@property | ||
def stages(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
examples/engines/tmp.py
Outdated
def stages(self): | ||
return ["train_freezed", "train_unfreezed"] | ||
|
||
def get_stage_len(self, stage: str) -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
examples/engines/tmp.py
Outdated
utils.set_requires_grad(model, True) | ||
return model | ||
|
||
def get_criterion(self, stage: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
examples/engines/tmp.py
Outdated
def get_criterion(self, stage: str): | ||
return nn.CrossEntropyLoss() | ||
|
||
def get_optimizer(self, stage: str, model): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
examples/engines/tmp.py
Outdated
else: | ||
return optim.SGD(model.parameters(), lr=1e-1) | ||
|
||
def get_callbacks(self, stage: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
examples/engines/tmp.py
Outdated
"verbose": dl.TqdmCallback(), | ||
} | ||
|
||
def handle_batch(self, batch): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
scheduler = self.sync_device(scheduler) | ||
|
||
|
||
return model, criterion, optimizer, scheduler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
E303 too many blank lines (2)
def init_components( | ||
self, model_fn=None, criterion_fn=None, optimizer_fn=None, scheduler_fn=None, | ||
): | ||
"""Inits the runs components.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D202 No blank lines allowed after function docstring
catalyst/engines/fairscale.py
Outdated
return pipe_model, criterion, optimizer, scheduler | ||
|
||
def deinit_components(self, runner): | ||
"""Deinits the runs components. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
DAR101 Missing parameter(s) in Docstring: - runner
self.targets = [] | ||
|
||
# now load the picked numpy arrays | ||
for file_name, checksum in downloaded_list: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
B007 Loop control variable 'checksum' not used within the loop body. If this is intended, start the name with an underscore.
+ " You can use download=True to download it" | ||
) | ||
with open(path, "rb") as infile: | ||
data = pickle.load(infile, encoding="latin1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
WPS442 Found outer scope names shadowing: data
|
||
return img, target | ||
|
||
def __len__(self) -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D105 Missing docstring in magic method
return False | ||
return True | ||
|
||
def download(self) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
return | ||
download_and_extract_archive(self.url, self.root, filename=self.filename, md5=self.tgz_md5) | ||
|
||
def extra_repr(self) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D102 Missing docstring in public method
catalyst/engines/fairscale.py
Outdated
|
||
if SETTINGS.fairscale_required: | ||
from fairscale.nn import Pipe | ||
from fairscale.nn.data_parallel import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
N817 camelcase 'FullyShardedDataParallel' imported as acronym 'FSDP'
def init_components( | ||
self, model_fn=None, criterion_fn=None, optimizer_fn=None, scheduler_fn=None, | ||
): | ||
"""Inits the runs components.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
D202 No blank lines allowed after function docstring
catalyst/engines/fairscale.py
Outdated
return pipe_model, criterion, optimizer, scheduler | ||
|
||
def deinit_components(self, runner): | ||
"""Deinits the runs components. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
DAR101 Missing parameter(s) in Docstring: - runner
catalyst/utils/distributed.py
Outdated
if SETTINGS.fairscale_required: | ||
from fairscale.nn.data_parallel import FullyShardedDataParallel, ShardedDataParallel | ||
|
||
parallel_wrappers = parallel_wrappers + (ShardedDataParallel, FullyShardedDataParallel,) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[pep8] reported by reviewdog 🐶
C819 trailing comma prohibited
Before submitting (checklist)
catalyst-make-codestyle && catalyst-check-codestyle
(pip install -U catalyst-codestyle
).make check-docs
?pytest .
?latest
andminimal
requirements?Description
Related Issue
Type of Change
PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.
FAQ
Please review the FAQ before submitting an issue: