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

Deprecate many datasets and models #2605

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions composer/callbacks/mlperf.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ def _get_dataloader_stats(self, dataloader: Iterable):
# attempt to import ffcv and test if its an ffcv loader.
import ffcv # type: ignore

warnings.warn(DeprecationWarning('ffcv is deprecated and will be removed in v0.18'))

if isinstance(dataloader, ffcv.loader.Loader):
# Use the cached attribute ffcv.init_traversal_order to compute number of samples
return (
Expand Down
15 changes: 15 additions & 0 deletions composer/datasets/ade20k.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""

import os
import warnings
from math import ceil
from typing import Any, Dict, Optional, Tuple, Union

Expand Down Expand Up @@ -50,6 +51,8 @@ def build_ade20k_transformations(split,
image_transforms (torch.nn.Module): Transformations to apply to the input image only.
target_transforms (torch.nn.Module): Transformations to apply to the target semantic segmentation mask only.
"""
warnings.warn(DeprecationWarning('build_ade20k_transformations is deprecated and will be removed in v0.18'))

if split == 'train':
both_transforms = torch.nn.Sequential(
RandomResizePair(
Expand Down Expand Up @@ -110,6 +113,8 @@ def build_ade20k_dataloader(
Default: ``true``.
**dataloader_kwargs (Dict[str, Any]): Additional settings for the dataloader (e.g. num_workers, etc.)
"""
warnings.warn(DeprecationWarning('build_ade20k_dataloader is deprecated and will be removed in v0.18'))

if global_batch_size % dist.get_world_size() != 0:
raise ValueError(
f'global_batch_size ({global_batch_size}) must be divisible by world_size ({dist.get_world_size()}).')
Expand Down Expand Up @@ -195,6 +200,8 @@ def build_streaming_ade20k_dataloader(
Defaults to ``None``, which is interpreted as the number of nodes of the initial run.
**dataloader_kwargs (Dict[str, Any]): Additional settings for the dataloader (e.g. num_workers, etc.)
"""
warnings.warn(DeprecationWarning('build_streaming_ade20k_dataloader is deprecated and will be removed in v0.18'))

if global_batch_size % dist.get_world_size() != 0:
raise ValueError(
f'global_batch_size ({global_batch_size}) must be divisible by world_size ({dist.get_world_size()}).')
Expand Down Expand Up @@ -274,6 +281,8 @@ def build_synthetic_ade20k_dataloader(
memory_format (:class:`composer.core.MemoryFormat`): Memory format of the tensors. Default: ``CONTIGUOUS_FORMAT``.
**dataloader_kwargs (Dict[str, Any]): Additional settings for the dataloader (e.g. num_workers, etc.)
"""
warnings.warn(DeprecationWarning('build_synthetic_ade20k_dataloader is deprecated and will be removed in v0.18'))

if global_batch_size % dist.get_world_size() != 0:
raise ValueError(
f'global_batch_size ({global_batch_size}) must be divisible by world_size ({dist.get_world_size()}).')
Expand Down Expand Up @@ -321,6 +330,7 @@ def __init__(self, min_scale: float, max_scale: float, base_size: Optional[Tuple
self.min_scale = min_scale
self.max_scale = max_scale
self.base_size = base_size
warnings.warn(DeprecationWarning('RandomResizePair is deprecated and will be removed in v0.18'))

def forward(self, sample: Tuple[Image.Image, Image.Image]):
image, target = sample
Expand Down Expand Up @@ -348,6 +358,7 @@ def __init__(self, crop_size: Tuple[int, int], class_max_percent: float = 1.0, n
self.crop_size = crop_size
self.class_max_percent = class_max_percent
self.num_retry = num_retry
warnings.warn(DeprecationWarning('RandomCropPair is deprecated and will be removed in v0.18'))

def forward(self, sample: Tuple[Image.Image, Image.Image]):
image, target = sample
Expand Down Expand Up @@ -392,6 +403,7 @@ class RandomHFlipPair(torch.nn.Module):
def __init__(self, probability: float = 0.5):
super().__init__()
self.probability = probability
warnings.warn(DeprecationWarning('RandomHFlipPair is deprecated and will be removed in v0.18'))

def forward(self, sample: Tuple[Image.Image, Image.Image]):
image, target = sample
Expand All @@ -413,6 +425,7 @@ def __init__(self, size: Tuple[int, int], fill: Union[int, Tuple[int, int, int]]
super().__init__()
self.size = size
self.fill = fill
warnings.warn(DeprecationWarning('PadToSize is deprecated and will be removed in v0.18'))

def forward(self, image: Image.Image):
padding = max(self.size[0] - image.height, 0), max(self.size[1] - image.width, 0)
Expand Down Expand Up @@ -440,6 +453,7 @@ def __init__(self, brightness: float, contrast: float, saturation: float, hue: f
self.contrast = contrast
self.saturation = saturation
self.hue = hue
warnings.warn(DeprecationWarning('PhotometricDistoration is deprecated and will be removed in v0.18'))

def forward(self, image: Image.Image):
if np.random.randint(2):
Expand Down Expand Up @@ -490,6 +504,7 @@ def __init__(self,
both_transforms: Optional[torch.nn.Module] = None,
image_transforms: Optional[torch.nn.Module] = None,
target_transforms: Optional[torch.nn.Module] = None):
warnings.warn(DeprecationWarning('ADE20k is deprecated and will be removed in v0.18'))
super().__init__()
self.datadir = datadir
self.split = split
Expand Down
3 changes: 3 additions & 0 deletions composer/datasets/brats.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import glob
import os
import random
import warnings

import numpy as np
import torch
Expand All @@ -36,6 +37,8 @@ def build_brats_dataloader(datadir: str,
global_batch_size (int): Global batch size.
**dataloader_kwargs (Dict[str, Any]): Additional settings for the dataloader (e.g. num_workers, etc.)
"""
warnings.warn(DeprecationWarning('build_brats_dataloader is deprecated and will be removed in v0.18'))

if global_batch_size % dist.get_world_size() != 0:
raise ValueError(
f'global_batch_size ({global_batch_size}) must be divisible by world_size ({dist.get_world_size()}).')
Expand Down
2 changes: 2 additions & 0 deletions composer/datasets/c4.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<https://commoncrawl.org>`_ dataset.
"""
import logging
import warnings
from typing import Any, Dict, Optional

from torch.utils.data import DataLoader
Expand Down Expand Up @@ -74,6 +75,7 @@ def build_streaming_c4_dataloader(
Defaults to ``None``, which is interpreted as the number of nodes of the initial run.
**dataloader_kwargs (Dict[str, Any]): Additional settings for the dataloader (e.g. num_workers, etc.)
"""
warnings.warn(DeprecationWarning('build_streaming_c4_dataloader is deprecated and will be removed in v0.18'))

try:
import transformers
Expand Down
5 changes: 5 additions & 0 deletions composer/datasets/cifar.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import os
import textwrap
import warnings
from typing import Any, Dict, List, Optional, Union

import torch
Expand Down Expand Up @@ -52,6 +53,8 @@ def build_cifar10_dataloader(
shuffle (bool): Shuffle the dataset. Default: ``True``.
**dataloader_kwargs (Any): Additional settings for the dataloader (e.g. num_workers, etc.)
"""
warnings.warn(DeprecationWarning('build_cifar10_dataloader is deprecated and will be removed in v0.18'))

if global_batch_size % dist.get_world_size() != 0:
raise ValueError(
f'global_batch_size ({global_batch_size}) must be divisible by world_size ({dist.get_world_size()}).')
Expand Down Expand Up @@ -119,6 +122,8 @@ def build_ffcv_cifar10_dataloader(
``False``.
datadir (str | None, optional): Path to the non-FFCV data directory.
"""
warnings.warn(DeprecationWarning('build_ffcv_cifar10_dataloader is deprecated and will be removed in v0.18'))

try:
import ffcv
from ffcv.fields.decoders import IntDecoder, SimpleRGBImageDecoder
Expand Down
3 changes: 3 additions & 0 deletions composer/datasets/ffcv_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

import logging
import warnings
from typing import Optional

import numpy as np
Expand All @@ -26,6 +27,7 @@ def _require_ffcv():


def ffcv_monkey_patches():
warnings.warn(DeprecationWarning('ffcv_monkey_patches is deprecated and will be removed in v0.18'))
_require_ffcv()

# ffcv's __len__ function is expensive as it always calls self.next_traversal_order which does shuffling.
Expand Down Expand Up @@ -62,6 +64,7 @@ def write_ffcv_dataset(dataset: Optional[Dataset] = None,
jpeg_quality (float): Quality to use for jpeg compression. Default: ``90``.
chunk_size (int): Size of chunks processed by each worker during conversion. Default: ``100``.
"""
warnings.warn(DeprecationWarning('write_ffcv_dataset is deprecated and will be removed in v0.18'))

_require_ffcv()
if dataset is None:
Expand Down
11 changes: 11 additions & 0 deletions composer/datasets/imagenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""

import os
import warnings
from typing import Any, Dict, List, Optional

import numpy as np
Expand Down Expand Up @@ -57,6 +58,8 @@ def build_imagenet_dataloader(
crop size (int): The crop size to use. Default: ``224``.
**dataloader_kwargs (Dict[str, Any]): Additional settings for the dataloader (e.g. num_workers, etc.)
"""
warnings.warn(DeprecationWarning('build_imagenet_dataloader is deprecated and will be removed in v0.18'))

if global_batch_size % dist.get_world_size() != 0:
raise ValueError(
f'global_batch_size ({global_batch_size}) must be divisible by world_size ({dist.get_world_size()}).')
Expand Down Expand Up @@ -126,6 +129,8 @@ def build_synthetic_imagenet_dataloader(
shuffle (bool): whether to shuffle the dataset. Default: ``True``.
**dataloader_kwargs (Dict[str, Any]): Additional settings for the dataloader (e.g. num_workers, etc.)
"""
warnings.warn(DeprecationWarning('build_synthetic_imagenet_dataloader is deprecated and will be removed in v0.18'))

if global_batch_size % dist.get_world_size() != 0:
raise ValueError(
f'global_batch_size ({global_batch_size}) must be divisible by world_size ({dist.get_world_size()}).')
Expand Down Expand Up @@ -166,6 +171,7 @@ def write_ffcv_imagenet(
split (str): 'train' or 'val'. Default: ``train``.
num_workers (int): Number of workers to use for conversion. Default: ``8``.
"""
warnings.warn(DeprecationWarning('write_ffcv_imagenet is deprecated and will be removed in v0.18'))

if dist.get_local_rank() == 0:
ds = ImageFolder(os.path.join(datadir, split))
Expand Down Expand Up @@ -205,6 +211,8 @@ def build_ffcv_imagenet_dataloader(
prefetch_factor (int): Number of batches to prefect. Default: ``2``.
num_workers (int): Number of workers. Default: ``8``.
"""
warnings.warn(DeprecationWarning('build_ffcv_imagenet_dataloader is deprecated and will be removed in v0.18'))

try:
import ffcv
from ffcv.fields.decoders import CenterCropRGBImageDecoder, IntDecoder, RandomResizedCropRGBImageDecoder
Expand Down Expand Up @@ -317,6 +325,9 @@ def build_streaming_imagenet1k_dataloader(
Defaults to ``None``, which is interpreted as the number of nodes of the initial run.
**dataloader_kwargs (Dict[str, Any]): Additional settings for the dataloader (e.g. num_workers, etc.)
"""
warnings.warn(
DeprecationWarning('build_streaming_imagenet1k_dataloader is deprecated and will be removed in v0.18'))

if global_batch_size % dist.get_world_size() != 0:
raise ValueError(
f'global_batch_size ({global_batch_size}) must be divisible by world_size ({dist.get_world_size()}).')
Expand Down
3 changes: 3 additions & 0 deletions composer/datasets/lm_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

import logging
import warnings
from typing import List, cast

from torch.utils.data import DataLoader, Dataset
Expand Down Expand Up @@ -48,6 +49,8 @@ def build_lm_dataloader(
``1.0``.
**dataloader_kwargs (Dict[str, Any]): Additional settings for the dataloader (e.g. num_workers, etc.)
"""
warnings.warn(DeprecationWarning('build_lm_dataloader is deprecated and will be removed in v0.18'))

if global_batch_size % dist.get_world_size() != 0:
raise ValueError(
f'global_batch_size ({global_batch_size}) must be divisible by world_size ({dist.get_world_size()}).')
Expand Down
3 changes: 3 additions & 0 deletions composer/datasets/mnist.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2022 MosaicML Composer authors
# SPDX-License-Identifier: Apache-2.0

import warnings
from typing import Any

from torch.utils.data import DataLoader
Expand Down Expand Up @@ -33,6 +34,8 @@ def build_mnist_dataloader(
shuffle (bool): Shuffle the dataset. Default: ``True``.
**dataloader_kwargs (Any): Additional settings for the dataloader (e.g. num_workers, etc.)
"""
warnings.warn(DeprecationWarning('build_mnist_dataloader is deprecated and will be removed in v0.18'))

if global_batch_size % dist.get_world_size() != 0:
raise ValueError(
f'global_batch_size ({global_batch_size}) must be divisible by world_size ({dist.get_world_size()}).')
Expand Down
4 changes: 4 additions & 0 deletions composer/datasets/synthetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from __future__ import annotations

import warnings
from typing import Callable, Optional, Sequence, Union

import torch
Expand Down Expand Up @@ -79,6 +80,8 @@ def __init__(self,
device: str = 'cpu',
memory_format: Union[str, MemoryFormat] = MemoryFormat.CONTIGUOUS_FORMAT,
transform: Optional[Callable] = None):
warnings.warn(DeprecationWarning('SyntheticBatchPairDataset is deprecated and will be removed in v0.18'))

self.total_dataset_size = total_dataset_size
self.data_shape = data_shape
self.num_unique_samples_to_create = num_unique_samples_to_create
Expand Down Expand Up @@ -187,6 +190,7 @@ def __init__(self,
num_classes: Optional[int] = None,
label_shape: Optional[Sequence[int]] = None,
transform: Optional[Callable] = None):
warnings.warn(DeprecationWarning('SyntheticPILDataset is deprecated and will be removed in v0.18'))
super().__init__(root='', transform=transform)
self._dataset = SyntheticBatchPairDataset(
total_dataset_size=total_dataset_size,
Expand Down
4 changes: 4 additions & 0 deletions composer/datasets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import logging
import textwrap
import warnings
from typing import Callable, List, Tuple, Union

import numpy as np
Expand Down Expand Up @@ -44,6 +45,7 @@ def __init__(self,
mean: Tuple[float, float, float],
std: Tuple[float, float, float],
ignore_background: bool = False):
warnings.warn(DeprecationWarning('NormalizationFn is deprecated and will be removed in v0.18'))
self.mean = mean
self.std = std
self.ignore_background = ignore_background
Expand Down Expand Up @@ -87,6 +89,7 @@ def pil_image_collate(
(torch.Tensor, torch.Tensor): Tuple of (image tensor, target tensor)
The image tensor will be four-dimensional (NCHW or NHWC, depending on the ``memory_format``).
"""
warnings.warn(DeprecationWarning('pil_image_collate is deprecated and will be removed in v0.18'))
imgs = [sample[0] for sample in batch]
w, h = imgs[0].size
image_tensor = torch.zeros((len(imgs), 3, h, w), dtype=torch.uint8).contiguous(memory_format=memory_format)
Expand Down Expand Up @@ -137,6 +140,7 @@ def add_vision_dataset_transform(dataset: VisionDataset, transform: Callable, is
Returns:
None: The ``dataset`` is modified in-place.
"""
warnings.warn(DeprecationWarning('add_vision_dataset_transform is deprecated and will be removed in v0.18'))

transform_added_logstring = textwrap.dedent(f"""\
Transform {transform} added to dataset.
Expand Down
5 changes: 5 additions & 0 deletions composer/models/bert/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from __future__ import annotations

import warnings
from typing import Optional

from torchmetrics import MeanSquaredError
Expand Down Expand Up @@ -70,6 +71,8 @@ def create_bert_mlm(use_pretrained: Optional[bool] = False,
model = create_bert_mlm()

"""
warnings.warn(DeprecationWarning('create_bert_mlm is deprecated and will be removed in v0.18'))

try:
import transformers
except ImportError as e:
Expand Down Expand Up @@ -175,6 +178,8 @@ def create_bert_classification(num_labels: int = 2,
For the classification case (when ``num_labels > 1``), the training loss is :class:`~torch.nn.CrossEntropyLoss`, and the train/validation
metrics are :class:`~torchmetrics.MulticlassAccuracy` and :class:`~torchmetrics.MatthewsCorrCoef`, as well as :class:`.BinaryF1Score` if ``num_labels == 2``.
"""
warnings.warn(DeprecationWarning('create_bert_classification is deprecated and will be removed in v0.18'))

try:
import transformers
except ImportError as e:
Expand Down
3 changes: 3 additions & 0 deletions composer/models/classify_mnist/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

"""A simple convolutional neural network extending :class:`.ComposerClassifier`."""

import warnings
from typing import List, Optional, Sequence, Union

import torch
Expand All @@ -19,6 +20,7 @@ class Model(nn.Module):
"""Toy convolutional neural network architecture in pytorch for MNIST."""

def __init__(self, initializers: Sequence[Union[str, Initializer]], num_classes: int = 10):
warnings.warn(DeprecationWarning('Model is deprecated and will be removed in v0.18'))
super().__init__()

self.num_classes = num_classes
Expand Down Expand Up @@ -65,6 +67,7 @@ def mnist_model(num_classes: int = 10, initializers: Optional[List[Initializer]]

model = mnist_model()
"""
warnings.warn(DeprecationWarning('mnist_model is deprecated and will be removed in v0.18'))

if initializers is None:
initializers = []
Expand Down
Loading
Loading