Skip to content
Merged
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*.csv
build/
docs/build/
dist/

*.pkl
*.png
Expand Down
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include LICENSE
include requirements.txt

recursive-include csrc *
2 changes: 2 additions & 0 deletions cacheflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from cacheflow.server.llm_server import LLMServer
from cacheflow.server.ray_utils import initialize_cluster

__version__ = "0.1.0"

__all__ = [
"LLM",
"SamplingParams",
Expand Down
Empty file added cacheflow/core/__init__.py
Empty file.
Empty file.
Empty file.
Empty file.
Empty file added cacheflow/server/__init__.py
Empty file.
Empty file added cacheflow/worker/__init__.py
Empty file.
3 changes: 1 addition & 2 deletions docs/source/getting_started/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ You can install CacheFlow using pip:
$ conda activate myenv

$ # Install CacheFlow.
$ pip install cacheflow
$ pip install cacheflow # This may take 5-10 minutes.


.. _build_from_source:
Expand All @@ -46,5 +46,4 @@ You can also build and install CacheFlow from source.

$ git clone https://github.com/WoosukKwon/cacheflow.git
$ cd cacheflow
$ pip install -r requirements.txt
$ pip install -e . # This may take 5-10 minutes.
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[build-system]
requires = [
"ninja",
"packaging",
"setuptools",
"torch >= 2.0.0",
"wheel",
]
build-backend = "setuptools.build_meta"
60 changes: 55 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import io
import os
import re
import subprocess
from typing import List, Set

from packaging.version import parse, Version
import setuptools
import torch
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
from torch.utils.cpp_extension import CUDA_HOME
from torch.utils.cpp_extension import BuildExtension, CUDAExtension, CUDA_HOME

ROOT_DIR = os.path.dirname(__file__)

# Compiler flags.
CXX_FLAGS = ["-g", "-O2"]
CXX_FLAGS = ["-g", "-O2", "-std=c++17"]
# TODO(woosuk): Should we use -O3?
NVCC_FLAGS = ["-O2"]
NVCC_FLAGS = ["-O2", "-std=c++17"]

ABI = 1 if torch._C._GLIBCXX_USE_CXX11_ABI else 0
CXX_FLAGS += [f"-D_GLIBCXX_USE_CXX11_ABI={ABI}"]
NVCC_FLAGS += [f"-D_GLIBCXX_USE_CXX11_ABI={ABI}"]

if not torch.cuda.is_available():
raise RuntimeError(
Expand Down Expand Up @@ -102,15 +109,58 @@ def get_nvcc_cuda_version(cuda_dir: str) -> Version:
ext_modules.append(activation_extension)


def get_path(*filepath) -> str:
return os.path.join(ROOT_DIR, *filepath)


def find_version(filepath: str):
"""Extract version information from the given filepath.

Adapted from https://github.com/ray-project/ray/blob/0b190ee1160eeca9796bc091e07eaebf4c85b511/python/setup.py
"""
with open(filepath) as fp:
version_match = re.search(
r"^__version__ = ['\"]([^'\"]*)['\"]", fp.read(), re.M)
if version_match:
return version_match.group(1)
raise RuntimeError("Unable to find version string.")


def read_readme() -> str:
"""Read the README file."""
return io.open(get_path("README.md"), "r", encoding="utf-8").read()


def get_requirements() -> List[str]:
"""Get Python package dependencies from requirements.txt."""
with open("requirements.txt") as f:
with open(get_path("requirements.txt")) as f:
requirements = f.read().strip().split("\n")
return requirements


setuptools.setup(
name="cacheflow",
version=find_version(get_path("cacheflow", "__init__.py")),
author="CacheFlow Team",
author_email="[email protected]",
license="Apache 2.0",
description="CacheFlow: A high-performance LLM Serving System",
long_description=read_readme(),
long_description_content_type="text/markdown",
url="https://github.com/WoosukKwon/cacheflow",
project_urls={
"Homepage": "https://github.com/WoosukKwon/cacheflow",
"Documentation": "https://cacheflow.readthedocs.io/en/latest/",
},
classifiers=[
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"License :: OSI Approved :: Apache Software License",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
],
packages=setuptools.find_packages(
exclude=("benchmarks", "csrc", "docs", "examples", "tests")),
python_requires=">=3.8",
install_requires=get_requirements(),
ext_modules=ext_modules,
Expand Down