From 2bfb9399c3872e9af1bc04d20df05dee91251a36 Mon Sep 17 00:00:00 2001 From: Jarl Saether Date: Wed, 30 Oct 2024 11:53:43 +0100 Subject: [PATCH] fix more linting errors --- src/itwinai/torch/monitoring/plotting.py | 2 +- .../torch-scaling-test/ddp_trainer.py | 17 +++++++---------- .../torch-scaling-test/deepspeed_trainer.py | 19 ++++++++----------- .../torch-scaling-test/horovod_trainer.py | 18 ++++++++---------- 4 files changed, 24 insertions(+), 32 deletions(-) diff --git a/src/itwinai/torch/monitoring/plotting.py b/src/itwinai/torch/monitoring/plotting.py index 1cf5910d..09c79b98 100644 --- a/src/itwinai/torch/monitoring/plotting.py +++ b/src/itwinai/torch/monitoring/plotting.py @@ -1,4 +1,4 @@ -from typing import Tuple, List +from typing import Tuple import matplotlib import matplotlib.pyplot as plt diff --git a/tutorials/distributed-ml/torch-scaling-test/ddp_trainer.py b/tutorials/distributed-ml/torch-scaling-test/ddp_trainer.py index 3b062c21..46389a9b 100755 --- a/tutorials/distributed-ml/torch-scaling-test/ddp_trainer.py +++ b/tutorials/distributed-ml/torch-scaling-test/ddp_trainer.py @@ -1,28 +1,25 @@ """ Scaling test of torch Distributed Data Parallel on Imagenet using Resnet. """ -from typing import Optional import argparse -import sys import os -from timeit import default_timer as timer +import sys import time +from timeit import default_timer as timer +from typing import Optional import torch import torch.distributed as dist import torch.nn as nn import torch.nn.functional as F +import torchvision from torch.utils.data import DataLoader from torch.utils.data.distributed import DistributedSampler -import torchvision +from utils import imagenet_dataset -from itwinai.parser import ArgumentParser as ItAIArgumentParser from itwinai.loggers import EpochTimeTracker -from itwinai.torch.reproducibility import ( - seed_worker, set_seed -) - -from utils import imagenet_dataset +from itwinai.parser import ArgumentParser as ItAIArgumentParser +from itwinai.torch.reproducibility import seed_worker, set_seed def parse_params(): diff --git a/tutorials/distributed-ml/torch-scaling-test/deepspeed_trainer.py b/tutorials/distributed-ml/torch-scaling-test/deepspeed_trainer.py index 5434a8fa..1cc5f848 100644 --- a/tutorials/distributed-ml/torch-scaling-test/deepspeed_trainer.py +++ b/tutorials/distributed-ml/torch-scaling-test/deepspeed_trainer.py @@ -1,28 +1,25 @@ """ Scaling test of Microsoft Deepspeed on Imagenet using Resnet. """ -from typing import Optional import argparse -import sys import os -from timeit import default_timer as timer +import sys import time -import deepspeed +from timeit import default_timer as timer +from typing import Optional +import deepspeed import torch import torch.distributed as dist import torch.nn.functional as F +import torchvision from torch.utils.data import DataLoader from torch.utils.data.distributed import DistributedSampler -import torchvision +from utils import imagenet_dataset -from itwinai.parser import ArgumentParser as ItAIArgumentParser from itwinai.loggers import EpochTimeTracker -from itwinai.torch.reproducibility import ( - seed_worker, set_seed -) - -from utils import imagenet_dataset +from itwinai.parser import ArgumentParser as ItAIArgumentParser +from itwinai.torch.reproducibility import seed_worker, set_seed def parse_params(): diff --git a/tutorials/distributed-ml/torch-scaling-test/horovod_trainer.py b/tutorials/distributed-ml/torch-scaling-test/horovod_trainer.py index 2b5048ed..6e27d921 100755 --- a/tutorials/distributed-ml/torch-scaling-test/horovod_trainer.py +++ b/tutorials/distributed-ml/torch-scaling-test/horovod_trainer.py @@ -1,29 +1,27 @@ """ Scaling test of Horovod on Imagenet using Resnet. """ -from typing import Optional import argparse import os import sys -from timeit import default_timer as timer import time +from timeit import default_timer as timer +from typing import Optional +import horovod.torch as hvd import torch + # import torch.multiprocessing as mp import torch.nn.functional as F import torch.optim as optim +import torchvision from torch.utils.data import DataLoader from torch.utils.data.distributed import DistributedSampler -import horovod.torch as hvd -import torchvision +from utils import imagenet_dataset -from itwinai.parser import ArgumentParser as ItAIArgumentParser from itwinai.loggers import EpochTimeTracker -from itwinai.torch.reproducibility import ( - seed_worker, set_seed -) - -from utils import imagenet_dataset +from itwinai.parser import ArgumentParser as ItAIArgumentParser +from itwinai.torch.reproducibility import seed_worker, set_seed def parse_params():