-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
83 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,34 @@ | ||
## vllm | ||
## vLLM | ||
|
||
### Setup | ||
``` | ||
pip install vllm | ||
``` | ||
|
||
### Example | ||
local | ||
``` | ||
python vllm_local.py | ||
``` | ||
Ray cluster | ||
``` | ||
ray init | ||
python vllm_on_ray.py | ||
``` | ||
Test: | ||
``` | ||
curl http://localhost:8000/inference?query="Who%20are%20you" | ||
``` | ||
|
||
### TODO | ||
- deploy vllm on k8s with helm chart | ||
- vllm on remote ray cluster | ||
- ray cluster internals | ||
|
||
### References | ||
- [vllm](https://github.com/vllm/vllm) | ||
- https://zhuanlan.zhihu.com/p/710614883 | ||
- https://docs.ray.io/en/latest/serve/tutorials/vllm-example.html | ||
- https://docs.vllm.ai/en/latest/ | ||
- https://github.com/vllm-project/vllm/issues/1363 | ||
- http://kubeagi.k8s.com.cn/docs/Concepts/models | ||
- https://github.com/skypilot-org/skypilot |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from vllm import LLM | ||
|
||
llm = LLM("qwen/qwen2-0.5B") | ||
output = llm.generate("Who are you?") | ||
print(output) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from fastapi import FastAPI | ||
from ray import serve | ||
from vllm import LLM | ||
|
||
app = FastAPI() | ||
|
||
|
||
@serve.deployment(num_replicas=1, ray_actor_options={"num_gpus": 1}) | ||
@serve.ingress(app) | ||
class FastAPIDeployment: | ||
def __init__(self): | ||
self.llm = LLM("qwen/qwen2-0.5B") | ||
|
||
@app.get("/inference") | ||
def model_inference(self, query: str) -> str: | ||
print("query: %s" % query) | ||
output = self.llm.generate(query) | ||
return str(output) | ||
|
||
@app.get("/hello") | ||
def hello(self) -> str: | ||
return "hello" | ||
|
||
|
||
serve.run(FastAPIDeployment.bind(), route_prefix="/", name="qwen2_model_service") |