Lightning-AI/pytorch-lightning · error · ValueError
`{type(self).__name__}` does not support the `CombinedLoader
Error message
`{type(self).__name__}` does not support the `CombinedLoader(mode="sequential")` mode. The available modes are: {[m for m in _SUPPORTED_MODES if m != 'sequential']} What it means
Raised in FitLoop.advance when the training CombinedLoader was created with mode='sequential'. Sequential mode concatenates multiple dataloaders one after another, which does not produce aligned batches across the epoch and is therefore unsupported for training; only the min_size/max_size/.. cycle-like modes are allowed.
Source
Thrown at src/lightning/pytorch/loops/fit_loop.py:472
_set_sampler_epoch(dl, self.epoch_progress.current.processed)
if not self.restarted_mid_epoch and not self.restarted_on_epoch_end:
if not self.restarted_on_epoch_start:
self.epoch_progress.increment_ready()
call._call_callback_hooks(trainer, "on_train_epoch_start")
call._call_lightning_module_hook(trainer, "on_train_epoch_start")
self.epoch_progress.increment_started()
def advance(self) -> None:
"""Runs one whole epoch."""
log.debug(f"{type(self).__name__}: advancing loop")
combined_loader = self._combined_loader
assert combined_loader is not None
if combined_loader._mode == "sequential":
raise ValueError(
f'`{type(self).__name__}` does not support the `CombinedLoader(mode="sequential")` mode.'
f" The available modes are: {[m for m in _SUPPORTED_MODES if m != 'sequential']}"
)
with self.trainer.profiler.profile("run_training_epoch"):
assert self._data_fetcher is not None
self.epoch_loop.run(self._data_fetcher)
def on_advance_end(self) -> None:
trainer = self.trainer
# inform logger the batch loop has finished
trainer._logger_connector.epoch_end_reached()
self.epoch_progress.increment_processed()
# call train epoch end hooks
# we always call callback hooks first, but here we need to make an exception for the callbacks that
# monitor a metric, otherwise they wouldn't be able to monitor a key logged in
# `LightningModule.on_train_epoch_end`View on GitHub (pinned to 9fed5c27d2)
Solutions
- Use one of the supported cycling modes: 'min_size', 'max_size', 'max_size_cycle'
- If sequential consumption is truly needed, manually chain the datasets into a single ConcatDataset/ConcatLoader and pass one dataloader
- If you intended evaluation over multiple loaders, use trainer.validate/test instead, where sequential is allowed
Example fix
# before train_loader = CombinedLoader([loader_a, loader_b], mode='sequential') trainer.fit(model, train_loader) # after train_loader = CombinedLoader([loader_a, loader_b], mode='max_size_cycle') trainer.fit(model, train_loader)
Defensive patterns
Strategy: validation
Validate before calling
from lightning.pytorch.utilities import CombinedLoader from lightning.fabric.utilities import _SUPPORTED_MODES assert combined.mode != 'sequential', 'training does not support sequential CombinedLoader mode'
Type guard
def mode_ok_for_training(mode: str) -> bool:
return mode != 'sequential' Prevention
- Keep separate CombinedLoader instances for train (cycling modes) and predict (sequential)
- Document the mode choice next to multi-dataloader setups in the data module
When it happens
Trigger: Passing multiple train dataloaders to Trainer.fit and constructing the CombinedLoader (e.g. via LightningDataModule or CombinedLoader directly) with `CombinedLoader(mode='sequential')`, then calling trainer.fit.
Common situations: Multi-dataset training setups (e.g. domain adaptation with source/target loaders) where the developer chose sequential mode thinking it cycles; copying a prediction-loop pattern (which does support sequential) into training.
Related errors
- `trainer.predict()` only supports the `CombinedLoader(mode="
- You called `self.log` with the key `{name}` but it should no
- The loss returned in `training_step` is {loss}.
- You provided multiple `{stage.dataloader_prefix}_dataloader`
- Device should be CPU, got {device} instead.
AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28).
Data as JSON: /api/errors/f6b7c575559e6dd5.
Report an issue: GitHub.