-
Notifications
You must be signed in to change notification settings - Fork 737
[Intel HPU] Support intel hpu platform #4161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Jiang-Jia-Jun
merged 13 commits into
PaddlePaddle:develop
from
fmiao2372:integration_upstreaming
Sep 24, 2025
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3272a7c
[Intel HPU] Support intel hpu platform
fmiao2372 5db9e35
fix some issues
fmiao2372 3468976
apply precommit and move AttentionBackend_HPU
fmiao2372 e985aff
fix format issue
fmiao2372 d07a484
correct ops import
fmiao2372 934a499
fix ci issue
fmiao2372 972face
update code in layers
fmiao2372 cb55256
fix code style issue
fmiao2372 3368638
remove dense tp moe ep mode
fmiao2372 f510a49
fix enc_dec_block_num
fmiao2372 cdc1d07
fix rebase issue
fmiao2372 28d5ed7
rename hpu to gaudi in readme
fmiao2372 d750f6d
rename ForwardMeta_HPU to HPUForwardMeta
fmiao2372 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,75 @@ | ||
| # Intel Gaudi Installation for running ERNIE 4.5 Series Models | ||
|
|
||
| The following installation methods are available when your environment meets these requirements: | ||
|
|
||
| - Python 3.10 | ||
| - Intel Gaudi 2 | ||
| - Intel Gaudi software version 1.22.0 | ||
| - Linux X86_64 | ||
|
|
||
| ## 1. Run Docker Container | ||
|
|
||
| Use the following commands to run a Docker container. Make sure to update the versions below as listed in the [Support Matrix](https://docs.habana.ai/en/latest/Support_Matrix/Support_Matrix.html): | ||
|
|
||
| ```{.console} | ||
| $ docker pull vault.habana.ai/gaudi-docker/1.22.0/ubuntu22.04/habanalabs/pytorch-installer-2.7.1:latest | ||
| $ docker run -it --runtime=habana -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none --cap-add=sys_nice --net=host --ipc=host vault.habana.ai/gaudi-docker/1.22.0/ubuntu22.04/habanalabs/pytorch-installer-2.7.1:latest | ||
| ``` | ||
|
|
||
| ### 2. Install PaddlePaddle | ||
|
|
||
| ```bash | ||
| python -m pip install paddlepaddle==3.1.1 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/ | ||
| ``` | ||
|
|
||
| ### 3. Install PaddleCustomDevice | ||
| ```shell | ||
| git clone https://github.com/PaddlePaddle/PaddleCustomDevice | ||
| cd PaddleCustomDevice/backends/intel_hpu/ | ||
| mkdir -p build | ||
| cd build | ||
| cmake .. | ||
| make -j | ||
| pip install --force-reinstall dist/paddle_intel_hpu*.whl | ||
| cd PaddleCustomDevice/backends/intel_hpu/custom_ops | ||
| python setup.py install | ||
| ``` | ||
|
|
||
| ### 4. Install FastDeploy | ||
|
|
||
| ```shell | ||
| git clone https://github.com/PaddlePaddle/FastDeploy | ||
| cd FastDeploy | ||
| bash build.sh | ||
| ``` | ||
|
|
||
| ## Prepare the inference demo | ||
|
|
||
| ### 1. Start inference service | ||
| ```shell | ||
| export GC_KERNEL_PATH=/usr/lib/habanalabs/libtpc_kernels.so | ||
| export GC_KERNEL_PATH=/usr/local/lib/python3.10/dist-packages/paddle_custom_device/intel_hpu/libcustom_tpc_perf_lib.so:$GC_KERNEL_PATH | ||
| export INTEL_HPU_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 | ||
| export PADDLE_DISTRI_BACKEND=xccl | ||
| export PADDLE_XCCL_BACKEND=intel_hpu | ||
| export HABANA_PROFILE=0 | ||
| export HPU_VISIBLE_DEVICES=0 | ||
|
|
||
| HPU_WARMUP_BUCKET=1 HPU_WARMUP_MODEL_LEN=4096 FD_ATTENTION_BACKEND=HPU_ATTN python -m fastdeploy.entrypoints.openai.api_server --model ERNIE-4.5-21B-A3B-Paddle --tensor-parallel-size 1 --max-model-len 32768 --max-num-seqs 128 | ||
| ``` | ||
|
|
||
| ### 2. Launch the request | ||
| ```bash | ||
| curl -X POST "http://0.0.0.0:8188/v1/chat/completions" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{ | ||
| "messages": [ | ||
| {"role": "user", "content": "What is AI?"} | ||
| ], "max_tokens": 24 | ||
| }' | ||
| ``` | ||
|
|
||
| ### 3. Successfully returns the result | ||
| ```json | ||
| {"id":"chatcmpl-3bd98ae2-fafe-46ae-a552-d653a8526503","object":"chat.completion","created":1757653575,"model":"ERNIE-4.5-21B-A3B-Paddle","choices":[{"index":0,"message":{"role":"assistant","content":"**AI (Artificial Intelligence)** refers to the development of computer systems that can perform tasks typically requiring human intelligence.","multimodal_content":null,"reasoning_content":null,"tool_calls":null,"prompt_token_ids":null,"completion_token_ids":null,"text_after_process":null,"raw_prediction":null,"prompt_tokens":null,"completion_tokens":null},"logprobs":null,"finish_reason":"length"}],"usage":{"prompt_tokens":11,"total_tokens":35,"completion_tokens":24,"prompt_tokens_details":{"cached_tokens":0}}} | ||
| ``` |
This file contains hidden or 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 hidden or 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,75 @@ | ||
| # 使用 Intel Gaudi 运行ERNIE 4.5 系列模型 | ||
|
|
||
| 在环境满足如下条件前提下 | ||
|
|
||
| - Python 3.10 | ||
| - Intel Gaudi 2 | ||
| - Intel Gaudi software version 1.22.0 | ||
| - Linux X86_64 | ||
|
|
||
| ## 1. 运行Docker容器 | ||
|
|
||
| 使用下面命令运行Docker容器. 确保更新的版本在如下列表中 [Support Matrix](https://docs.habana.ai/en/latest/Support_Matrix/Support_Matrix.html): | ||
|
|
||
| ```{.console} | ||
| $ docker pull vault.habana.ai/gaudi-docker/1.22.0/ubuntu22.04/habanalabs/pytorch-installer-2.7.1:latest | ||
| $ docker run -it --runtime=habana -e HABANA_VISIBLE_DEVICES=all -e OMPI_MCA_btl_vader_single_copy_mechanism=none --cap-add=sys_nice --net=host --ipc=host vault.habana.ai/gaudi-docker/1.22.0/ubuntu22.04/habanalabs/pytorch-installer-2.7.1:latest | ||
| ``` | ||
|
|
||
| ### 2. 安装 PaddlePaddle | ||
|
|
||
| ```bash | ||
| python -m pip install paddlepaddle==3.1.1 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/ | ||
| ``` | ||
|
|
||
| ### 3. 安装 PaddleCustomDevice | ||
| ```shell | ||
| git clone https://github.com/PaddlePaddle/PaddleCustomDevice | ||
| cd PaddleCustomDevice/backends/intel_hpu/ | ||
| mkdir -p build | ||
| cd build | ||
| cmake .. | ||
| make -j | ||
| pip install --force-reinstall dist/paddle_intel_hpu*.whl | ||
| cd PaddleCustomDevice/backends/intel_hpu/custom_ops | ||
| python setup.py install | ||
| ``` | ||
|
|
||
| ### 4. 安装 FastDeploy | ||
|
|
||
| ```shell | ||
| git clone https://github.com/PaddlePaddle/FastDeploy | ||
| cd FastDeploy | ||
| bash build.sh | ||
| ``` | ||
|
|
||
| ## 准备推理示例 | ||
|
|
||
| ### 1. 启动推理服务 | ||
| ```shell | ||
| export GC_KERNEL_PATH=/usr/lib/habanalabs/libtpc_kernels.so | ||
| export GC_KERNEL_PATH=/usr/local/lib/python3.10/dist-packages/paddle_custom_device/intel_hpu/libcustom_tpc_perf_lib.so:$GC_KERNEL_PATH | ||
| export INTEL_HPU_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 | ||
| export PADDLE_DISTRI_BACKEND=xccl | ||
| export PADDLE_XCCL_BACKEND=intel_hpu | ||
| export HABANA_PROFILE=0 | ||
| export HPU_VISIBLE_DEVICES=0 | ||
|
|
||
| HPU_WARMUP_BUCKET=1 HPU_WARMUP_MODEL_LEN=4096 FD_ATTENTION_BACKEND=HPU_ATTN python -m fastdeploy.entrypoints.openai.api_server --model ERNIE-4.5-21B-A3B-Paddle --tensor-parallel-size 1 --max-model-len 32768 --max-num-seqs 128 | ||
| ``` | ||
|
|
||
| ### 2. 发送请求 | ||
| ```bash | ||
| curl -X POST "http://0.0.0.0:8188/v1/chat/completions" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{ | ||
| "messages": [ | ||
| {"role": "user", "content": "What is AI?"} | ||
| ], "max_tokens": 24 | ||
| }' | ||
| ``` | ||
|
|
||
| ### 3. 成功返回结果 | ||
| ```json | ||
| {"id":"chatcmpl-3bd98ae2-fafe-46ae-a552-d653a8526503","object":"chat.completion","created":1757653575,"model":"ERNIE-4.5-21B-A3B-Paddle","choices":[{"index":0,"message":{"role":"assistant","content":"**AI (Artificial Intelligence)** refers to the development of computer systems that can perform tasks typically requiring human intelligence.","multimodal_content":null,"reasoning_content":null,"tool_calls":null,"prompt_token_ids":null,"completion_token_ids":null,"text_after_process":null,"raw_prediction":null,"prompt_tokens":null,"completion_tokens":null},"logprobs":null,"finish_reason":"length"}],"usage":{"prompt_tokens":11,"total_tokens":35,"completion_tokens":24,"prompt_tokens_details":{"cached_tokens":0}}} | ||
| ``` |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
命名是否可以与上面其他硬件保持一致呢,HPUForwardMeta
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已改为HPUForwardMeta