Skip to content

Commit

Permalink
Update litserve dependency (#1356)
Browse files Browse the repository at this point in the history
Co-authored-by: Carlos Mocholí <[email protected]>
  • Loading branch information
rasbt and carmocca authored Apr 25, 2024
1 parent b9ddd8b commit 1d69eac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions litgpt/deploy/serve.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Copyright Lightning AI. Licensed under the Apache License 2.0, see LICENSE file.
from pathlib import Path
from typing import Dict, Any, Optional, Literal
from typing import Dict, Any, Optional
from litgpt.utils import check_valid_checkpoint_dir

import lightning as L
from lightning_utilities.core.imports import RequirementCache
import torch
from litserve import LitAPI, LitServer


from litgpt.model import GPT
from litgpt.config import Config
Expand All @@ -15,6 +16,13 @@
from litgpt.utils import load_checkpoint, CLI, get_default_supported_precision


_LITSERVE_AVAILABLE = RequirementCache("litserve")
if _LITSERVE_AVAILABLE:
from litserve import LitAPI, LitServer
else:
LitAPI, LitServer = object, object


class SimpleLitAPI(LitAPI):
def __init__(self,
checkpoint_dir: Path,
Expand All @@ -23,6 +31,9 @@ def __init__(self,
top_k: int = 50,
max_new_tokens: int = 50) -> None:

if not _LITSERVE_AVAILABLE:
raise ImportError(str(_LITSERVE_AVAILABLE))

super().__init__()
self.checkpoint_dir = checkpoint_dir
self.precision = precision
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ license = { file = "LICENSE" }
dependencies = [
"torch>=2.2.0",
"lightning==2.3.0.dev20240328",
"jsonargparse[signatures]>=4.27.6",
"litserve>=0.1.0" # imported by litgpt.deploy
"jsonargparse[signatures]>=4.27.6"
]

[project.urls]
Expand All @@ -38,6 +37,7 @@ all = [
"tokenizers>=0.15.2", # pythia, falcon, redpajama
"requests>=2.31.0", # litgpt.data
"litdata>=0.2.2", # litgpt.data
"litserve>=0.1.0", # litgpt.deploy
"zstandard>=0.22.0", # litgpt.data.prepare_slimpajama.py
"pandas>=1.9.0", # litgpt.data.prepare_starcoder.py
"pyarrow>=15.0.2", # litgpt.data.prepare_starcoder.py
Expand Down

0 comments on commit 1d69eac

Please sign in to comment.