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

log packing ratio progress #1070

Merged
merged 13 commits into from
Apr 4, 2024
14 changes: 11 additions & 3 deletions llmfoundry/data/packing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import numpy as np
import torch
from omegaconf import DictConfig
from tqdm import tqdm
milocress marked this conversation as resolved.
Show resolved Hide resolved
from tqdm.contrib.logging import logging_redirect_tqdm
milocress marked this conversation as resolved.
Show resolved Hide resolved
from transformers import PreTrainedTokenizerBase

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -315,6 +317,8 @@ def auto_packing_ratio(dataloader_cfg: DictConfig,
"""
from composer.utils import dist, get_device, reproducibility

log.debug('Searching for optimal packing ratio.')
milocress marked this conversation as resolved.
Show resolved Hide resolved

# Stash the rng state to restore later.
rng_state = reproducibility.get_rng_state()
# Set the seed so that auto packing is deterministic.
Expand Down Expand Up @@ -447,6 +451,10 @@ def profile(raw_batch_size: int) -> Tuple[Optional[float], Optional[float]]:
waste_percent = 100 * packer.waste
return padding_percent, waste_percent

for packing_ratio, raw_batch_size in zip(packing_ratios, raw_batch_sizes):
padding, waste = profile(raw_batch_size)
yield (packing_ratio, padding, waste)
with logging_redirect_tqdm(loggers=[log]):
milocress marked this conversation as resolved.
Show resolved Hide resolved
for packing_ratio, raw_batch_size in (pbar := tqdm(
zip(packing_ratios, raw_batch_sizes),
desc='Profiling packing ratios')):
pbar.set_description_str(f'Profiling packing ratio {packing_ratio}')
padding, waste = profile(raw_batch_size)
yield (packing_ratio, padding, waste)
Loading