Skip to content

Commit cfe23c5

Browse files
committed
Enable CodeGen vLLM service as default
Signed-off-by: Wang, Xigui <xigui.wang@intel.com>
1 parent 43d0a18 commit cfe23c5

8 files changed

Lines changed: 417 additions & 194 deletions

File tree

CodeGen/docker_compose/intel/cpu/xeon/README.md

Lines changed: 84 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Build MegaService of CodeGen on Xeon
22

33
This document outlines the deployment process for a CodeGen application utilizing the [GenAIComps](https://github.com/opea-project/GenAIComps.git) microservice pipeline on Intel Xeon server. The steps include Docker images creation, container deployment via Docker Compose, and service execution to integrate microservices such as `llm`. We will publish the Docker images to Docker Hub soon, further simplifying the deployment process for this service.
4+
The default pipeline deploys with vLLM as the LLM serving component. It also provides options of using TGI backend for LLM microservice.
45

56
## 🚀 Create an AWS Xeon Instance
67

@@ -10,55 +11,6 @@ For detailed information about these instance types, you can refer to [m7i](http
1011

1112
After launching your instance, you can connect to it using SSH (for Linux instances) or Remote Desktop Protocol (RDP) (for Windows instances). From there, you'll have full access to your Xeon server, allowing you to install, configure, and manage your applications as needed.
1213

13-
## 🚀 Download or Build Docker Images
14-
15-
Should the Docker image you seek not yet be available on Docker Hub, you can build the Docker image locally.
16-
17-
### 1. Build the LLM Docker Image
18-
19-
```bash
20-
git clone https://github.com/opea-project/GenAIComps.git
21-
cd GenAIComps
22-
docker build -t opea/llm-textgen:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/llms/src/text-generation/Dockerfile .
23-
```
24-
25-
### 2. Build the MegaService Docker Image
26-
27-
To construct the Mega Service, we utilize the [GenAIComps](https://github.com/opea-project/GenAIComps.git) microservice pipeline within the `codegen.py` Python script. Build MegaService Docker image via the command below:
28-
29-
```bash
30-
git clone https://github.com/opea-project/GenAIExamples
31-
cd GenAIExamples/CodeGen
32-
docker build -t opea/codegen:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f Dockerfile .
33-
```
34-
35-
### 3. Build the UI Docker Image
36-
37-
Build the frontend Docker image via the command below:
38-
39-
```bash
40-
cd GenAIExamples/CodeGen/ui
41-
docker build -t opea/codegen-ui:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f ./docker/Dockerfile .
42-
```
43-
44-
### 4. Build CodeGen React UI Docker Image (Optional)
45-
46-
Build react frontend Docker image via below command:
47-
48-
**Export the value of the public IP address of your Xeon server to the `host_ip` environment variable**
49-
50-
```bash
51-
cd GenAIExamples/CodeGen/ui
52-
docker build --no-cache -t opea/codegen-react-ui:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f ./docker/Dockerfile.react .
53-
```
54-
55-
Then run the command `docker images`, you will have the following Docker Images:
56-
57-
- `opea/llm-textgen:latest`
58-
- `opea/codegen:latest`
59-
- `opea/codegen-ui:latest`
60-
- `opea/codegen-react-ui:latest` (optional)
61-
6214
## 🚀 Start Microservices and MegaService
6315

6416
The CodeGen megaservice manages a single microservice called LLM within a Directed Acyclic Graph (DAG). In the diagram above, the LLM microservice is a language model microservice that generates code snippets based on the user's input query. The TGI service serves as a text generation interface, providing a RESTful API for the LLM microservice. The CodeGen Gateway acts as the entry point for the CodeGen application, invoking the Megaservice to generate code snippets in response to the user's input query.
@@ -89,42 +41,55 @@ flowchart LR
8941

9042
Since the `compose.yaml` will consume some environment variables, you need to setup them in advance as below.
9143

92-
**Append the value of the public IP address to the no_proxy list**
44+
1. set the host_ip and huggingface token
9345

46+
> Note:
47+
> Please replace the `your_ip_address` with you external IP address, do not use `localhost`.
48+
49+
```bash
50+
export host_ip=${your_ip_address}
51+
export HUGGINGFACEHUB_API_TOKEN=you_huggingface_token
9452
```
95-
export your_no_proxy=${your_no_proxy},"External_Public_IP"
96-
```
53+
54+
2. Set Netowork Proxy
55+
56+
**If you access public network through proxy, set the network proxy, otherwise, skip this step**
9757

9858
```bash
9959
export no_proxy=${your_no_proxy}
10060
export http_proxy=${your_http_proxy}
101-
export https_proxy=${your_http_proxy}
102-
export LLM_MODEL_ID="Qwen/Qwen2.5-Coder-7B-Instruct"
103-
export TGI_LLM_ENDPOINT="http://${host_ip}:8028"
104-
export HUGGINGFACEHUB_API_TOKEN=${your_hf_api_token}
105-
export MEGA_SERVICE_HOST_IP=${host_ip}
106-
export LLM_SERVICE_HOST_IP=${host_ip}
107-
export BACKEND_SERVICE_ENDPOINT="http://${host_ip}:7778/v1/codegen"
61+
export https_proxy=${your_https_proxy}
10862
```
10963

110-
Note: Please replace the `host_ip` with you external IP address, do not use `localhost`.
111-
11264
### Start the Docker Containers for All Services
11365

66+
CodeGen support TGI service and vLLM service, you can choose start either one of them.
67+
68+
Start CodeGen based on TGI service:
11469
```bash
115-
cd GenAIExamples/CodeGen/docker_compose/intel/cpu/xeon
116-
docker compose up -d
70+
cd GenAIExamples/CodeGen/docker_compose
71+
source set_env.sh
72+
cd intel/cpu/xeon
73+
docker compose --profile codegen-xeon-tgi up -d
74+
```
75+
76+
Start CodeGen based on vLLM service:
77+
```bash
78+
cd GenAIExamples/CodeGen/docker_compose
79+
source set_env.sh
80+
cd intel/cpu/xeon
81+
docker compose --profile codegen-xeon-vllm up -d
11782
```
11883

11984
### Validate the MicroServices and MegaService
12085

121-
1. TGI Service
86+
1. LLM Service (for TGI, vLLM)
12287

12388
```bash
124-
curl http://${host_ip}:8028/generate \
125-
-X POST \
126-
-d '{"inputs":"Implement a high-level API for a TODO list application. The API takes as input an operation request and updates the TODO list in place. If the request is invalid, raise an exception.","parameters":{"max_new_tokens":256, "do_sample": true}}' \
127-
-H 'Content-Type: application/json'
89+
curl http://${host_ip}:8028/v1/chat/completions \
90+
-X POST \
91+
-d '{"model": "Qwen/Qwen2.5-Coder-7B-Instruct", "messages": [{"role": "user", "content": "Implement a high-level API for a TODO list application. The API takes as input an operation request and updates the TODO list in place. If the request is invalid, raise an exception."}], "max_tokens":32}' \
92+
-H 'Content-Type: application/json'
12893
```
12994

13095
2. LLM Microservices
@@ -257,3 +222,54 @@ For example:
257222
- Ask question and get answer
258223

259224
![qna](../../../../assets/img/codegen_qna.png)
225+
226+
227+
## 🚀 Download or Build Docker Images
228+
229+
Should the Docker image you seek not yet be available on Docker Hub, you can build the Docker image locally.
230+
231+
### 1. Build the LLM Docker Image
232+
233+
```bash
234+
git clone https://github.com/opea-project/GenAIComps.git
235+
cd GenAIComps
236+
docker build -t opea/llm-textgen:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/llms/src/text-generation/Dockerfile .
237+
```
238+
239+
### 2. Build the MegaService Docker Image
240+
241+
To construct the Mega Service, we utilize the [GenAIComps](https://github.com/opea-project/GenAIComps.git) microservice pipeline within the `codegen.py` Python script. Build MegaService Docker image via the command below:
242+
243+
```bash
244+
git clone https://github.com/opea-project/GenAIExamples
245+
cd GenAIExamples/CodeGen
246+
docker build -t opea/codegen:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f Dockerfile .
247+
```
248+
249+
### 3. Build the UI Docker Image
250+
251+
Build the frontend Docker image via the command below:
252+
253+
```bash
254+
cd GenAIExamples/CodeGen/ui
255+
docker build -t opea/codegen-ui:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f ./docker/Dockerfile .
256+
```
257+
258+
### 4. Build CodeGen React UI Docker Image (Optional)
259+
260+
Build react frontend Docker image via below command:
261+
262+
**Export the value of the public IP address of your Xeon server to the `host_ip` environment variable**
263+
264+
```bash
265+
cd GenAIExamples/CodeGen/ui
266+
docker build --no-cache -t opea/codegen-react-ui:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f ./docker/Dockerfile.react .
267+
```
268+
269+
Then run the command `docker images`, you will have the following Docker Images:
270+
271+
- `opea/llm-textgen:latest`
272+
- `opea/codegen:latest`
273+
- `opea/codegen-ui:latest`
274+
- `opea/codegen-react-ui:latest` (optional)
275+

CodeGen/docker_compose/intel/cpu/xeon/compose.yaml

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
services:
55
tgi-service:
66
image: ghcr.io/huggingface/text-generation-inference:2.4.0-intel-cpu
7-
container_name: tgi-service
7+
container_name: tgi-server
8+
profiles:
9+
- codegen-xeon-tgi
810
ports:
911
- "8028:80"
1012
volumes:
@@ -22,28 +24,66 @@ services:
2224
timeout: 10s
2325
retries: 100
2426
command: --model-id ${LLM_MODEL_ID} --cuda-graphs 0
25-
llm:
27+
vllm-service:
28+
image: ${REGISTRY:-opea}/vllm:${TAG:-latest}
29+
container_name: vllm-server
30+
profiles:
31+
- codegen-xeon-vllm
32+
ports:
33+
- "8028:80"
34+
volumes:
35+
- "${MODEL_CACHE:-./data}:/root/.cache/huggingface/hub"
36+
shm_size: 1g
37+
environment:
38+
no_proxy: ${no_proxy}
39+
http_proxy: ${http_proxy}
40+
https_proxy: ${https_proxy}
41+
HF_TOKEN: ${HUGGINGFACEHUB_API_TOKEN}
42+
host_ip: ${host_ip}
43+
healthcheck:
44+
test: ["CMD-SHELL", "curl -f http://$host_ip:8028/health || exit 1"]
45+
interval: 10s
46+
timeout: 10s
47+
retries: 100
48+
command: --model ${LLM_MODEL_ID} --host 0.0.0.0 --port 80
49+
llm-base:
2650
image: ${REGISTRY:-opea}/llm-textgen:${TAG:-latest}
2751
container_name: llm-textgen-server
28-
depends_on:
29-
tgi-service:
30-
condition: service_healthy
31-
ports:
32-
- "9000:9000"
33-
ipc: host
3452
environment:
3553
no_proxy: ${no_proxy}
3654
http_proxy: ${http_proxy}
3755
https_proxy: ${https_proxy}
38-
LLM_ENDPOINT: ${TGI_LLM_ENDPOINT}
56+
LLM_ENDPOINT: ${LLM_ENDPOINT}
3957
LLM_MODEL_ID: ${LLM_MODEL_ID}
4058
HUGGINGFACEHUB_API_TOKEN: ${HUGGINGFACEHUB_API_TOKEN}
4159
restart: unless-stopped
60+
llm-tgi-service:
61+
extends: llm-base
62+
container_name: llm-codegen-tgi-server
63+
profiles:
64+
- codegen-xeon-tgi
65+
ports:
66+
- "9000:9000"
67+
ipc: host
68+
depends_on:
69+
tgi-service:
70+
condition: service_healthy
71+
llm-vllm-service:
72+
extends: llm-base
73+
container_name: llm-codegen-vllm-server
74+
profiles:
75+
- codegen-xeon-vllm
76+
ports:
77+
- "9000:9000"
78+
ipc: host
79+
depends_on:
80+
vllm-service:
81+
condition: service_healthy
4282
codegen-xeon-backend-server:
4383
image: ${REGISTRY:-opea}/codegen:${TAG:-latest}
4484
container_name: codegen-xeon-backend-server
4585
depends_on:
46-
- llm
86+
- llm-base
4787
ports:
4888
- "7778:7778"
4989
environment:

0 commit comments

Comments
 (0)