Skip to content

Commit 7f5111a

Browse files
authored
LLM: Refine start script for Pipeline Parallel Serving (#11557)
Refine start script and readme for Pipeline Parallel Serving
1 parent 1355b2c commit 7f5111a

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

docker/llm/serving/xpu/docker/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export DOCKER_IMAGE=intelanalytics/ipex-llm-serving-xpu:2.1.0-SNAPSHOT
2323
sudo docker run -itd \
2424
--net=host \
2525
--device=/dev/dri \
26-
--memory="32G" \
2726
--name=CONTAINER_NAME \
2827
--shm-size="16g" \
2928
$DOCKER_IMAGE

docker/llm/serving/xpu/docker/start-pp_serving-service.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ if [[ $KERNEL_VERSION != *"6.5"* ]]; then
1414
fi
1515
export TORCH_LLM_ALLREDUCE=0
1616

17+
export IPEX_LLM_LAST_LM_HEAD=1
1718
export IPEX_LLM_QUANTIZE_KV_CACHE=1
19+
export IPEX_LLM_LOW_MEM=1
1820
export num_gpus=2
1921
export model_path="/llm/models/Llama-2-7b-chat-hf"
2022
export low_bit="fp8"
2123
# max requests = max_num_reqs * rank_num
2224
export max_num_seqs="4"
25+
export max_prefilled_seqs="0"
26+
2327
cd /llm/pp_serving
24-
CCL_ZE_IPC_EXCHANGE=sockets torchrun --standalone --nnodes=1 --nproc-per-node $num_gpus pipeline_serving.py --repo-id-or-model-path $model_path --low-bit $low_bit --max-num-seqs $max_num_seqs
28+
CCL_ZE_IPC_EXCHANGE=sockets torchrun --standalone --nnodes=1 --nproc-per-node $num_gpus pipeline_serving.py --repo-id-or-model-path $model_path --low-bit $low_bit --max-num-seqs $max_num_seqs --max-prefilled-seqs $max_prefilled_seqs

python/llm/example/GPU/Pipeline-Parallel-FastAPI/run.sh

+9-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,16 @@ if [[ $KERNEL_VERSION != *"6.5"* ]]; then
2828
export SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1
2929
fi
3030
export TORCH_LLM_ALLREDUCE=0
31+
export IPEX_LLM_QUANTIZE_KV_CACHE=1
32+
export IPEX_LLM_LAST_LM_HEAD=1
33+
export IPEX_LLM_LOW_MEM=1
3134

3235
export MODEL_PATH=YOUR_MODEL_PATH
3336
export NUM_GPUS=2
34-
export IPEX_LLM_QUANTIZE_KV_CACHE=1
37+
export ZE_AFFINITY_MASK=0,1
38+
export LOW_BIT="fp8"
39+
# max requests = max_num_reqs * rank_num
40+
export MAX_NUM_SEQS="4"
41+
export MAX_PREFILLED_SEQS=0
3542

36-
CCL_ZE_IPC_EXCHANGE=sockets torchrun --standalone --nnodes=1 --nproc-per-node $NUM_GPUS pipeline_serving.py --repo-id-or-model-path $MODEL_PATH --low-bit fp8 --max-num-seqs 4 --max-prefilled-seqs 0
43+
CCL_ZE_IPC_EXCHANGE=sockets torchrun --standalone --nnodes=1 --nproc-per-node $NUM_GPUS pipeline_serving.py --repo-id-or-model-path $MODEL_PATH --low-bit $LOW_BIT --max-num-seqs $MAX_NUM_SEQS --max-prefilled-seqs $MAX_PREFILLED_SEQS

python/llm/src/ipex_llm/transformers/pipeline_parallel.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ def load_model(self, model_path, world_size, low_bit='sym_int4'):
447447
model = AutoModelForCausalLM.from_pretrained(model_path,
448448
load_in_low_bit=low_bit,
449449
torch_dtype=self.dtype,
450+
cpu_embedding=True,
450451
optimize_model=True,
451452
trust_remote_code=True,
452453
use_cache=True,
@@ -499,7 +500,8 @@ def cat_kv_cache(self, model_type, kv_cache_1, kv_cache_2):
499500
return tuple(result)
500501
else:
501502
# num_layers = self.model.layer_end - self.model.layer_start
502-
for layer_idx in range(self.model.num_layers):
503+
num_cache = min(len(kv_cache_1.key_cache), self.model.num_layers)
504+
for layer_idx in range(num_cache):
503505
kv_cache_1.key_cache[layer_idx] = \
504506
torch.cat([kv_cache_1.key_cache[layer_idx],
505507
kv_cache_2.key_cache[layer_idx]], dim=0)

0 commit comments

Comments
 (0)