{"record":{"id":"a423bfa2bc576448","repo":"Lightning-AI/pytorch-lightning","slug":"f-trainer-barebones-true-detect-anomaly-detect","errorCode":null,"errorMessage":"f\"`Trainer(barebones=True, detect_anomaly={detect_anomaly!r})` was passed.\" \" Anomaly detection can impact raw speed so it is disabled in barebones mode.\"","messagePattern":"f\"`Trainer\\(barebones=True, detect_anomaly=(.+?)\\)` was passed\\.\" \" Anomaly detection can impact raw speed so it is disabled in barebones mode\\.\"","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/trainer/trainer.py","lineNumber":380,"sourceCode":"                raise ValueError(\n                    f\"`Trainer(barebones=True, enable_model_summary={enable_model_summary!r})` was passed.\"\n                    \" Model summary can impact raw speed so it is disabled in barebones mode.\"\n                )\n            enable_model_summary = False\n            if num_sanity_val_steps is not None and num_sanity_val_steps != 0:\n                raise ValueError(\n                    f\"`Trainer(barebones=True, num_sanity_val_steps={num_sanity_val_steps!r})` was passed.\"\n                    \" Sanity checking can impact raw speed so it is disabled in barebones mode.\"\n                )\n            num_sanity_val_steps = 0\n            # opt-ins\n            if fast_dev_run is not False and fast_dev_run != 0:\n                raise ValueError(\n                    f\"`Trainer(barebones=True, fast_dev_run={fast_dev_run!r})` was passed.\"\n                    \" Development run is not meant for raw speed evaluation so it is disabled in barebones mode.\"\n                )\n            if detect_anomaly:\n                raise ValueError(\n                    f\"`Trainer(barebones=True, detect_anomaly={detect_anomaly!r})` was passed.\"\n                    \" Anomaly detection can impact raw speed so it is disabled in barebones mode.\"\n                )\n            if profiler is not None:\n                raise ValueError(\n                    f\"`Trainer(barebones=True, profiler={profiler!r})` was passed.\"\n                    \" Profiling can impact raw speed so it is disabled in barebones mode.\"\n                )\n            deactivated = (\n                \" - Checkpointing: `Trainer(enable_checkpointing=True)`\",\n                \" - Progress bar: `Trainer(enable_progress_bar=True)`\",\n                \" - Model summary: `Trainer(enable_model_summary=True)`\",\n                \" - Logging: `Trainer(logger=True)`, `Trainer(log_every_n_steps>0)`,\"\n                \" `LightningModule.log(...)`, `LightningModule.log_dict(...)`\",\n                \" - Sanity checking: `Trainer(num_sanity_val_steps>0)`\",\n                \" - Development run: `Trainer(fast_dev_run=True)`\",\n                \" - Anomaly detection: `Trainer(detect_anomaly=True)`\",\n                \" - Profiling: `Trainer(profiler=...)`\",","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/trainer/trainer.py#L362-L398","documentation":"Trainer was created with barebones=True while detect_anomaly=True. Torch anomaly detection wraps autograd ops and adds huge overhead, so it is incompatible with barebones speed-benchmark mode.","triggerScenarios":"Trainer(barebones=True, detect_anomaly=True).","commonSituations":"Reusing a debugging Trainer configuration (with detect_anomaly enabled to hunt NaNs) and adding barebones=True without removing debugging flags.","solutions":["Remove detect_anomaly when using barebones=True","Set detect_anomaly=False","Drop barebones=True if anomaly detection is needed"],"exampleFix":"// before\ntrainer = Trainer(barebones=True, detect_anomaly=True)\n// after\ntrainer = Trainer(barebones=True)","handlingStrategy":"validation","validationCode":"if cfg.get(\"barebones\") and cfg.get(\"detect_anomaly\"):\n    cfg[\"detect_anomaly\"] = False\ntrainer = Trainer(**cfg)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Search your config for 'detect_anomaly' before enabling barebones","Debug NaNs in a separate run from speed benchmarks"],"tags":["trainer","barebones","anomaly-detection","misconfiguration","pytorch-lightning"],"backgroundTag":"invalid-argument-combination","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}