{"record":{"id":"6006d59f0fbe657a","repo":"Lightning-AI/pytorch-lightning","slug":"the-configure-payload-method-needs-to-be-overrid","errorCode":null,"errorMessage":"The `configure_payload` method needs to be overridden.","messagePattern":"The `configure_payload` method needs to be overridden\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/serve/servable_module_validator.py","lineNumber":88,"sourceCode":"        self.server = server\n        self.timeout = timeout\n        self.exit_on_failure = exit_on_failure\n        self.resp: Optional[requests.Response] = None\n\n    @override\n    @rank_zero_only\n    def on_train_start(self, trainer: \"pl.Trainer\", servable_module: \"pl.LightningModule\") -> None:\n        if isinstance(trainer.strategy, _NOT_SUPPORTED_STRATEGIES):\n            raise Exception(\n                f\"The current strategy {trainer.strategy.__class__.__qualname__} used \"\n                \"by the trainer isn't supported for sanity serving yet.\"\n            )\n\n        if not isinstance(servable_module, ServableModule):\n            raise TypeError(f\"The provided model should be subclass of {ServableModule.__qualname__}.\")\n\n        if not is_overridden(\"configure_payload\", servable_module, ServableModule):\n            raise NotImplementedError(\"The `configure_payload` method needs to be overridden.\")\n        if not is_overridden(\"configure_serialization\", servable_module, ServableModule):\n            raise NotImplementedError(\"The `configure_serialization` method needs to be overridden.\")\n        if not is_overridden(\"serve_step\", servable_module, ServableModule):\n            raise NotImplementedError(\"The `serve_step` method needs to be overridden.\")\n\n        # Note: The Trainer needs to be detached from the pl_module before starting the process.\n        # This would fail during the deepcopy with DDP.\n        servable_module.trainer = None\n\n        process = Process(target=self._start_server, args=(servable_module, self.host, self.port, self.optimization))\n        process.start()\n\n        servable_module.trainer = trainer\n\n        ready = False\n        t0 = time.time()\n        while not ready:\n            with contextlib.suppress(requests.exceptions.ConnectionError):","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/serve/servable_module_validator.py#L70-L106","documentation":"Lightning's ServableModuleValidator requires any ServableModule passed to serving validation to implement configure_payload. The check runs in on_train_start via is_overridden; if your model still uses the base ServableModule stub, serving metadata cannot be generated and training halts with NotImplementedError.","triggerScenarios":"Attaching ServableModuleValidator callback to a Trainer whose model subclasses ServableModule but does not override configure_payload (only configure_serialization or serve_step implemented).","commonSituations":"Partially implementing the ServableModule interface, copy-pasting an example model and deleting the payload method, or upgrading Lightning where the serving API became stricter.","solutions":["Override configure_payload in your LightningModule to return the request payload dict, e.g. {\"body\": {\"x\": ...}}","Ensure the override signature matches ServableModule.configure_payload (no args, returns dict)","Alternatively drop ServableModuleValidator from the callbacks list if serving validation is not needed"],"exampleFix":"// before\nclass MyModel(ServableModule):\n    def configure_serialization(self): ...\n    def serve_step(self, **kwargs): ...\n// after\nclass MyModel(ServableModule):\n    def configure_payload(self):\n        return {\"body\": {\"x\": self.example_input}}\n    def configure_serialization(self): ...\n    def serve_step(self, **kwargs): ...","handlingStrategy":"validation","validationCode":"from lightning.pytorch.utilities import is_overridden\nfrom lightning.pytorch.serve import ServableModule\n\nrequired = [\"configure_payload\", \"configure_serialization\", \"serve_step\"]\nmissing = [m for m in required if not is_overridden(m, model, ServableModule)]\nassert not missing, f\"Override required methods: {missing}\"","typeGuard":"def is_fully_servable(m) -> bool:\n    return all(\n        is_overridden(meth, m, ServableModule)\n        for meth in (\"configure_payload\", \"configure_serialization\", \"serve_step\")\n    )","tryCatchPattern":null,"preventionTips":["Implement all three ServableModule hooks together as a checklist","Add a unit test asserting is_overridden for each required method before training"],"tags":["lightning","serving","not-implemented","pytorch"],"backgroundTag":"abstract-method-not-implemented","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}