{"record":{"id":"00be3ddc36b4cad9","repo":"Lightning-AI/pytorch-lightning","slug":"device-should-be-mps-got-device-instead","errorCode":null,"errorMessage":"Device should be MPS, got {device} instead.","messagePattern":"Device should be MPS, got (.+?) instead\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/fabric/accelerators/mps.py","lineNumber":41,"sourceCode":"from lightning.fabric.accelerators.registry import _AcceleratorRegistry\n\n\nclass MPSAccelerator(Accelerator):\n    \"\"\"Accelerator for Metal Apple Silicon GPU devices.\n\n    .. warning::  Use of this accelerator beyond import and instantiation is experimental.\n\n    \"\"\"\n\n    @override\n    def setup_device(self, device: torch.device) -> None:\n        \"\"\"\n        Raises:\n            ValueError:\n                If the selected device is not MPS.\n        \"\"\"\n        if device.type != \"mps\":\n            raise ValueError(f\"Device should be MPS, got {device} instead.\")\n\n    @override\n    def teardown(self) -> None:\n        pass\n\n    @staticmethod\n    @override\n    def parse_devices(devices: Union[int, str, list[int]]) -> Optional[list[int]]:\n        \"\"\"Accelerator device parsing logic.\"\"\"\n        from lightning.fabric.utilities.device_parser import _parse_gpu_ids\n\n        return _parse_gpu_ids(devices, include_mps=True)\n\n    @staticmethod\n    @override\n    def get_parallel_devices(devices: Union[int, str, list[int]]) -> list[torch.device]:\n        \"\"\"Gets parallel devices for the Accelerator.\"\"\"\n        parsed_devices = MPSAccelerator.parse_devices(devices)","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/accelerators/mps.py#L23-L59","documentation":"The DD:HH:MM:SS string for val_check_interval must have four integer components. After the format check (exactly 4 parts) passes, each part is coerced with int(); if any component is non-numeric (e.g. '0:a:0:0', '0.5:0:0:0', empty string part), the ValueError from int() is converted into this MisconfigurationException.","triggerScenarios":"Trainer(val_check_interval='0:0:thirty:0'); Trainer(val_check_interval='00:00:00:1.5'); a component with whitespace or a float like '0.5'; empty component '0::0:0'.","commonSituations":"Building the string from f-strings with unvalidated variables; float seconds intended (e.g. 1.5s) which the format does not support; copy-paste with a missing value leaving an empty slot.","solutions":["Ensure all four components are plain integers: '0:0:0:1' not '0:0:0:1.5'","Construct from validated ints: f\"{d}:{h}:{m}:{s}\" with each an int","Use timedelta(seconds=float) or a dict {'seconds': 1.5} when fractional units are needed"],"exampleFix":"# before\ntrainer = Trainer(val_check_interval=\"0:0:0:1.5\")\n\n# after\nfrom datetime import timedelta\ntrainer = Trainer(val_check_interval=timedelta(seconds=1.5))","handlingStrategy":"validation","validationCode":"def parse_interval(s: str):\n    parts = s.split(\":\")\n    if len(parts) != 4 or not all(p.lstrip(\"-\").isdigit() for p in parts):\n        raise ValueError(\"val_check_interval string must be 'DD:HH:MM:SS' with integers\")\n    return s","typeGuard":"def is_valid_interval_str(v) -> bool:\n    if not isinstance(v, str):\n        return False\n    parts = v.split(\":\")\n    return len(parts) == 4 and all(p.isdigit() for p in parts)","tryCatchPattern":null,"preventionTips":["Never put floats in the DD:HH:MM:SS string; use timedelta(seconds=1.5) instead","Validate the string before constructing the Trainer","Build the string only from int-typed variables"],"tags":["pytorch-lightning","trainer","val-check-interval","parse-error"],"backgroundTag":"invalid-time-format","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}