-
Notifications
You must be signed in to change notification settings - Fork 606
add ppu quick start doc #3841
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
Open
guozixu2001
wants to merge
9
commits into
InternLM:main
Choose a base branch
from
guozixu2001:gzx/add_ppu_doc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add ppu quick start doc #3841
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2aebb40
add ppu quick start doc
guozixu2001 be36259
fix lint error
guozixu2001 65c53a1
fix lint error
guozixu2001 3190235
add supported_models doc
guozixu2001 5a246ec
Merge branch 'gzx/add_ppu_doc' of https://github.com/guozixu2001/lmde…
guozixu2001 e019976
fix: remove main in example code, remove unsupported model
guozixu2001 ef051d0
remove main in example code
guozixu2001 c4d03f3
add ppu to index.rst
guozixu2001 03dda48
fix caption
guozixu2001 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Get Started with PPU | ||
|
||
The usage of lmdeploy on a ppu device is almost the same as its usage on CUDA with PytorchEngine in lmdeploy. | ||
Please read the original [Get Started](../get_started.md) guide before reading this tutorial. | ||
|
||
## Installation | ||
|
||
Please refer to [dlinfer installation guide](https://github.com/DeepLink-org/dlinfer#%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95). | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we need to setup the device software toolkit? |
||
## Offline batch inference | ||
|
||
> \[!TIP\] | ||
> Graph mode is supported on ppu. | ||
> Users can set `eager_mode=False` to enable graph mode, or set `eager_mode=True` to disable graph mode. | ||
|
||
### LLM inference | ||
|
||
Set `device_type="ppu"` in the `PytorchEngineConfig`: | ||
|
||
```python | ||
from lmdeploy import pipeline | ||
from lmdeploy import PytorchEngineConfig | ||
|
||
pipe = pipeline("internlm/internlm2_5-7b-chat", | ||
backend_config=PytorchEngineConfig(tp=1, device_type="ppu", eager_mode=False)) | ||
question = ['Hi, pls intro yourself', 'Shanghai is'] | ||
response = pipe(question) | ||
print(response) | ||
``` | ||
|
||
### VLM inference | ||
|
||
Set `device_type="ppu"` in the `PytorchEngineConfig`: | ||
|
||
```python | ||
from lmdeploy import pipeline, PytorchEngineConfig | ||
from lmdeploy.vl import load_image | ||
|
||
pipe = pipeline('OpenGVLab/InternVL2-2B', | ||
backend_config=PytorchEngineConfig(tp=1, device_type='ppu', eager_mode=False)) | ||
image = load_image('https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/tests/data/tiger.jpeg') | ||
response = pipe(('describe this image', image)) | ||
print(response) | ||
``` | ||
|
||
## Online serving | ||
|
||
> \[!TIP\] | ||
> Graph mode is supported on ppu. | ||
> Graph mode is default enabled in online serving. Users can add `--eager-mode` to disable graph mode. | ||
|
||
### Serve an LLM model | ||
|
||
Add `--device ppu` in the serve command. | ||
|
||
```bash | ||
lmdeploy serve api_server --backend pytorch --device ppu --eager-mode internlm/internlm2_5-7b-chat | ||
``` | ||
|
||
### Serve a VLM model | ||
|
||
Add `--device ppu` in the serve command | ||
|
||
```bash | ||
lmdeploy serve api_server --backend pytorch --device ppu --eager-mode OpenGVLab/InternVL2-2B | ||
``` | ||
|
||
## Inference with Command line Interface | ||
|
||
Add `--device ppu` in the serve command. | ||
|
||
```bash | ||
lmdeploy chat internlm/internlm2_5-7b-chat --backend pytorch --device ppu --eager-mode | ||
``` |
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 |
---|---|---|
|
@@ -6,3 +6,9 @@ | |
:caption: NPU(Huawei) | ||
|
||
ascend/get_started.md | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:caption: PPU | ||
|
||
ppu/get_started.md |
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,72 @@ | ||
# 在阿里平头哥上快速开始 | ||
|
||
我们基于 LMDeploy 的 PytorchEngine,增加了平头哥设备的支持。所以,在平头哥上使用 LMDeploy 的方法与在英伟达 GPU 上使用 PytorchEngine 后端的方法几乎相同。在阅读本教程之前,请先阅读原版的[快速开始](../get_started.md)。 | ||
|
||
## 安装 | ||
|
||
安装请参考 [dlinfer 安装方法](https://github.com/DeepLink-org/dlinfer#%E5%AE%89%E8%A3%85%E6%96%B9%E6%B3%95)。 | ||
|
||
## 离线批处理 | ||
|
||
> \[!TIP\] | ||
> 图模式已支持。用户可以设定`eager_mode=False`来开启图模式,或者设定`eager_mode=True`来关闭图模式。 | ||
|
||
### LLM 推理 | ||
|
||
将`device_type="ppu"`加入`PytorchEngineConfig`的参数中。 | ||
|
||
```python | ||
from lmdeploy import pipeline | ||
from lmdeploy import PytorchEngineConfig | ||
|
||
pipe = pipeline("internlm/internlm2_5-7b-chat", | ||
backend_config=PytorchEngineConfig(tp=1, device_type="ppu", eager_mode=True)) | ||
question = ["Shanghai is", "Please introduce China", "How are you?"] | ||
response = pipe(question) | ||
print(response) | ||
``` | ||
|
||
### VLM 推理 | ||
|
||
将`device_type="ppu"`加入`PytorchEngineConfig`的参数中。 | ||
|
||
```python | ||
from lmdeploy import pipeline, PytorchEngineConfig | ||
from lmdeploy.vl import load_image | ||
|
||
pipe = pipeline('OpenGVLab/InternVL2-2B', | ||
backend_config=PytorchEngineConfig(tp=1, device_type='ppu', eager_mode=True)) | ||
image = load_image('https://raw.githubusercontent.com/open-mmlab/mmdeploy/main/tests/data/tiger.jpeg') | ||
response = pipe(('describe this image', image)) | ||
print(response) | ||
``` | ||
|
||
## 在线服务 | ||
|
||
> \[!TIP\] | ||
> 图模式已支持。 | ||
> 在线服务时,图模式默认开启,用户可以添加`--eager-mode`来关闭图模式。 | ||
|
||
### LLM 模型服务 | ||
|
||
将`--device ppu`加入到服务启动命令中。 | ||
|
||
```bash | ||
lmdeploy serve api_server --backend pytorch --device ppu --eager-mode internlm/internlm2_5-7b-chat | ||
``` | ||
|
||
### VLM 模型服务 | ||
|
||
将`--device ppu`加入到服务启动命令中。 | ||
|
||
```bash | ||
lmdeploy serve api_server --backend pytorch --device ppu --eager-mode OpenGVLab/InternVL2-2B | ||
``` | ||
|
||
## 使用命令行与LLM模型对话 | ||
|
||
将`--device ppu`加入到服务启动命令中。 | ||
|
||
```bash | ||
lmdeploy chat internlm/internlm2_5-7b-chat --backend pytorch --device ppu --eager-mode | ||
``` |
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
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.
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.
But this links describe installation on ascend platform.
cc @jinminxi104