{"record":{"id":"bad9b3bcdc478a8d","repo":"Lightning-AI/pytorch-lightning","slug":"in-tuner-with-method-method-r-dataloaders-arg","errorCode":null,"errorMessage":"In tuner with method={method!r}, `dataloaders` argument should be None, please consider setting `train_dataloaders` and `val_dataloaders` instead.","messagePattern":"In tuner with method=(.+?), `dataloaders` argument should be None, please consider setting `train_dataloaders` and `val_dataloaders` instead\\.","errorType":"validation","errorClass":"MisconfigurationException","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/tuner/tuning.py","lineNumber":217,"sourceCode":"\n        self._trainer.callbacks = [cb for cb in self._trainer.callbacks if cb is not lr_finder_callback]\n\n        return lr_finder_callback.optimal_lr\n\n\ndef _check_tuner_configuration(\n    train_dataloaders: Optional[Union[TRAIN_DATALOADERS, \"pl.LightningDataModule\"]] = None,\n    val_dataloaders: Optional[EVAL_DATALOADERS] = None,\n    dataloaders: Optional[EVAL_DATALOADERS] = None,\n    method: Literal[\"fit\", \"validate\", \"test\", \"predict\"] = \"fit\",\n) -> None:\n    supported_methods = (\"fit\", \"validate\", \"test\", \"predict\")\n    if method not in supported_methods:\n        raise ValueError(f\"method {method!r} is invalid. Should be one of {supported_methods}.\")\n\n    if method == \"fit\":\n        if dataloaders is not None:\n            raise MisconfigurationException(\n                f\"In tuner with method={method!r}, `dataloaders` argument should be None,\"\n                \" please consider setting `train_dataloaders` and `val_dataloaders` instead.\"\n            )\n    else:\n        if train_dataloaders is not None or val_dataloaders is not None:\n            raise MisconfigurationException(\n                f\"In tuner with `method`={method!r}, `train_dataloaders` and `val_dataloaders`\"\n                \" arguments should be None, please consider setting `dataloaders` instead.\"\n            )\n\n\ndef _check_lr_find_configuration(trainer: \"pl.Trainer\") -> None:\n    # local import to avoid circular import\n    from lightning.pytorch.callbacks.lr_finder import LearningRateFinder\n\n    configured_callbacks = [cb for cb in trainer.callbacks if isinstance(cb, LearningRateFinder)]\n    if configured_callbacks:\n        raise ValueError(","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/tuner/tuning.py#L199-L235","documentation":"When the tuner runs with method='fit', the combined `dataloaders` argument is disallowed because training needs distinct train and validation loaders. Passing `dataloaders` raises MisconfigurationException.","triggerScenarios":"trainer.tuner.lr_find(model, dataloaders=dl) or tuner.scale_batch_size(..., dataloaders=dl, method='fit') (method defaults to 'fit').","commonSituations":"Migrating from an older API that accepted a single dataloaders argument; reusing a validate/test-style call for fitting.","solutions":["Pass train_dataloaders=... (and optionally val_dataloaders=...) instead of dataloaders","Or let lr_find reuse the loaders already attached to the model/trainer by omitting the argument"],"exampleFix":"# before\ntrainer.tuner.lr_find(model, dataloaders=train_dl)\n# after\ntrainer.tuner.lr_find(model, train_dataloaders=train_dl, val_dataloaders=val_dl)","handlingStrategy":"validation","validationCode":"assert dataloaders is None, \"method='fit' requires train_dataloaders/val_dataloaders, not dataloaders\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use keyword arguments (train_dataloaders=...) so mistakes surface early"],"tags":["tuner","dataloaders","misconfiguration"],"backgroundTag":"invalid-argument-value","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}