From eb55a178b9d79b123d3f3c37e2e907b01d558d2e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 6 Sep 2024 19:36:12 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .azure/README.md | 14 +++++++------- .github/ISSUE_TEMPLATE/bug_report.md | 6 +++--- .github/ISSUE_TEMPLATE/documentation.md | 4 ++-- examples/fabric/image_classifier/train_fabric.py | 8 +------- src/lightning_habana/__init__.py | 2 +- .../pytorch/plugins/deepspeed_precision.py | 4 ++-- src/lightning_habana/pytorch/plugins/precision.py | 2 +- 7 files changed, 17 insertions(+), 23 deletions(-) diff --git a/.azure/README.md b/.azure/README.md index 530da019..41c1cf05 100644 --- a/.azure/README.md +++ b/.azure/README.md @@ -5,10 +5,10 @@ In general follow instructions in [Bare Metal Fresh OS Installation](https://docs.habana.ai/en/v1.15.0/Installation_Guide/Bare_Metal_Fresh_OS.html#) and in particular [Habana Driver Unattended Upgrade](https://docs.habana.ai/en/v1.15.0/Installation_Guide/Bare_Metal_Fresh_OS.html#habana-driver-unattended-upgrade). 1. check what is the actual state and version of HW - `hl-smi` -1. check the actual OS version - `lsb_release -a` -1. update sources - `sudo apt update --fix-missing` -1. run upgrade to the latest - `sudo apt upgrade` -1. reboot the machine... +2. check the actual OS version - `lsb_release -a` +3. update sources - `sudo apt update --fix-missing` +4. run upgrade to the latest - `sudo apt upgrade` +5. reboot the machine... ### Troubleshooting @@ -25,7 +25,7 @@ In some cases you may get stack with hanged libs linked to past kernel (for exam sudo mv /var/lib/dpkg/info_old /var/lib/dpkg/info sudo apt-get update && sudo apt-get -f install ``` -1. purge the hanging package +2. purge the hanging package ```bash apt list --installed | grep habana sudo rm /var/lib/dpkg/info/habanalabs-dkms* @@ -33,11 +33,11 @@ In some cases you may get stack with hanged libs linked to past kernel (for exam sudo apt -f install sudo apt purge habanalabs-dkms ``` -1. if the package folder hangs, drop it: +3. if the package folder hangs, drop it: ```bash sudo rm -rf /var/lib/dkms/habanalabs-dkms ``` -1. install all, if some failed try rerun the script +4. install all, if some failed try rerun the script ```bash wget -nv https://vault.habana.ai/artifactory/gaudi-installer/latest/habanalabs-installer.sh chmod +x habanalabs-installer.sh diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index a78343c3..812b3ee7 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -15,9 +15,9 @@ assignees: '' Steps to reproduce the behavior: 1. Go to '...' -1. Run '....' -1. Scroll down to '....' -1. See error +2. Run '....' +3. Scroll down to '....' +4. See error diff --git a/.github/ISSUE_TEMPLATE/documentation.md b/.github/ISSUE_TEMPLATE/documentation.md index c74b3408..ef18dcaf 100644 --- a/.github/ISSUE_TEMPLATE/documentation.md +++ b/.github/ISSUE_TEMPLATE/documentation.md @@ -11,7 +11,7 @@ assignees: '' For typos and doc fixes, please go ahead and: 1. Create an issue. -1. Fix the typo. -1. Submit a PR. +2. Fix the typo. +3. Submit a PR. Thanks! diff --git a/examples/fabric/image_classifier/train_fabric.py b/examples/fabric/image_classifier/train_fabric.py index 8086ca58..7cc218ca 100644 --- a/examples/fabric/image_classifier/train_fabric.py +++ b/examples/fabric/image_classifier/train_fabric.py @@ -108,13 +108,7 @@ def run(hparams): optimizer.step() if (batch_idx == 0) or ((batch_idx + 1) % hparams.log_interval == 0): print( - "Train Epoch: {} [{}/{} ({:.0f}%)]\tLoss: {:.6f}".format( - epoch, - batch_idx * len(data), - len(train_loader.dataset), - 100.0 * batch_idx / len(train_loader), - loss.item(), - ) + f"Train Epoch: {epoch} [{batch_idx * len(data)}/{len(train_loader.dataset)} ({100.0 * batch_idx / len(train_loader):.0f}%)]\tLoss: {loss.item():.6f}" ) if hparams.dry_run: break diff --git a/src/lightning_habana/__init__.py b/src/lightning_habana/__init__.py index 014402e3..4c82366e 100644 --- a/src/lightning_habana/__init__.py +++ b/src/lightning_habana/__init__.py @@ -16,7 +16,7 @@ from lightning_utilities import compare_version -from lightning_habana.__about__ import * # noqa: F401, F403 +from lightning_habana.__about__ import * # noqa: F403 from lightning_habana.pytorch.accelerator import HPUAccelerator from lightning_habana.pytorch.datamodule.datamodule import HPUDataModule from lightning_habana.pytorch.plugins.deepspeed_precision import HPUDeepSpeedPrecisionPlugin diff --git a/src/lightning_habana/pytorch/plugins/deepspeed_precision.py b/src/lightning_habana/pytorch/plugins/deepspeed_precision.py index da0cbf14..a8f79105 100644 --- a/src/lightning_habana/pytorch/plugins/deepspeed_precision.py +++ b/src/lightning_habana/pytorch/plugins/deepspeed_precision.py @@ -103,7 +103,7 @@ def backward( "You have overridden the `LightningModule.backward` hook but it will be ignored since DeepSpeed handles" " the backward logic internally." ) - deepspeed_engine: "deepspeed.DeepSpeedEngine" = model.trainer.model + deepspeed_engine: deepspeed.DeepSpeedEngine = model.trainer.model deepspeed_engine.backward(tensor, *args, **kwargs) def optimizer_step( @@ -124,7 +124,7 @@ def optimizer_step( "Skipping backward by returning `None` from your `training_step` is not supported by `DeepSpeed`" ) # DeepSpeed handles the optimizer step internally - deepspeed_engine: "deepspeed.DeepSpeedEngine" = model.trainer.model + deepspeed_engine: deepspeed.DeepSpeedEngine = model.trainer.model return deepspeed_engine.step(**kwargs) def clip_gradients( diff --git a/src/lightning_habana/pytorch/plugins/precision.py b/src/lightning_habana/pytorch/plugins/precision.py index 37cf20c2..af5d4f60 100644 --- a/src/lightning_habana/pytorch/plugins/precision.py +++ b/src/lightning_habana/pytorch/plugins/precision.py @@ -92,7 +92,7 @@ def __init__( self.device = device self.precision = precision - self.recipe: Union[Mapping[str, Any], "DelayedScaling"] = None + self.recipe: Union[Mapping[str, Any], DelayedScaling] = None self.replace_layers = False self.fp8_training_available = False self.fp8_inference_available = False