{"record":{"id":"98b45f07054ba2ef","repo":"Lightning-AI/pytorch-lightning","slug":"no-precision-set-98b45f","errorCode":null,"errorMessage":"No precision set","messagePattern":"No precision set","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/trainer/connectors/accelerator_connector.py","lineNumber":492,"sourceCode":"            return TransformerEnginePrecision(weights_dtype=torch.bfloat16)\n        if self._precision_flag == \"transformer-engine-float16\":\n            return TransformerEnginePrecision(weights_dtype=torch.float16)\n\n        if self._precision_flag == \"16-mixed\" and self._accelerator_flag == \"cpu\":\n            rank_zero_warn(\n                \"You passed `Trainer(accelerator='cpu', precision='16-mixed')` but AMP with fp16 is not supported on \"\n                \"CPU. Using `precision='bf16-mixed'` instead.\"\n            )\n            self._precision_flag = \"bf16-mixed\"\n\n        if self._precision_flag in (\"16-mixed\", \"bf16-mixed\"):\n            rank_zero_info(\n                f\"Using {'16bit' if self._precision_flag == '16-mixed' else 'bfloat16'} Automatic Mixed Precision (AMP)\"\n            )\n            device = self._accelerator_flag if self._accelerator_flag in (\"cpu\", \"mps\") else \"cuda\"\n            return MixedPrecision(self._precision_flag, device)\n\n        raise RuntimeError(\"No precision set\")\n\n    def _validate_precision_choice(self) -> None:\n        \"\"\"Validate the combination of choices for precision, AMP type, and accelerator.\"\"\"\n        if isinstance(self._precision_plugin_flag, BitsandbytesPrecision) and not isinstance(\n            self.accelerator, CUDAAccelerator\n        ):\n            raise RuntimeError(\"Bitsandbytes is only supported on CUDA GPUs.\")\n        mp_precision_supported = (\"32-true\", \"bf16-mixed\", \"bf16-true\", \"16-true\")\n        if (\n            isinstance(self._strategy_flag, ModelParallelStrategy)\n            and self._precision_flag not in mp_precision_supported\n        ):\n            raise ValueError(\n                f\"The `ModelParallelStrategy` does not support `Fabric(..., precision={self._precision_flag!r})`.\"\n                f\" Choose a different precision among: {', '.join(mp_precision_supported)}.\"\n            )\n\n    def _lazy_init_strategy(self) -> None:","sourceCodeStart":474,"sourceCodeEnd":510,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/trainer/connectors/accelerator_connector.py#L474-L510","documentation":"After trying all precision configuration branches in _check_and_init_precision, none matched the current precision flag, so the connector has no Precision plugin to install and raises RuntimeError('No precision set'). It indicates an unrecognized precision value or a code path gap.","triggerScenarios":"Trainer(precision=<unsupported-value>) that matches neither 32-true, 16-true, bf16-true, 16-mixed, bf16-mixed, 64-true nor a plugin-based path; custom precision strings not handled by any branch.","commonSituations":"Typos in precision strings ('bf16', 'mixed' from older versions); custom precision plugin flows where the flag remains set but no branch handles it; version drift between Lightning releases changing accepted precision tokens.","solutions":["Use a supported precision literal: '32-true', '16-mixed', 'bf16-mixed', 'bf16-true', '16-true', '64-true'","For custom precision, pass a Precision plugin via plugins=[...] instead of a precision string","Upgrade Lightning if using recently added precision names"],"exampleFix":"# before\ntrainer = Trainer(precision=\"bf16\")\n# after\ntrainer = Trainer(precision=\"bf16-mixed\")","handlingStrategy":"validation","validationCode":"SUPPORTED = {\"32-true\", \"16-true\", \"bf16-true\", \"16-mixed\", \"bf16-mixed\", \"64-true\"}\nif precision not in SUPPORTED:\n    precision = \"32-true\"  # or route to a custom Precision plugin\ntrainer = Trainer(precision=precision)","typeGuard":"def valid_precision(p) -> bool:\n    return p in {\"32-true\", \"16-true\", \"bf16-true\", \"16-mixed\", \"bf16-mixed\", \"64-true\"}","tryCatchPattern":"try:\n    trainer = Trainer(precision=precision)\nexcept RuntimeError as e:\n    if \"No precision set\" in str(e):\n        trainer = Trainer(precision=\"32-true\")\n    else:\n        raise","preventionTips":["Use the new '<dtype>-<mode>' precision literals ('bf16-mixed', not 'bf16')","For custom precision pass a plugin, not a string"],"tags":["pytorch-lightning","precision","config-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}