{"record":{"id":"cae1aa71b81b0cd4","repo":"hiyouga/LlamaFactory","slug":"hyperparallel-cp-training-requires-a-map-style-dat","errorCode":null,"errorMessage":"HyperParallel CP training requires a map-style dataset because iterable datasets cannot repeat logical batches across CP ranks.","messagePattern":"HyperParallel CP training requires a map-style dataset because iterable datasets cannot repeat logical batches across CP ranks\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"src/llamafactory/train/hyper_parallel/trainer.py","lineNumber":257,"sourceCode":"        if getattr(self.finetuning_args, \"disable_shuffling\", False):\n            return torch.utils.data.SequentialSampler(train_dataset)\n        return super()._get_train_sampler(train_dataset)\n\n    def _build_cp_batch_sampler(self, dataset, shuffle: bool, batch_size: int, drop_last: bool):\n        \"\"\"Repeat complete logical batches so CP groups consume the same baseline batch.\"\"\"\n        sampler = self._get_train_sampler(dataset) if shuffle else torch.utils.data.SequentialSampler(dataset)\n        return _CPBatchRepeatedBatchSampler(\n            sampler,\n            batch_size=batch_size,\n            drop_last=drop_last,\n            repeat_factor=self._cp_size,\n            logical_group_size=max(1, get_platform().get_world_size() // self._cp_size),\n        )\n\n    def _get_cp_dataloader(self, dataset, batch_size: int, shuffle: bool):\n        \"\"\"Create a train dataloader whose logical batches are shared within each CP group.\"\"\"\n        if isinstance(dataset, torch.utils.data.IterableDataset):\n            raise NotImplementedError(\n                \"HyperParallel CP training requires a map-style dataset because iterable datasets cannot \"\n                \"repeat logical batches across CP ranks.\"\n            )\n\n        try:\n            import datasets  # pylint: disable=C0415\n        except ImportError:  # pragma: no cover\n            datasets = None\n\n        if datasets is not None and isinstance(dataset, datasets.Dataset):\n            dataset = self._remove_unused_columns(dataset, description=\"Training\")\n            data_collator = self.data_collator\n        else:\n            data_collator = self._get_collator_with_removed_columns(self.data_collator, description=\"Training\")\n\n        batch_sampler = self._build_cp_batch_sampler(\n            dataset,\n            shuffle=shuffle,","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/hiyouga/LlamaFactory/blob/f28afaf6355af515454dfb16c97d728307c93897/src/llamafactory/train/hyper_parallel/trainer.py#L239-L275","documentation":"Error \"HyperParallel CP training requires a map-style dataset because iterable datasets cannot repeat logical batches across CP ranks.\" thrown in hiyouga/LlamaFactory.","triggerScenarios":"Thrown at src/llamafactory/train/hyper_parallel/trainer.py:257 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Disable streaming (streaming: false) so the dataset is loaded as a map-style dataset before HyperParallel CP training."],"exampleFix":"streaming: false","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f28afaf6355af515454dfb16c97d728307c93897","analyzedAt":"2026-08-14T21:57:28.298Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}