{"record":{"id":"0d0d0c76ce7eadda","repo":"Lightning-AI/pytorch-lightning","slug":"trainer-is-already-configured-with-a-learningrate","errorCode":null,"errorMessage":"Trainer is already configured with a `LearningRateFinder` callback.Please remove it if you want to use the Tuner.","messagePattern":"Trainer is already configured with a `LearningRateFinder` callback\\.Please remove it if you want to use the Tuner\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/tuner/tuning.py","lineNumber":235,"sourceCode":"            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:\n    if trainer._accelerator_connector.is_distributed:\n        raise ValueError(\"Tuning the batch size is currently not supported with distributed strategies.\")\n\n    # local import to avoid circular import\n    from lightning.pytorch.callbacks.batch_size_finder import BatchSizeFinder\n\n    configured_callbacks = [cb for cb in trainer.callbacks if isinstance(cb, BatchSizeFinder)]\n    if configured_callbacks:\n        raise ValueError(\n            \"Trainer is already configured with a `BatchSizeFinder` callback.\"\n            \"Please remove it if you want to use the Tuner.\"\n        )","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/tuner/tuning.py#L217-L253","documentation":"_check_lr_find_configuration rejects running tuner.lr_find when the Trainer already has a LearningRateFinder callback attached, since the Tuner installs its own and duplication would conflict.","triggerScenarios":"trainer = Trainer(callbacks=[LearningRateFinder(...)]) followed by trainer.tuner.lr_find(model).","commonSituations":"Copy-pasting a callback-based LR-find snippet and also calling the Tuner API; migrating from the callback approach to the Tuner without removing the callback.","solutions":["Remove LearningRateFinder from the Trainer's callbacks list and rely on tuner.lr_find alone","Or keep the callback and skip calling tuner.lr_find"],"exampleFix":"# before\ntrainer = Trainer(callbacks=[LearningRateFinder()])\ntrainer.tuner.lr_find(model)\n# after\ntrainer = Trainer()\ntrainer.tuner.lr_find(model)","handlingStrategy":"validation","validationCode":"from lightning.pytorch.callbacks.lr_finder import LearningRateFinder\nassert not any(isinstance(cb, LearningRateFinder) for cb in trainer.callbacks)","typeGuard":"def has_lr_finder_callback(trainer) -> bool:\n    from lightning.pytorch.callbacks.lr_finder import LearningRateFinder\n    return any(isinstance(cb, LearningRateFinder) for cb in trainer.callbacks)","tryCatchPattern":null,"preventionTips":["Choose one LR-find mechanism (Tuner XOR callback), never both"],"tags":["lr-finder","callbacks","tuner","duplicate-config"],"backgroundTag":"duplicate-callback-registration","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}