{"record":{"id":"bab6bf720482f3d1","repo":"Lightning-AI/pytorch-lightning","slug":"in-tuner-with-method-method-r-train-dataload","errorCode":null,"errorMessage":"In tuner with `method`={method!r}, `train_dataloaders` and `val_dataloaders` arguments should be None, please consider setting `dataloaders` instead.","messagePattern":"In tuner with `method`=(.+?), `train_dataloaders` and `val_dataloaders` arguments should be None, please consider setting `dataloaders` instead\\.","errorType":"validation","errorClass":"MisconfigurationException","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/tuner/tuning.py","lineNumber":223,"sourceCode":"def _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(\n            \"Trainer is already configured with a `LearningRateFinder` callback.\"\n            \"Please remove it if you want to use the Tuner.\"\n        )\n\n\ndef _check_scale_batch_size_configuration(trainer: \"pl.Trainer\") -> None:","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/tuner/tuning.py#L205-L241","documentation":"For tuner calls with method != 'fit' (validate/test/predict), the train_dataloaders and val_dataloaders arguments must be None; only the unified `dataloaders` argument is accepted. Violating this raises MisconfigurationException.","triggerScenarios":"trainer.tuner.lr_find(model, method='validate', train_dataloaders=dl) or scale_batch_size with train/val loaders and a non-fit method.","commonSituations":"Reusing a fit-style call signature while switching the method to validate/test/predict.","solutions":["Remove train_dataloaders/val_dataloaders and pass dataloaders=... instead","Check you actually meant a non-fit method; use 'fit' if you want train/val loaders"],"exampleFix":"# before\ntrainer.tuner.lr_find(model, method=\"test\", train_dataloaders=dl)\n# after\ntrainer.tuner.lr_find(model, method=\"test\", dataloaders=dl)","handlingStrategy":"validation","validationCode":"if method != \"fit\":\n    assert train_dataloaders is None and val_dataloaders is None\n    assert dataloaders is not None","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember the argument symmetry: fit -> train/val loaders, non-fit -> dataloaders"],"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"}