Skip to content
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

Refactor PyTorch profiler 4/5 #6349

Merged
merged 98 commits into from
Mar 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
aa89fa1
Refactor profilers
carmocca Mar 4, 2021
b66f1f6
Update PassThrough
carmocca Mar 5, 2021
d388d80
WIP - This is broken and will change
carmocca Mar 6, 2021
93aa073
Update pytorch_lightning/profiler/pytorch.py
carmocca Mar 9, 2021
0f8b6ef
resolve tests
tchaton Mar 18, 2021
d219ae1
Merge branch 'master' into update-pytorch-profiler
tchaton Mar 18, 2021
8a3d3cf
resolve tests
tchaton Mar 18, 2021
af865ff
find output
tchaton Mar 18, 2021
6147e6e
try something
tchaton Mar 19, 2021
5053b4f
update
tchaton Mar 19, 2021
3ae2fbf
add support for test and predict
tchaton Mar 19, 2021
1d7ac88
update
tchaton Mar 19, 2021
64f8a58
update
tchaton Mar 19, 2021
655ff46
use getattr
tchaton Mar 19, 2021
3f5c4d6
test
tchaton Mar 19, 2021
ced0d66
test
tchaton Mar 19, 2021
662f8de
update
tchaton Mar 19, 2021
753f63b
tests
tchaton Mar 19, 2021
e6a6917
update
tchaton Mar 19, 2021
a7f7f4c
update
tchaton Mar 19, 2021
c221d7d
update
tchaton Mar 19, 2021
e39f6d7
update
tchaton Mar 19, 2021
e485850
update
tchaton Mar 19, 2021
00d355a
remove file
tchaton Mar 19, 2021
61da390
update
tchaton Mar 19, 2021
002f137
Merge branch 'update-pytorch-profiler' of https://github.com/PyTorchL…
tchaton Mar 19, 2021
e565e8a
update
tchaton Mar 19, 2021
6f2258f
update
tchaton Mar 19, 2021
883b242
update
tchaton Mar 21, 2021
9b957bd
update
tchaton Mar 21, 2021
70cc20d
test
tchaton Mar 21, 2021
226e0be
update#
tchaton Mar 21, 2021
27348c7
update
tchaton Mar 21, 2021
853d36c
update tests
tchaton Mar 21, 2021
9004e92
update
tchaton Mar 21, 2021
9a87c52
Merge branch 'master' into update-pytorch-profiler
carmocca Mar 22, 2021
fbbb9a2
Refactor basic profilers
carmocca Mar 22, 2021
2a82e05
Fixes
carmocca Mar 22, 2021
ff125e2
Unused import
carmocca Mar 22, 2021
01a760e
Introduce setup
carmocca Mar 22, 2021
b31831e
Profile on all ranks. Print to stdout on 0
carmocca Mar 22, 2021
f8a8772
Introduce dirpath + filename
carmocca Mar 22, 2021
aa4b7dd
CHANGELOG
carmocca Mar 22, 2021
8e3034e
Add tests. Address comments
carmocca Mar 22, 2021
e4e0dd6
add `on_run_stage_setup`
tchaton Mar 22, 2021
d0fdbb9
add on_run_stage_setup function
tchaton Mar 22, 2021
1a16bb3
update
tchaton Mar 22, 2021
52fa69b
add test for RegisterRecordFunction
tchaton Mar 22, 2021
63b6988
update lightnng flow direction
tchaton Mar 22, 2021
1cf5a64
move variable to private
tchaton Mar 22, 2021
a05acdd
remove trace
tchaton Mar 22, 2021
af72dff
Merge branch 'master' into refactor-base-profilers
tchaton Mar 22, 2021
59c941b
Undo code that should be in 3/4
carmocca Mar 22, 2021
da0f310
Multi-stage multi-rank
carmocca Mar 22, 2021
59c1b4c
2/5 changes
carmocca Mar 22, 2021
dd1dce0
Pass stage in __del__
carmocca Mar 22, 2021
12d014b
Merge branch 'master' into refactor-base-profilers
carmocca Mar 22, 2021
097a426
Remove TODOs
carmocca Mar 22, 2021
4d529fa
Describe on_evaluation_end. Add tests
carmocca Mar 22, 2021
58dcd4e
Typo
carmocca Mar 22, 2021
c37162f
Address comments
carmocca Mar 22, 2021
4c5f1f3
deepcopy tests
carmocca Mar 22, 2021
5ed73fb
Advanced teardown
carmocca Mar 22, 2021
897f8e5
Fix teardown test
carmocca Mar 22, 2021
e42be2a
Fix tests
carmocca Mar 22, 2021
32c301c
Minor change
carmocca Mar 22, 2021
af0c8ad
Update CHANGELOG.md
carmocca Mar 22, 2021
29a73c5
Fix test
carmocca Mar 22, 2021
d6ede58
Merge branch 'refactor-base-profilers' into update-pytorch-profiler
carmocca Mar 22, 2021
0dc1e06
Quick fixes
carmocca Mar 22, 2021
cb756b8
Fix 6522
carmocca Mar 22, 2021
758b942
resolve ddp tests
tchaton Mar 23, 2021
fca4eb2
resolve tests
tchaton Mar 23, 2021
2919a39
resolve some tests
tchaton Mar 23, 2021
d7ca5fa
update tests
tchaton Mar 23, 2021
34b7991
Merge branch 'refactor-base-profilers' into update-pytorch-profiler
tchaton Mar 23, 2021
b3ffe64
resolve tests
tchaton Mar 23, 2021
e0d8308
Merge branch 'master' into update-pytorch-profiler
tchaton Mar 23, 2021
97c87d3
resolve tests
tchaton Mar 23, 2021
ae31f00
Missed fixes from 3/5
carmocca Mar 23, 2021
78970d5
Fixes
carmocca Mar 23, 2021
ba067fd
Broken refactor
carmocca Mar 23, 2021
f916013
Missed stage
carmocca Mar 23, 2021
9a1b1b6
Minor changes
carmocca Mar 23, 2021
04abd0a
resolve tests
tchaton Mar 23, 2021
ab1218e
Merge branch 'update-pytorch-profiler' of https://github.com/PyTorchL…
tchaton Mar 23, 2021
0230330
Update CHANGELOG
carmocca Mar 23, 2021
cba643b
resolve bug
tchaton Mar 23, 2021
85bfc7d
Merge branch 'update-pytorch-profiler' of https://github.com/PyTorchL…
tchaton Mar 23, 2021
af209f5
remove print
tchaton Mar 23, 2021
bb813bb
Typo
carmocca Mar 23, 2021
624a85f
Cleanup
carmocca Mar 23, 2021
1732ece
resolve ddp test
tchaton Mar 23, 2021
f0c1675
remove barrier
tchaton Mar 23, 2021
a13664d
Merge branch 'master' into update-pytorch-profiler
tchaton Mar 23, 2021
374f0da
update
tchaton Mar 23, 2021
6e948ca
Smaller model
carmocca Mar 23, 2021
e0d8623
add check for emit_nvtx
tchaton Mar 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Added `AbstractProfiler` interface ([#6621](https://github.com/PyTorchLightning/pytorch-lightning/pull/6621))


- Added support for including module names for forward in the autograd trace of `PyTorchProfiler` ([#6349](https://github.com/PyTorchLightning/pytorch-lightning/pull/6349))


- Added `outputs` parameter to callback's `on_validation_epoch_end` & `on_test_epoch_end` hooks ([#6120](https://github.com/PyTorchLightning/pytorch-lightning/pull/6120))


Expand All @@ -72,6 +75,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Changed profilers to save separate report files per state and rank ([#6621](https://github.com/PyTorchLightning/pytorch-lightning/pull/6621))


- Changed `PyTorchProfiler` to use `torch.autograd.profiler.record_function` to record functions ([#6349](https://github.com/PyTorchLightning/pytorch-lightning/pull/6349))


### Deprecated

- `period` has been deprecated in favor of `every_n_val_epochs` in the `ModelCheckpoint` callback ([#6146](https://github.com/PyTorchLightning/pytorch-lightning/pull/6146))
Expand All @@ -83,6 +89,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Deprecated `Profiler(output_filename)` in favor of `dirpath` and `filename` ([#6621](https://github.com/PyTorchLightning/pytorch-lightning/pull/6621))


- Deprecated `PytorchProfiler(profiled_functions)` in favor of `record_functions` ([#6349](https://github.com/PyTorchLightning/pytorch-lightning/pull/6349))


- Deprecated metrics in favor of `torchmetrics` ([#6505](https://github.com/PyTorchLightning/pytorch-lightning/pull/6505),

[#6530](https://github.com/PyTorchLightning/pytorch-lightning/pull/6530),
Expand Down
12 changes: 5 additions & 7 deletions pytorch_lightning/profiler/profilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,15 @@ def _prepare_filename(self) -> str:
filename += f"{self._stage}-"
filename += str(self.filename)
if self._local_rank is not None:
filename += f"-{self.local_rank}"
filename += f"-{self._local_rank}"
filename += ".txt"
return filename

def _prepare_streams(self) -> None:
if self._write_stream is not None:
return
if self.filename:
dirpath = self.dirpath or self._log_dir
filepath = os.path.join(dirpath, self._prepare_filename())
filepath = os.path.join(self.dirpath, self._prepare_filename())
fs = get_filesystem(filepath)
file = fs.open(filepath, "a")
self._output_file = file
Expand Down Expand Up @@ -175,8 +174,7 @@ def setup(
self._stage = stage
self._local_rank = local_rank
self._log_dir = log_dir
if self.dirpath is None:
self.dirpath = self._log_dir
self.dirpath = self.dirpath or log_dir

def teardown(self, stage: Optional[str] = None) -> None:
"""
Expand All @@ -202,8 +200,8 @@ def summary(self) -> str:
raise NotImplementedError

@property
def local_rank(self):
return '0' if self._local_rank is None else self._local_rank
def local_rank(self) -> int:
return 0 if self._local_rank is None else self._local_rank


class PassThroughProfiler(BaseProfiler):
Expand Down
Loading