-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[Feat] Support native Kimi-K2-Thinking native W4A16 quantized experts weights #4516
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
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
ee8e7d2
feat(quantization): add `W4A16` quantization moe method for native Ki…
zhoux77899 5963482
fix(bug): fix missing keyword arguments
zhoux77899 5e86d7b
test(ci): add unit and e2e test cases
zhoux77899 b1b8abd
Merge branch 'vllm-project:main' into k2-thinking
zhoux77899 8b2b7e1
fix(doc): add new doc to index
zhoux77899 a9260a9
fix(typo): fix typo
zhoux77899 18a5c20
Merge branch 'main' into k2-thinking
zhoux77899 5d81c44
fix(bug): fix missing line after resolving conflicts
zhoux77899 1655a7b
test(ci): add test case to workflows
zhoux77899 206fe00
fix(bug): consider some fused_moe quant_methods do not have `group_si…
zhoux77899 06b96c0
Merge branch 'vllm-project:main' into k2-thinking
zhoux77899 0933400
feat(quant): adapt quant method of "compressed-tensors"
zhoux77899 fcea26f
test(ci): remove quantization param
zhoux77899 e9f1cfd
fix(lint): fix json in doc
zhoux77899 9aa3f51
Merge branch 'vllm-project:main' into k2-thinking
zhoux77899 235dfe2
test(ci): change test to 4 cards and add some assertions
zhoux77899 78ea4eb
Merge branch 'vllm-project:main' into k2-thinking
zhoux77899 82bf2be
Merge branch 'vllm-project:main' into k2-thinking
zhoux77899 7bcad09
Merge branch 'vllm-project:main' into k2-thinking
zhoux77899 bb00b3b
Merge branch 'main' into k2-thinking
zhoux77899 178969d
fix(bug): add missing parameters after merging
zhoux77899 7f8117f
fix(bug): add missing parameters after merging
zhoux77899 4a7f453
Merge branch 'vllm-project:main' into k2-thinking
zhoux77899 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| # Multi-NPU (Kimi-K2-Thinking) | ||
|
|
||
| ## Run with Docker | ||
|
|
||
| ```{code-block} bash | ||
| :substitutions: | ||
| # Update the vllm-ascend image | ||
| export IMAGE=m.daocloud.io/quay.io/ascend/vllm-ascend:|vllm_ascend_version| | ||
| export NAME=vllm-ascend | ||
|
|
||
| # Run the container using the defined variables | ||
| # Note: If you are running bridge network with docker, please expose available ports for multiple nodes communication in advance | ||
| docker run --rm \ | ||
| --name $NAME \ | ||
| --net=host \ | ||
| --shm-size=1g \ | ||
| --device /dev/davinci0 \ | ||
| --device /dev/davinci1 \ | ||
| --device /dev/davinci2 \ | ||
| --device /dev/davinci3 \ | ||
| --device /dev/davinci4 \ | ||
| --device /dev/davinci5 \ | ||
| --device /dev/davinci6 \ | ||
| --device /dev/davinci7 \ | ||
| --device /dev/davinci8 \ | ||
| --device /dev/davinci9 \ | ||
| --device /dev/davinci10 \ | ||
| --device /dev/davinci11 \ | ||
| --device /dev/davinci12 \ | ||
| --device /dev/davinci13 \ | ||
| --device /dev/davinci14 \ | ||
| --device /dev/davinci15 \ | ||
| --device /dev/davinci_manager \ | ||
| --device /dev/devmm_svm \ | ||
| --device /dev/hisi_hdc \ | ||
| -v /usr/local/dcmi:/usr/local/dcmi \ | ||
| -v /usr/local/Ascend/driver/tools/hccn_tool:/usr/local/Ascend/driver/tools/hccn_tool \ | ||
| -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \ | ||
| -v /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/ \ | ||
| -v /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info \ | ||
| -v /etc/ascend_install.info:/etc/ascend_install.info \ | ||
| -v /mnt/sfs_turbo/.cache:/home/cache \ | ||
| -it $IMAGE bash | ||
| ``` | ||
|
|
||
| ## Verify the Quantized Model | ||
| Please be advised to edit the value of `"quantization_config.config_groups.group_0.targets"` from `["Linear"]` into `["MoE"]` in `config.json` of original model downloaded from [Hugging Face](https://huggingface.co/moonshotai/Kimi-K2-Thinking). | ||
|
|
||
| ```json | ||
| { | ||
| "quantization_config": { | ||
| "config_groups": { | ||
| "group_0": { | ||
| "targets": [ | ||
| "MoE" | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Your model files look like: | ||
|
|
||
| ```bash | ||
| . | ||
| |-- chat_template.jinja | ||
| |-- config.json | ||
| |-- configuration_deepseek.py | ||
| |-- configuration.json | ||
| |-- generation_config.json | ||
| |-- model-00001-of-000062.safetensors | ||
| |-- ... | ||
| |-- model-00062-of-000062.safetensors | ||
| |-- model.safetensors.index.json | ||
| |-- modeling_deepseek.py | ||
| |-- tiktoken.model | ||
| |-- tokenization_kimi.py | ||
| `-- tokenizer_config.json | ||
| ``` | ||
|
|
||
| ## Online Inference on Multi-NPU | ||
|
|
||
| Run the following script to start the vLLM server on Multi-NPU: | ||
|
|
||
| For an Atlas 800 A3 (64G*16) node, tensor-parallel-size should be at least 16. | ||
|
|
||
| ```bash | ||
| vllm serve Kimi-K2-Thinking \ | ||
| --served-model-name kimi-k2-thinking \ | ||
| --tensor-parallel-size 16 \ | ||
| --enable_expert_parallel \ | ||
| --trust-remote-code \ | ||
| --no-enable-prefix-caching | ||
| ``` | ||
|
|
||
| Once your server is started, you can query the model with input prompts. | ||
|
|
||
| ```bash | ||
| curl http://localhost:8000/v1/chat/completions -H "Content-Type: application/json" -d '{ | ||
| "model": "kimi-k2-thinking", | ||
| "messages": [ | ||
| {"role": "user", "content": "Who are you?"} | ||
| ], | ||
| "temperature": 1.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
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.