Skip to content

Commit

Permalink
Move logger.py to core
Browse files Browse the repository at this point in the history
Add moved logger file to sparseml/pytorch/utils/__init__.py for backwards compatibility
  • Loading branch information
rahul-tuli committed Oct 17, 2023
1 parent 6a2b650 commit 5643369
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/sparseml/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from .framework import *
from .framework_object import *
from .lifecycle import *
from .logger import *
from .model import *
from .modifier import *
from .optimizer import *
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
from sparseml.pytorch.sparsification.pruning.mask_params import ModuleParamPruningMask
from sparseml.pytorch.sparsification.pruning.scorer import PruningParamsScorer
from sparseml.pytorch.utils import (
LoggerManager,
NamedLayerParam,
get_named_layers_and_params_by_regex,
get_prunable_layers,
tensor_sparsity,
)
from sparseml.pytorch.utils.logger import LoggerManager
from sparseml.sparsification import SparsificationTypes
from sparseml.utils import (
ALL_PRUNABLE_TOKEN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@
ScheduledModifier,
ScheduledUpdateModifier,
)
from sparseml.pytorch.utils import get_layer, get_prunable_layers, replace_layer
from sparseml.pytorch.utils.logger import BaseLogger
from sparseml.pytorch.utils import (
BaseLogger,
get_layer,
get_prunable_layers,
replace_layer,
)
from sparseml.sparsification import SparsificationTypes
from sparseml.utils import ALL_PRUNABLE_TOKEN, ALL_TOKEN, validate_str_iterable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
BaseGradualPruningModifier,
)
from sparseml.pytorch.sparsification.pruning.scorer import PruningParamsGradScorer
from sparseml.pytorch.utils import GradSampler
from sparseml.pytorch.utils.logger import BaseLogger
from sparseml.pytorch.utils import BaseLogger, GradSampler


__all__ = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
BaseGradualPruningModifier,
)
from sparseml.pytorch.sparsification.pruning.scorer import PruningParamsGradScorer
from sparseml.pytorch.utils import MEMORY_BOUNDED, GradSampler
from sparseml.pytorch.utils.logger import BaseLogger
from sparseml.pytorch.utils import MEMORY_BOUNDED, BaseLogger, GradSampler
from sparseml.utils import interpolate


Expand Down
12 changes: 6 additions & 6 deletions src/sparseml/pytorch/torchvision/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@
from sparseml.pytorch.optim import ScheduledModifierManager
from sparseml.pytorch.torchvision import presets, transforms, utils
from sparseml.pytorch.torchvision.sampler import RASampler
from sparseml.pytorch.utils.helpers import (
default_device,
download_framework_model_by_recipe_type,
torch_distributed_zero_first,
)
from sparseml.pytorch.utils.logger import (
from sparseml.pytorch.utils import (
LoggerManager,
PythonLogger,
TensorBoardLogger,
WANDBLogger,
)
from sparseml.pytorch.utils.helpers import (
default_device,
download_framework_model_by_recipe_type,
torch_distributed_zero_first,
)
from sparseml.pytorch.utils.model import load_model, model_to_device
from sparsezoo import Model

Expand Down
2 changes: 1 addition & 1 deletion src/sparseml/pytorch/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@

# flake8: noqa

from ...core.logger import *
from ..base import check_torch_install as _check_torch_install
from .benchmarker import *
from .distributed import *
from .exporter import *
from .helpers import *
from .log_sparsification_info import *
from .logger import *
from .loss import *
from .model import *
from .module import *
Expand Down
2 changes: 1 addition & 1 deletion src/sparseml/pytorch/utils/log_sparsification_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import torch

from sparseml.pytorch.utils.logger import BaseLogger
from sparseml.pytorch.utils import BaseLogger
from sparseml.pytorch.utils.sparsification_info.module_sparsification_info import (
ModuleSparsificationInfo,
)
Expand Down
2 changes: 1 addition & 1 deletion src/sparseml/pytorch/utils/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
from torch.utils.hooks import RemovableHandle
from tqdm import auto

from sparseml.pytorch.utils import BaseLogger
from sparseml.pytorch.utils.helpers import (
get_optim_learning_rate,
tensors_batch_size,
tensors_module_forward,
tensors_to_device,
)
from sparseml.pytorch.utils.logger import BaseLogger
from sparseml.pytorch.utils.loss import DEFAULT_LOSS_KEY, LossWrapper


Expand Down
8 changes: 6 additions & 2 deletions src/sparseml/yolov8/trainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@
from sparseml.optim.helpers import load_recipe_yaml_str
from sparseml.pytorch.optim.manager import ScheduledModifierManager
from sparseml.pytorch.sparsification.quantization import skip_onnx_input_quantize
from sparseml.pytorch.utils import ModuleExporter
from sparseml.pytorch.utils import (
LoggerManager,
ModuleExporter,
PythonLogger,
WANDBLogger,
)
from sparseml.pytorch.utils.helpers import download_framework_model_by_recipe_type
from sparseml.pytorch.utils.logger import LoggerManager, PythonLogger, WANDBLogger
from sparseml.yolov8.modules import Bottleneck, Conv
from sparseml.yolov8.utils import (
check_coco128_segmentation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import pytest

from sparseml.pytorch.utils import (
from sparseml.core.logger import (
LambdaLogger,
LoggerManager,
PythonLogger,
Expand Down

0 comments on commit 5643369

Please sign in to comment.