#6981·trl

[Bug] get_dataset raises ZeroDivisionError for zero-sum fractions

Author: YZJFCreated Aug 31, 2026Updated Sep 15, 2026

Reproduction

trl/scripts/utils.py is unchanged between the observed failing base 6630e17 and current main (f341a51). The following configuration reproduces the problem with two zero target shares:

python
from trl import DatasetMixtureConfig, get_dataset
from trl.scripts.utils import DatasetConfig

mixture = DatasetMixtureConfig(
    datasets=[
        DatasetConfig(
            path="trl-internal-testing/zen",
            name="standard_language_modeling",
            fraction=0.0,
        ),
        DatasetConfig(
            path="trl-internal-testing/zen",
            name="standard_language_modeling",
            fraction=0.0,
        ),
    ]
)
get_dataset(mixture)

The fraction normalization currently divides by sum(fractions) after loading the datasets, producing ZeroDivisionError: float division by zero for this configuration.

Negative fractions are also accepted and can produce negative selection sizes instead of an actionable configuration error.

Expected behavior

Validate configured fractions before loading datasets: reject negative values and require their sum to be positive with a clear ValueError. Individual zero fractions should remain supported when at least one dataset has a positive share.

System Info

  • Platform: macOS-26.5.2-arm64-arm-64bit-Mach-O
  • Python version: 3.13.5
  • TRL version: 1.13.0.dev0+f341a51
  • PyTorch version: 2.13.0
  • accelerator(s): cpu
  • Transformers version: 5.16.1
  • Accelerate version: 1.14.0
  • Accelerate config: not found
  • Datasets version: 5.0.1
  • HF Hub version: 1.29.0
  • bitsandbytes version: not installed
  • DeepSpeed version: not installed
  • Liger-Kernel version: not installed
  • PEFT version: not installed
  • vLLM version: not installed

Checklist

  • I have checked that this issue is not already filed.
  • I have included system information.
  • The code sample is minimal, complete, and reproducible.
  • The code sample is formatted in code blocks.
  • No traceback is included; the exception and minimal reproduction are provided above.