{"record":{"id":"faeaf2fcafbfb981","repo":"deepset-ai/haystack","slug":"the-disk-device-can-only-be-used-as-a-part-of-devi","errorCode":null,"errorMessage":"The disk device can only be used as a part of device maps","messagePattern":"The disk device can only be used as a part of device maps","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"haystack/utils/device.py","lineNumber":286,"sourceCode":"            The component device representation.\n        \"\"\"\n        device = Device.from_str(device_str)\n        return cls.from_single(device)\n\n    @classmethod\n    def from_single(cls, device: Device) -> \"ComponentDevice\":\n        \"\"\"\n        Create a component device representation from a single device.\n\n        Disks cannot be used as single devices.\n\n        :param device:\n            The device.\n        :returns:\n            The component device representation.\n        \"\"\"\n        if device.type == DeviceType.DISK:\n            raise ValueError(\"The disk device can only be used as a part of device maps\")\n\n        return cls(_single_device=device)\n\n    @classmethod\n    def from_multiple(cls, device_map: DeviceMap) -> \"ComponentDevice\":\n        \"\"\"\n        Create a component device representation from a device map.\n\n        :param device_map:\n            The device map.\n        :returns:\n            The component device representation.\n        \"\"\"\n        return cls(_multiple_devices=device_map)\n\n    def _validate(self) -> None:\n        \"\"\"\n        Validate the component device representation.","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/utils/device.py#L268-L304","documentation":"ComponentDevice.from_single raises ValueError when the given Device is a DISK device. A single disk device is meaningless in Haystack; offloading to disk is only expressible as part of a multi-device map (as accelerate uses it).","triggerScenarios":"Calling ComponentDevice.from_str('disk') or ComponentDevice.from_single(Device(type=DeviceType.DISK, ...)) — note from_str delegates to from_single.","commonSituations":"Setting a pipeline component's device to 'disk' in config hoping to offload to disk; translating accelerate device maps that use 'disk' for some layers and mistakenly extracting it as the single component device.","solutions":["Use a real compute device ('cpu', 'cuda', 'mps', 'xpu') for the component","If you need multi-device/disk offloading, build a DeviceMap via ComponentDevice.from_multiple/DeviceMap with disk entries","Remove 'disk' from single-device config and rely on accelerate's own offloading if applicable"],"exampleFix":"// before\ncomp = ComponentDevice.from_str(\"disk\")\n// after\ncomp = ComponentDevice.from_str(\"cpu\")\n# or for disk offloading use a DeviceMap: ComponentDevice.from_multiple(DeviceMap({\"layer0\": Device(DeviceType.DISK, None), \"layer1\": Device(DeviceType.CUDA, 0)}))","handlingStrategy":"validation","validationCode":"def component_device_from_str_safe(s: str):\n    if s.strip().lower() == \"disk\":\n        raise ValueError(\"disk is only valid inside a DeviceMap\")\n    return ComponentDevice.from_str(s)","typeGuard":"def is_single_computable_device(d: Device) -> bool:\n    return d.type != DeviceType.DISK","tryCatchPattern":"try:\n    comp = ComponentDevice.from_str(cfg_device)\nexcept ValueError as e:\n    print(f\"{cfg_device} unusable as a single device: {e}\")\n    comp = ComponentDevice.from_str(\"cpu\")","preventionTips":["Never set a component's single device to 'disk'","Use DeviceMap/from_multiple when disk offloading is needed","Restrict allowed device values in your config schema"],"tags":["device","gpu","validation","value-error"],"backgroundTag":"invalid-device-string","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}