Skip to content

Commit 3a30760

Browse files
authored
Merge branch 'master' into bugfix/5007
2 parents e60215c + 5ad5ba5 commit 3a30760

File tree

33 files changed

+241
-177
lines changed

33 files changed

+241
-177
lines changed

.github/workflows/docs-link.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Docs Link
2+
3+
on: [status]
4+
5+
jobs:
6+
circleci_artifacts_redirector_job:
7+
runs-on: ubuntu-20.04
8+
steps:
9+
- uses: larsoner/circleci-artifacts-redirector-action@master
10+
with:
11+
repo-token: ${{ secrets.GITHUB_TOKEN }}
12+
artifact-path: 0/html/index.html
13+
circleci-jobs: build-Docs
14+
job-title: Check the rendered docs here!

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
412412

413413
- Removed `Strategy.optimizer_zero_grad` ([#11246](https://github.com/PyTorchLightning/pytorch-lightning/pull/11246))
414414

415+
416+
- Removed `Strategy.on_gpu` ([#11537](https://github.com/PyTorchLightning/pytorch-lightning/pull/11537))
417+
418+
419+
- Removed `Strategy.on_tpu` property ([#11536](https://github.com/PyTorchLightning/pytorch-lightning/pull/11536))
420+
421+
422+
- Removed access to `_short_id` in `NeptuneLogger` ([#11517](https://github.com/PyTorchLightning/pytorch-lightning/pull/11517))
423+
424+
415425
### Fixed
416426

417427
- Fixed security vulnerabilities CVE-2020-1747 and CVE-2020-14343 caused by the `PyYAML` dependency ([#11099](https://github.com/PyTorchLightning/pytorch-lightning/pull/11099))
@@ -432,12 +442,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
432442
- Fixed wrong typehint for `Trainer.lightning_optimizers` ([#11155](https://github.com/PyTorchLightning/pytorch-lightning/pull/11155))
433443

434444

445+
- Fixed the format of the configuration saved automatically by the CLI's `SaveConfigCallback` ([#11532](https://github.com/PyTorchLightning/pytorch-lightning/pull/11532))
446+
447+
435448
- Fixed type promotion when tensors of higher category than float are logged ([#11401](https://github.com/PyTorchLightning/pytorch-lightning/pull/11401))
436449

437450

438451
- Fixed the lr-scheduler state not being dumped to checkpoint when using the deepspeed strategy ([#11307](https://github.com/PyTorchLightning/pytorch-lightning/pull/11307))
439452

440453

454+
- Fixed `SimpleProfiler` summary ([#11414](https://github.com/PyTorchLightning/pytorch-lightning/pull/11414))
455+
456+
441457
- Disbled sampler replacement when using `IterableDataset` ([#11507](https://github.com/PyTorchLightning/pytorch-lightning/pull/11507))
442458

443459

docs/source/accelerators/gpu.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ Lightning supports multiple ways of doing distributed training.
3636

3737
|
3838
39+
Model Parallel Training
40+
-----------------------
41+
42+
Check out the :ref:`Model Parallel Guide <model_parallel>` documentation.
43+
3944
----------
4045

4146
Preparing your code

docs/source/advanced/advanced_gpu.rst

Lines changed: 36 additions & 32 deletions
Large diffs are not rendered by default.

docs/source/common/loggers.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,10 @@ The :class:`~pytorch_lightning.loggers.WandbLogger` is available anywhere except
212212
class MyModule(LightningModule):
213213
def any_lightning_module_function_or_hook(self):
214214
some_img = fake_image()
215-
self.log({"generated_images": [wandb.Image(some_img, caption="...")]})
215+
# Option 1
216+
self.logger.experiment.log({"generated_images": [wandb.Image(some_img, caption="...")]})
217+
# Option 2 for specifically logging images
218+
self.logger.log_image(key="generated_images", images=[some_img])
216219
217220
.. seealso::
218221
- :class:`~pytorch_lightning.loggers.WandbLogger` docs.

pytorch_lightning/loggers/neptune.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,10 @@ def __init__(
293293
def _retrieve_run_data(self):
294294
try:
295295
self._run_instance.wait()
296-
self._run_short_id = self.run._short_id # skipcq: PYL-W0212
296+
self._run_short_id = self._run_instance["sys/id"].fetch()
297297
self._run_name = self._run_instance["sys/name"].fetch()
298298
except NeptuneOfflineModeFetchException:
299+
self._run_short_id = "OFFLINE"
299300
self._run_name = "offline-name"
300301

301302
@property

pytorch_lightning/profiler/simple.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ def __init__(
4545
filename: If present, filename where the profiler results will be saved instead of printing to stdout.
4646
The ``.txt`` extension will be used automatically.
4747
48+
extended: If ``True``, adds extra columns representing number of calls and percentage of total time spent on
49+
respective action.
50+
4851
Raises:
4952
ValueError:
5053
If you attempt to start an action which has already started, or
@@ -73,7 +76,8 @@ def _make_report(self) -> Tuple[list, float]:
7376
total_duration = time.monotonic() - self.start_time
7477
report = [[a, d, 100.0 * np.sum(d) / total_duration] for a, d in self.recorded_durations.items()]
7578
report.sort(key=lambda x: x[2], reverse=True)
76-
return report, total_duration
79+
total_calls = sum(len(x[1]) for x in report)
80+
return report, total_calls, total_duration
7781

7882
def summary(self) -> str:
7983
sep = os.linesep
@@ -88,16 +92,17 @@ def summary(self) -> str:
8892
max_key = max(len(k) for k in self.recorded_durations.keys())
8993

9094
def log_row(action, mean, num_calls, total, per):
91-
row = f"{sep}{action:<{max_key}s}\t| {mean:<15}\t|"
92-
row += f"{num_calls:<15}\t| {total:<15}\t| {per:<15}\t|"
95+
row = f"{sep}| {action:<{max_key}s}\t| {mean:<15}\t|"
96+
row += f" {num_calls:<15}\t| {total:<15}\t| {per:<15}\t|"
9397
return row
9498

95-
output_string += log_row("Action", "Mean duration (s)", "Num calls", "Total time (s)", "Percentage %")
96-
output_string_len = len(output_string)
97-
output_string += f"{sep}{'-' * output_string_len}"
98-
report, total_duration = self._make_report()
99-
output_string += log_row("Total", "-", "_", f"{total_duration:.5}", "100 %")
100-
output_string += f"{sep}{'-' * output_string_len}"
99+
header_string = log_row("Action", "Mean duration (s)", "Num calls", "Total time (s)", "Percentage %")
100+
output_string_len = len(header_string.expandtabs())
101+
sep_lines = f"{sep}{'-' * output_string_len}"
102+
output_string += sep_lines + header_string + sep_lines
103+
report, total_calls, total_duration = self._make_report()
104+
output_string += log_row("Total", "-", f"{total_calls:}", f"{total_duration:.5}", "100 %")
105+
output_string += sep_lines
101106
for action, durations, duration_per in report:
102107
output_string += log_row(
103108
action,
@@ -106,15 +111,20 @@ def log_row(action, mean, num_calls, total, per):
106111
f"{np.sum(durations):.5}",
107112
f"{duration_per:.5}",
108113
)
114+
output_string += sep_lines
109115
else:
116+
max_key = max(len(k) for k in self.recorded_durations)
110117

111118
def log_row(action, mean, total):
112-
return f"{sep}{action:<20s}\t| {mean:<15}\t| {total:<15}"
119+
return f"{sep}| {action:<{max_key}s}\t| {mean:<15}\t| {total:<15}\t|"
113120

114-
output_string += log_row("Action", "Mean duration (s)", "Total time (s)")
115-
output_string += f"{sep}{'-' * 65}"
121+
header_string = log_row("Action", "Mean duration (s)", "Total time (s)")
122+
output_string_len = len(header_string.expandtabs())
123+
sep_lines = f"{sep}{'-' * output_string_len}"
124+
output_string += sep_lines + header_string + sep_lines
116125

117126
for action, durations in self.recorded_durations.items():
118127
output_string += log_row(action, f"{np.mean(durations):.5}", f"{np.sum(durations):.5}")
128+
output_string += sep_lines
119129
output_string += sep
120130
return output_string

pytorch_lightning/strategies/ddp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def _register_ddp_hooks(self) -> None:
296296
# In 1.8, DDP communication hooks only work with NCCL backend and SPSD (single process single device) mode
297297
# Since 1.9, DDP communication hooks can work on all backends.
298298
if _TORCH_GREATER_EQUAL_1_9 or (
299-
_TORCH_GREATER_EQUAL_1_8 and self.on_gpu and self._is_single_process_single_device
299+
_TORCH_GREATER_EQUAL_1_8 and self.root_device.type == "cuda" and self._is_single_process_single_device
300300
):
301301
register_ddp_comm_hook(
302302
model=self.model,
@@ -514,7 +514,7 @@ def teardown(self) -> None:
514514
if self.sync_batchnorm:
515515
self.model = _revert_sync_batchnorm(self.model)
516516

517-
if self.on_gpu:
517+
if self.root_device.type == "cuda":
518518
# GPU teardown
519519
log.detail(f"{self.__class__.__name__}: moving model to CPU")
520520
self.lightning_module.cpu()

pytorch_lightning/strategies/ddp_spawn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def pre_configure_ddp(self):
200200
def _register_ddp_hooks(self) -> None:
201201
# currently, DDP communication hooks only work with NCCL backend and SPSD (single process single device) mode
202202
# https://github.com/pytorch/pytorch/blob/v1.8.0/torch/nn/parallel/distributed.py#L1080-L1084
203-
if _TORCH_GREATER_EQUAL_1_8 and self.on_gpu and self._is_single_process_single_device:
203+
if _TORCH_GREATER_EQUAL_1_8 and self.root_device.type == "cuda" and self._is_single_process_single_device:
204204
register_ddp_comm_hook(
205205
model=self.model,
206206
ddp_comm_state=self._ddp_comm_state,
@@ -378,7 +378,7 @@ def teardown(self) -> None:
378378
if self.sync_batchnorm:
379379
self.model = _revert_sync_batchnorm(self.model)
380380

381-
if self.on_gpu:
381+
if self.root_device.type == "cuda":
382382
# GPU teardown
383383
self.lightning_module.cpu()
384384
# clean up memory

pytorch_lightning/strategies/dp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def test_step_end(self, output):
153153

154154
def teardown(self) -> None:
155155
super().teardown()
156-
if self.on_gpu:
156+
if self.root_device.type == "cuda":
157157
# GPU teardown
158158
self.lightning_module.cpu()
159159
# clean up memory

0 commit comments

Comments
 (0)