Lightning-AI/pytorch-lightning · error · MisconfigurationException

The model isn't servable. Investigate the traceback and try

Error message

The model isn't servable. Investigate the traceback and try again.

What it means

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.

Source

Thrown at src/lightning/pytorch/serve/servable_module_validator.py:128

                process.kill()
                raise Exception(f"The server didn't start within {self.timeout} seconds.")
            time.sleep(0.1)

        payload = servable_module.configure_payload()

        if "body" not in payload:
            raise Exception(f'Your provided payload {payload} should have a field named "body".')

        self.resp = requests.post(f"http://{self.host}:{self.port}/serve", json=payload)
        process.kill()

        if is_overridden("configure_response", servable_module, ServableModule):
            response = servable_module.configure_response()
            if self.resp.json() != response:
                raise Exception(f"The expected response {response} doesn't match the generated one {self.resp.json()}.")

        if self.exit_on_failure and not self.successful:
            raise MisconfigurationException("The model isn't servable. Investigate the traceback and try again.")

        if self.successful:
            _logger.info(f"Your model is servable and the received payload was {self.resp.json()}.")

    @property
    def successful(self) -> Optional[bool]:
        """Returns whether the model was successfully served."""
        return self.resp.status_code == 200 if self.resp else None

    @override
    def state_dict(self) -> dict[str, Any]:
        return {"successful": self.successful, "optimization": self.optimization, "server": self.server}

    @staticmethod
    def _start_server(servable_model: ServableModule, host: str, port: int, _: bool) -> None:
        """This method starts a server with a serve and ping endpoints."""
        from fastapi import Body, FastAPI
        from uvicorn import run

View on GitHub (pinned to 9fed5c27d2)

Solutions

  1. Look upward in the log for the real traceback from the serve subprocess — this exception is only the summary
  2. Fix the underlying serve_step/serialization error (e.g. a KeyError from mismatched serializer names)
  3. During development set exit_on_failure=False to let training continue while iterating on serving

Example fix

# before
ServableModuleValidator(host="127.0.0.1", port=8000, exit_on_failure=True)
# after (while debugging)
ServableModuleValidator(host="127.0.0.1", port=8000, exit_on_failure=False)
Defensive patterns

Strategy: fallback

Validate before calling

from lightning.pytorch.serve import ServableModuleValidator

validator = ServableModuleValidator(host="127.0.0.1", port=8000, exit_on_failure=False)
# inspect validator.successful after fit instead of aborting training

Try / catch

try:
    trainer.fit(model, ckpt_path=...)  # serving-gated run
except MisconfigurationException as e:
    if "isn't servable" in str(e):
        # keep serving artifacts out of this run; investigate server logs
        log.warning("Serving validation failed; skipping deploy")
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28). Data as JSON: /api/errors/d6eacb3497785e3f. Report an issue: GitHub.