-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[NPU] NZ for non-quantized MOE, Qwen3 MOE double memory consumption fix #15904
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
iforgetmyname
merged 57 commits into
sgl-project:main
from
OrangeRedeng:memory_and_nz_fix
Jan 28, 2026
Merged
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
711d217
Qwen3 MOE quick fix
eshoguli a5bae60
Merge branch 'ping1jing2:main' into memory_and_nz_fix
OrangeRedeng 2b24ec3
Add nz support for MOE
OrangeRedeng 5eda2b9
Merge branch 'ping1jing2:main' into memory_and_nz_fix
OrangeRedeng 0195e52
Merge branch 'main' into memory_and_nz_fix
OrangeRedeng 2ec286a
Update python/sglang/srt/layers/quantization/unquant.py
OrangeRedeng cecaea0
Merge branch 'main' into memory_and_nz_fix
OrangeRedeng d9a3818
Update unquant.py
OrangeRedeng 1ad1ca1
Update unquant.py
OrangeRedeng e5484c9
Fix lint issue
OrangeRedeng 153b9b7
Merge branch 'main' into memory_and_nz_fix
OrangeRedeng d898855
Merge branch 'main' into memory_and_nz_fix
OrangeRedeng 25a0e56
Remove a non-used env ENABLE_ASCEND_MOE_NZ variable from ascend_npu_q…
OrangeRedeng 61830a2
Remove a non-used env ENABLE_MOE_NZ variable from ascend_npu_qwen3_ex…
OrangeRedeng f586b40
Update NZ converison
OrangeRedeng ecfafa1
Merge branch 'main' into memory_and_nz_fix
OrangeRedeng 4d38ade
Remove unnecessary function
OrangeRedeng 2f4608d
Update layer.py
OrangeRedeng 3699288
Update unquant.py
OrangeRedeng 3092b31
Update layer.py
OrangeRedeng fe2aed7
Update layer.py
OrangeRedeng 1054c9d
Update fused_moe_method_npu.py
OrangeRedeng da5158b
Update fused_moe_method_npu.py
OrangeRedeng 0162b74
Update fused_moe_method_npu.py
OrangeRedeng 019e2d6
Update fused_moe_method_npu.py
OrangeRedeng 8018ee9
Merge branch 'main' into memory_and_nz_fix
OrangeRedeng d02b451
Create test_ascend_memory_consumption.py
OrangeRedeng 312ad28
Merge branch 'main' into memory_and_nz_fix
OrangeRedeng edbba1b
Fix lint issue
OrangeRedeng fa13828
Fix lint issue
OrangeRedeng c78449b
Fix lint issue
OrangeRedeng 5b0b787
Merge branch 'main' into memory_and_nz_fix
OrangeRedeng 5888bd6
Update fused_moe_method_npu.py
OrangeRedeng a2b332d
Merge branch 'main' into memory_and_nz_fix
OrangeRedeng ab233ad
Update test_ascend_memory_consumption.py
OrangeRedeng 5ceeab1
Update run_suite.py
OrangeRedeng 5cfa59c
Merge branch 'main' into memory_and_nz_fix
OrangeRedeng 0d1cfd1
Merge branch 'main' into memory_and_nz_fix
OrangeRedeng a3d2798
Merge branch 'main' into memory_and_nz_fix
OrangeRedeng 929e03b
Merge branch 'main' into memory_and_nz_fix
OrangeRedeng f5462d1
Merge branch 'main' into memory_and_nz_fix
OrangeRedeng b8d8285
Move transpose(1,2) from forward_npu() to process_weights
OrangeRedeng a80de0b
Quickfix
OrangeRedeng 495ee00
Merge branch 'main' into memory_and_nz_fix
iforgetmyname 47a5d8a
Delete test/srt/ascend/test_ascend_memory_consumption.py
OrangeRedeng 87d6963
Rename test_ascend_memory_consumption.py
OrangeRedeng 105e063
Delete test/srt/ascend/test_ascend_memory_consumption.py
OrangeRedeng c501e4e
Add test_ascend_memory_consumption.py
OrangeRedeng 4824eb4
Update run_suite.py
OrangeRedeng f398506
Move test to test/registered
OrangeRedeng bacb1ee
Move test to test/registered
OrangeRedeng 5929c9b
Delete test/srt/ascend/test_ascend_memory_consumption.py
OrangeRedeng 8fbe3a1
Fix lint issue
OrangeRedeng f15c406
Merge branch 'main' into memory_and_nz_fix
OrangeRedeng b08d02c
Merge branch 'main' into memory_and_nz_fix
OrangeRedeng d33144c
Merge branch 'main' into memory_and_nz_fix
iforgetmyname 57fb4a1
Merge branch 'main' into memory_and_nz_fix
iforgetmyname 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
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,76 @@ | ||
| """ | ||
| Usage: | ||
| python3 -m unittest test_ascend_memory_consumption.TestMemoryConsumptionAscend.test_memory_consumption | ||
| """ | ||
|
|
||
| import os | ||
| import unittest | ||
|
|
||
| import torch | ||
|
|
||
| from sglang.srt.utils import kill_process_tree | ||
| from sglang.test.ci.ci_register import register_npu_ci | ||
| from sglang.test.test_utils import ( | ||
| DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH, | ||
| DEFAULT_URL_FOR_TEST, | ||
| CustomTestCase, | ||
| popen_launch_server, | ||
| ) | ||
|
|
||
| register_npu_ci(est_time=400, suite="nightly-1-npu-a3", nightly=True) | ||
|
|
||
| if "ASCEND_RT_VISIBLE_DEVICES" not in os.environ: | ||
| os.environ["ASCEND_RT_VISIBLE_DEVICES"] = "0,1" | ||
| DEFAULT_PORT_FOR_SRT_TEST_RUNNER = ( | ||
| 8000 + int(os.environ.get("ASCEND_RT_VISIBLE_DEVICES", "0")[0]) * 100 | ||
| ) | ||
| DEFAULT_URL_FOR_TEST = f"http://127.0.0.1:{DEFAULT_PORT_FOR_SRT_TEST_RUNNER + 1000}" | ||
|
|
||
|
|
||
| class TestMemoryConsumptionAscend(CustomTestCase): | ||
|
|
||
| def test_memory_consumption(self): | ||
|
|
||
| model = "nytopop/Qwen3-30B-A3B.w8a8" | ||
| base_url = DEFAULT_URL_FOR_TEST | ||
|
|
||
| ### Calculate initial used memory | ||
| free_npu_memory, total_npu_memory = torch.npu.mem_get_info() | ||
| initial_used_memory = total_npu_memory - free_npu_memory | ||
|
|
||
| process = popen_launch_server( | ||
| model, | ||
| base_url, | ||
| timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH, | ||
| other_args=[ | ||
| "--trust-remote-code", | ||
| "--device", | ||
| "npu", | ||
| "--attention-backend", | ||
| "ascend", | ||
| "--tp-size", | ||
| "2", | ||
| "--mem-fraction-static", | ||
| "0.8", | ||
| "--cuda-graph-bs", | ||
| "1", | ||
| "--max-total-tokens", | ||
| "1024", | ||
| "--disable-radix-cache", | ||
| "--disable-cuda-graph", | ||
| ], | ||
| ) | ||
|
|
||
| ### Calculate initial used memory | ||
| free_npu_memory, total_npu_memory = torch.npu.mem_get_info() | ||
| used_memory_after_server_starting = ( | ||
| total_npu_memory - free_npu_memory - initial_used_memory | ||
| ) / (1 << 30) | ||
| self.assertLessEqual(float(used_memory_after_server_starting), 16.00) | ||
|
|
||
| # Clean up everything | ||
| kill_process_tree(process.pid) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
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.