{"record":{"id":"d6eacb3497785e3f","repo":"Lightning-AI/pytorch-lightning","slug":"the-model-isn-t-servable-investigate-the-tracebac","errorCode":null,"errorMessage":"The model isn't servable. Investigate the traceback and try again.","messagePattern":"The model isn't servable\\. Investigate the traceback and try again\\.","errorType":"exception","errorClass":"MisconfigurationException","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/serve/servable_module_validator.py","lineNumber":128,"sourceCode":"                process.kill()\n                raise Exception(f\"The server didn't start within {self.timeout} seconds.\")\n            time.sleep(0.1)\n\n        payload = servable_module.configure_payload()\n\n        if \"body\" not in payload:\n            raise Exception(f'Your provided payload {payload} should have a field named \"body\".')\n\n        self.resp = requests.post(f\"http://{self.host}:{self.port}/serve\", json=payload)\n        process.kill()\n\n        if is_overridden(\"configure_response\", servable_module, ServableModule):\n            response = servable_module.configure_response()\n            if self.resp.json() != response:\n                raise Exception(f\"The expected response {response} doesn't match the generated one {self.resp.json()}.\")\n\n        if self.exit_on_failure and not self.successful:\n            raise MisconfigurationException(\"The model isn't servable. Investigate the traceback and try again.\")\n\n        if self.successful:\n            _logger.info(f\"Your model is servable and the received payload was {self.resp.json()}.\")\n\n    @property\n    def successful(self) -> Optional[bool]:\n        \"\"\"Returns whether the model was successfully served.\"\"\"\n        return self.resp.status_code == 200 if self.resp else None\n\n    @override\n    def state_dict(self) -> dict[str, Any]:\n        return {\"successful\": self.successful, \"optimization\": self.optimization, \"server\": self.server}\n\n    @staticmethod\n    def _start_server(servable_model: ServableModule, host: str, port: int, _: bool) -> None:\n        \"\"\"This method starts a server with a serve and ping endpoints.\"\"\"\n        from fastapi import Body, FastAPI\n        from uvicorn import run","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/serve/servable_module_validator.py#L110-L146","documentation":"When ServableModuleValidator is created with exit_on_failure=True and the /serve request failed (self.successful is falsy), a MisconfigurationException is raised telling you the model isn't servable and to investigate the traceback.","triggerScenarios":"The POST to /serve returned a non-200 response (exception inside serve_step, missing serializer key, deserialization error) while exit_on_failure=True, so training aborts after validation.","commonSituations":"Running serving validation as a gate in CI/training pipeline; the underlying cause is an earlier serve_step or serialization bug whose traceback appears in the server logs before this exception.","solutions":["Look upward in the log for the real traceback from the serve subprocess — this exception is only the summary","Fix the underlying serve_step/serialization error (e.g. a KeyError from mismatched serializer names)","During development set exit_on_failure=False to let training continue while iterating on serving"],"exampleFix":"# before\nServableModuleValidator(host=\"127.0.0.1\", port=8000, exit_on_failure=True)\n# after (while debugging)\nServableModuleValidator(host=\"127.0.0.1\", port=8000, exit_on_failure=False)","handlingStrategy":"fallback","validationCode":"from lightning.pytorch.serve import ServableModuleValidator\n\nvalidator = ServableModuleValidator(host=\"127.0.0.1\", port=8000, exit_on_failure=False)\n# inspect validator.successful after fit instead of aborting training","typeGuard":null,"tryCatchPattern":"try:\n    trainer.fit(model, ckpt_path=...)  # serving-gated run\nexcept MisconfigurationException as e:\n    if \"isn't servable\" in str(e):\n        # keep serving artifacts out of this run; investigate server logs\n        log.warning(\"Serving validation failed; skipping deploy\")\n    else:\n        raise","preventionTips":["Use exit_on_failure=False during development","Always read the subprocess traceback above this exception for the root cause"],"tags":["lightning","serving","misconfiguration","pipeline-gate"],"backgroundTag":"serving-validation-failed","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}