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

Warning -> info about defaults from v0.7.0 #799

Merged
merged 3 commits into from
Oct 8, 2024
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
26 changes: 9 additions & 17 deletions streaming/base/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,8 @@ def __init__(self,
f'This may result in slower batch time. Recommendation is to set ' +
f'predownload to at-least batch_size.')
elif self.predownload is None:
logger.warning(f'Because `predownload` was not specified, it will default to ' +
f'8*batch_size if batch_size is not None, otherwise 64. Prior to ' +
f'Streaming v0.7.0, `predownload` defaulted to ' +
f'max(batch_size, 256 * batch_size // num_canonical_nodes).')
logger.info(f'Because `predownload` was not specified, it will default to ' +
f'8*batch_size if batch_size is not None, otherwise 64.')
self.predownload = 8 * self.batch_size if self.batch_size is not None else 64

# Convert epoch size from string to int, if needed. Cannot be negative.
Expand Down Expand Up @@ -669,10 +667,9 @@ def _set_shuffle_block_size(self, world: World):
"""Set the shuffle block size value."""
if self.shuffle_block_size is None:
if not world.worker_of_rank:
logger.warning(f'Because `shuffle_block_size` was not specified, it will ' +
f'default to max(4_000_000 // num_canonical_nodes, 1 << 18) if ' +
f'num_canonical_nodes is not None, otherwise 262144. Prior to ' +
f'Streaming v0.7.0, `shuffle_block_size` defaulted to 262144.')
logger.info(f'Because `shuffle_block_size` was not specified, it will ' +
f'default to max(4_000_000 // num_canonical_nodes, 1 << 18) if ' +
f'num_canonical_nodes is not None, otherwise 262144.')
self.shuffle_block_size = max(4_000_000 // self.num_canonical_nodes, 1 << 18) \
if self.num_canonical_nodes is not None else 1 << 18

Expand All @@ -697,12 +694,9 @@ def _resume(self, world: World, epoch: int) -> tuple[int, int]:
self.num_canonical_nodes = 64 * world.num_nodes
else:
if not world.worker_of_rank:
logger.warning(
f'Because `num_canonical_nodes` was not specified, and ' +
f'`shuffle_algo` is {self.shuffle_algo}, it will default to ' +
f'be equal to physical nodes. Prior to Streaming ' +
f'v0.7.0, `num_canonical_nodes` defaulted to 64 * physical ' +
f'nodes.')
logger.info(f'Because `num_canonical_nodes` was not specified, and ' +
f'`shuffle_algo` is {self.shuffle_algo}, it will default to ' +
f'be equal to physical nodes.')
self.num_canonical_nodes = world.num_nodes
self._set_shuffle_block_size(world)
return epoch, 0
Expand All @@ -723,9 +717,7 @@ def _resume(self, world: World, epoch: int) -> tuple[int, int]:
logger.warning(
f'Because `num_canonical_nodes` was not specified, and ' +
f'`shuffle_algo` is {self.shuffle_algo}, it will default to ' +
f'be equal to physical nodes. Prior to Streaming ' +
f'v0.7.0, `num_canonical_nodes` defaulted to 64 * physical ' +
f'nodes.')
f'be equal to physical nodes.')
self.num_canonical_nodes = world.num_nodes
self._set_shuffle_block_size(world)
return epoch, 0
Expand Down
23 changes: 1 addition & 22 deletions tests/test_streaming.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Copyright 2022-2024 MosaicML Streaming authors
# SPDX-License-Identifier: Apache-2.0

import logging
import math
import os
import shutil
from multiprocessing import Process
from typing import Any, Callable
from typing import Any

import pytest
from torch.utils.data import DataLoader
Expand Down Expand Up @@ -65,26 +64,6 @@ def test_no_batch_size_exception(local_remote_dir: tuple[str, str]):
pass


@pytest.mark.usefixtures('local_remote_dir')
def test_new_defaults_warning(local_remote_dir: tuple[str, str], caplog: Callable):
caplog.set_level(logging.WARNING)
local, remote = local_remote_dir
convert_to_mds(out_root=remote,
dataset_name='sequencedataset',
num_samples=100,
size_limit=1 << 8)

# Build a StreamingDataset with new defaults. Should warn about the new defaults changes.
dataset = StreamingDataset(local=local, remote=remote, shuffle=True, batch_size=4)
dataloader = StreamingDataLoader(dataset=dataset, batch_size=4)
for _ in dataloader:
pass

assert 'Because `predownload` was not specified,' in caplog.text
assert 'Because `shuffle_block_size` was not specified,' in caplog.text
assert 'Because `num_canonical_nodes` was not specified,' in caplog.text


@pytest.mark.parametrize('batch_size', [4, 7])
@pytest.mark.parametrize('seed', [2222, 1000])
@pytest.mark.parametrize('num_canonical_nodes', [2, 4])
Expand Down
Loading