Support DDP partitioning for prebaked datasets - #3061
Conversation
When using a prebaked dataset string (e.g. `dataset="perfectblend"`) in a distributed setting, automatically partition the split across ranks so each rank only loads its slice of calibration data. This matches the behavior of the existing `get_rank_partition()` utility used in DDP examples. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces dataset split partitioning across ranks in a distributed data parallel (DDP) setting for prebaked (string) datasets, ensuring each rank only loads its respective slice of calibration data. The reviewer pointed out that while the dataset split is partitioned, the global dataset_args.num_calibration_samples is not updated to reflect the reduced sample count per rank. This discrepancy triggers a false warning in _make_sampler regarding insufficient samples. The reviewer provided a code suggestion to update dataset_args.num_calibration_samples based on the partitioned range for the current rank.
| if ( | ||
| isinstance(dataset_args.dataset, str) | ||
| and dist.is_initialized() | ||
| and split_str is not None | ||
| and "[" not in split_str | ||
| and dataset_args.num_calibration_samples is not None | ||
| ): | ||
| split_str = get_rank_partition( | ||
| split_str, dataset_args.num_calibration_samples | ||
| ) | ||
| logger.info( | ||
| f"DDP: partitioned dataset split to '{split_str}' for rank " | ||
| f"{dist.get_rank()}/{dist.get_world_size()}" | ||
| ) |
There was a problem hiding this comment.
When partitioning the dataset split across ranks in a distributed setting, the number of samples loaded per rank is reduced (e.g., to num_calibration_samples / world_size). However, dataset_args.num_calibration_samples remains at its original global value. Later in _make_sampler, this discrepancy triggers a false warning: Requested X samples but the provided dataset only has Y samples.
To prevent this false warning and ensure consistency, we should update dataset_args.num_calibration_samples to reflect the partitioned sample count for the current rank.
| if ( | |
| isinstance(dataset_args.dataset, str) | |
| and dist.is_initialized() | |
| and split_str is not None | |
| and "[" not in split_str | |
| and dataset_args.num_calibration_samples is not None | |
| ): | |
| split_str = get_rank_partition( | |
| split_str, dataset_args.num_calibration_samples | |
| ) | |
| logger.info( | |
| f"DDP: partitioned dataset split to '{split_str}' for rank " | |
| f"{dist.get_rank()}/{dist.get_world_size()}" | |
| ) | |
| if ( | |
| isinstance(dataset_args.dataset, str) | |
| and dist.is_initialized() | |
| and split_str is not None | |
| and "[" not in split_str | |
| and dataset_args.num_calibration_samples is not None | |
| ): | |
| start, end = _get_partition_start_end( | |
| dataset_args.num_calibration_samples, | |
| dist.get_rank(), | |
| dist.get_world_size(), | |
| ) | |
| split_str = get_rank_partition( | |
| split_str, dataset_args.num_calibration_samples | |
| ) | |
| dataset_args.num_calibration_samples = end - start | |
| logger.info( | |
| f"DDP: partitioned dataset split to '{split_str}' for rank " | |
| f"{dist.get_rank()}/{dist.get_world_size()}" | |
| ) |
Merge Protections🔴 1 of 1 protections blocking · waiting on 👀 reviews
🔴 Require one maintainer reviewWaiting for any of
This rule is failing.All PRs must have at least one approving review from a maintainer before merging.
|
Summary
dataset="perfectblend") in a distributed setting, automatically partition the split across ranks viaget_rank_partition()so each rank only loads its slice of calibration data.oneshot(model, dataset="perfectblend", ...)without manually callingload_dataset+get_rank_partition().Test plan
dataset="perfectblend"usingtorchrun --nproc_per_node=2🤖 Generated with Claude Code