{"record":{"id":"a97d0223d8be810b","repo":"hiyouga/LlamaFactory","slug":"streaming-mode-should-have-an-integer-val-size","errorCode":null,"errorMessage":"Streaming mode should have an integer val size.","messagePattern":"Streaming mode should have an integer val size\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/hparams/data_args.py","lineNumber":177,"sourceCode":"        if self.dataset is None and self.val_size > 1e-6:\n            raise ValueError(\"Cannot specify `val_size` if `dataset` is None.\")\n\n        if self.eval_dataset is not None and self.val_size > 1e-6:\n            raise ValueError(\"Cannot specify `val_size` if `eval_dataset` is not None.\")\n\n        if self.interleave_probs is not None:\n            if self.mix_strategy == \"concat\":\n                raise ValueError(\"`interleave_probs` is only valid for interleaved mixing.\")\n\n            self.interleave_probs = list(map(float, split_arg(self.interleave_probs)))\n            if self.dataset is not None and len(self.dataset) != len(self.interleave_probs):\n                raise ValueError(\"The length of dataset and interleave probs should be identical.\")\n\n            if self.eval_dataset is not None and len(self.eval_dataset) != len(self.interleave_probs):\n                raise ValueError(\"The length of eval dataset and interleave probs should be identical.\")\n\n        if self.streaming and self.val_size > 1e-6 and self.val_size < 1:\n            raise ValueError(\"Streaming mode should have an integer val size.\")\n\n        if self.streaming and self.max_samples is not None:\n            raise ValueError(\"`max_samples` is incompatible with `streaming`.\")\n\n        if self.mask_history and self.train_on_prompt:\n            raise ValueError(\"`mask_history` is incompatible with `train_on_prompt`.\")\n\n        if self.neat_packing:\n            self.packing = True\n\n        if self.packing:\n            self.cutoff_len -= 1  # avoid pad_to_multiple_of, needs improve\n\n    def to_dict(self) -> dict[str, Any]:\n        return asdict(self)\n","sourceCodeStart":159,"sourceCodeEnd":193,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/hparams/data_args.py#L159-L193","documentation":"LlamaFactory splits a fraction of the training set as validation when val_size is between 0 and 1, but HuggingFace IterableDatasets (streaming mode) cannot be randomly split by fraction. The check in DataArguments.__post_init__ (src/llamafactory/hparams/data_args.py:177) therefore rejects fractional val_size when streaming=True. Use an integer val_size, which takes a fixed number of samples from the stream.","triggerScenarios":"A YAML/JSON training config (or DataArguments instance) with streaming: true and val_size set to a float in (0,1), e.g. val_size: 0.1. The condition self.streaming and self.val_size > 1e-6 and self.val_size < 1 fires during argument parsing, before any data is loaded.","commonSituations":"Copying a non-streaming config (where val_size: 0.1 is idiomatic) and flipping streaming: true for large datasets. Also happens when tuning large streamed corpora (e.g. pile, fineweb) where users keep the fractional split habit.","solutions":["Set val_size to an integer number of samples, e.g. val_size: 500, in your training YAML.","Set val_size: 0 to disable the validation split entirely if you do not need eval during streaming training.","Disable streaming (streaming: false) if the dataset fits in memory and you want to keep a fractional split."],"exampleFix":"# before (yaml)\nstreaming: true\nval_size: 0.1\n\n# after (yaml)\nstreaming: true\nval_size: 500","handlingStrategy":"validation","validationCode":"def check_streaming_val_size(streaming: bool, val_size: float) -> None:\n    if streaming and 1e-6 < val_size < 1:\n        raise ValueError(\"Use an integer val_size with streaming=True, e.g. val_size=500\")","typeGuard":null,"tryCatchPattern":"try:\n    data_args = DataArguments(dataset=..., streaming=True, val_size=0.1)\nexcept ValueError as e:\n    # fix config and re-run; this is a config error, never retry as-is\n    raise SystemExit(f\"Invalid data config: {e}\")","preventionTips":["Keep separate YAML templates for streaming vs non-streaming runs; fractional val_size belongs only in non-streaming templates.","Lint training YAMLs in CI with a rule: if streaming is true, val_size must be int or 0."],"tags":["config","streaming","data","validation-split"],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}