-
Notifications
You must be signed in to change notification settings - Fork 257
feat: Add Ascend npu support. #576
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
menogrey
wants to merge
10
commits into
sgl-project:main
Choose a base branch
from
menogrey:add_npu_support
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
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
939be3f
Adapt torch.compile backend for npu.
menogrey e66eca7
feat: add automatic device detection for non-CUDA backends
mingliangfu 5c2c104
Add npu device support.
menogrey 3a37b4c
Fix TemplateError for not having first user message.
menogrey 4a942ff
Add NPU triton logsoftmaxloss implement to save the memory.
menogrey b3eb2bb
Add npu llama3.1 online example.
menogrey 3a0ce09
Add npu requirements.txt for user installation.
menogrey 10339f3
Add installation guide for ascend npu.
menogrey 57647e1
Replace torch.get_device_module
menogrey a8a2e07
Fix format.
menogrey 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,30 @@ | ||
| SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
| ROOT_DIR=$(dirname $SCRIPT_DIR) | ||
|
|
||
| export TORCHINDUCTOR_CACHE_DIR=$ROOT_DIR/cache/compiled_kernels | ||
| # train eagle3 for llama3.1-8b | ||
| NUM_GPUS=${1:-1} | ||
| TP_SIZE=${2:-1} | ||
| BUILD_DATASET_NUM_PROC=${BUILD_DATASET_NUM_PROC:-64} | ||
|
|
||
| # Currently we only train with --max-length 2048 due to OOM issue on A3(64GB) | ||
| torchrun \ | ||
| --standalone \ | ||
| --nproc_per_node $NUM_GPUS \ | ||
| $ROOT_DIR/scripts/train_eagle3.py \ | ||
| --target-model-path meta-llama/Llama-3.1-8B-Instruct \ | ||
| --draft-model-config $ROOT_DIR/configs/llama3-8B-eagle3.json \ | ||
| --train-data-path $ROOT_DIR/cache/dataset/sharegpt_train.jsonl \ | ||
| --build-dataset-num-proc $BUILD_DATASET_NUM_PROC \ | ||
| --output-dir $ROOT_DIR/outputs/llama3-8b-eagle3-sharegpt \ | ||
| --num-epochs 10 \ | ||
| --batch-size 1 \ | ||
| --tp-size $TP_SIZE \ | ||
| --learning-rate 1e-4 \ | ||
| --max-length 2048 \ | ||
| --chat-template llama3 \ | ||
| --cache-dir $ROOT_DIR/cache \ | ||
| --attention-backend sdpa \ | ||
| --target-model-backend sglang \ | ||
| --log-interval 10 \ | ||
| --sglang-mem-fraction-static 0.3 | ||
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,24 @@ | ||
| # Use the PyTorch CPU wheel index cause torch_npu depends on a CPU version of PyTorch | ||
| --extra-index-url https://download.pytorch.org/whl/cpu | ||
|
|
||
| pre-commit | ||
| torch==2.8.0+cpu | ||
| torch_npu==2.8.0.post2 | ||
| torchaudio==2.8.0 | ||
| torchvision==0.23.0 | ||
| transformers==4.57.1 | ||
| qwen-vl-utils==0.0.11 | ||
| datasets | ||
| setuptools | ||
| tqdm | ||
| wandb | ||
| psutil | ||
| numpy | ||
| accelerate | ||
| pydantic | ||
| sglang==0.5.9 | ||
| openai-harmony | ||
| ninja | ||
| packaging | ||
| yunchang | ||
| tensorboard |
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.
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.
Unquoted variables in shell scripts can cause word splitting and globbing issues if paths contain spaces or special characters. It is highly recommended to double-quote all variable expansions like
$ROOT_DIRand$BUILD_DATASET_NUM_PROCto ensure robustness.