{"record":{"id":"17fc3fdce1e74be6","repo":"keras-team/keras","slug":"argument-layout-map-must-be-a-layoutmap-instan","errorCode":null,"errorMessage":"Argument `layout_map` must be a `LayoutMap` instance. Received: layout_map={layout_map}","messagePattern":"Argument `layout_map` must be a `LayoutMap` instance\\. Received: layout_map=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/distribution/distribution_lib.py","lineNumber":631,"sourceCode":"            first axis from the device mesh will be used.\n        auto_shard_dataset: Automatically shard the dataset amongst\n            processes in a multi-process setting. Set to `False` if the dataset\n            is already sharded across hosts.  Defaults to `True`.\n    \"\"\"\n\n    def __init__(\n        self,\n        *,\n        layout_map=None,\n        batch_dim_name=None,\n        auto_shard_dataset=True,\n        **kwargs,\n    ):\n        kwargs.pop(\"device_mesh\", None)\n        if layout_map is None:\n            raise ValueError(\"You must specify a layout_map argument.\")\n        if not isinstance(layout_map, LayoutMap):\n            raise ValueError(\n                \"Argument `layout_map` must be a `LayoutMap` instance. \"\n                f\"Received: layout_map={layout_map}\"\n            )\n        device_mesh = layout_map.device_mesh\n        batch_dim_name = batch_dim_name or device_mesh.axis_names[0]\n        super().__init__(device_mesh, batch_dim_name, auto_shard_dataset)\n        self._layout_map = layout_map\n\n        if (\n            self._is_multi_process\n            and self.num_processes > self.num_model_replicas\n            and self.num_processes % self.num_model_replicas != 0\n        ):\n            raise ValueError(\n                \"If `num_processes` is greater than `num_model_replicas`, \"\n                \"`num_processes` must be divisible by `num_model_replicas`. \"\n                f\"Got num_processes={self.num_processes}, \"\n                f\"num_model_replicas={self.num_model_replicas}.\"","sourceCodeStart":613,"sourceCodeEnd":649,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/distribution/distribution_lib.py#L613-L649","documentation":"Error \"Argument `layout_map` must be a `LayoutMap` instance. Received: layout_map={layout_map}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/distribution/distribution_lib.py:631 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}