-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[2/N] Quantization Refactor: Compressed tensors MoE schemes #17503
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
sglang-npu-bot
merged 72 commits into
sgl-project:main
from
TamirBaydasov:compressed_tensors_moe_schemes
Feb 16, 2026
Merged
Changes from all commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
3d3dc09
Compressed tensors MoE schemes initial implementation
TamirBaydasov cb87af5
Apply suggestion from @gemini-code-assist[bot]
TamirBaydasov db90ec7
Apply suggestion from @gemini-code-assist[bot]
TamirBaydasov f6ddc08
Apply suggestion from @gemini-code-assist[bot]
TamirBaydasov d94e307
Apply suggestion from @gemini-code-assist[bot]
TamirBaydasov b6c554e
Merge branch 'sgl-project:main' into compressed_tensors_moe_schemes
TamirBaydasov 1e57ef6
Update layer.py
TamirBaydasov d7351c0
Update kt_ep_wrapper.py
TamirBaydasov 8d5b3ee
Update compressed_tensors.py
TamirBaydasov 96e49df
Update __init__.py
TamirBaydasov e4219c6
Update compressed_tensors_w4a4_nvfp4_moe.py
TamirBaydasov 47b93b1
Update compressed_tensors_w4a8_int8_moe.py
TamirBaydasov 8b2364a
Update compressed_tensors_w8a8_fp8_moe.py
TamirBaydasov 845a724
Update compressed_tensors_w8a8_int8.py
TamirBaydasov c144c81
Update compressed_tensors_w8a8_int8_moe.py
TamirBaydasov c411d95
Update compressed_tensors_wNa16_moe.py
TamirBaydasov b7d9194
Merge branch 'main' into compressed_tensors_moe_schemes
TamirBaydasov 25b3fd4
Update layer.py
TamirBaydasov e439a63
Update compressed_tensors.py
TamirBaydasov 620e43b
Delete python/sglang/srt/layers/quantization/compressed_tensors/compr…
TamirBaydasov 00dcfc1
Update __init__.py
TamirBaydasov 3d15808
Update compressed_tensors_w4a4_nvfp4_moe.py
TamirBaydasov 6b8fc97
Update compressed_tensors_w4a8_int8_moe.py
TamirBaydasov a50a58a
Update compressed_tensors_w8a8_fp8_moe.py
TamirBaydasov 2b0aae2
Update compressed_tensors_w8a8_int8.py
TamirBaydasov dc0e31a
Update compressed_tensors_w8a8_int8_moe.py
TamirBaydasov 5d76dd1
Update compressed_tensors_wNa16_moe.py
TamirBaydasov 4da8049
Update compressed_tensors_w4a8_int8_moe.py
TamirBaydasov 1e275bb
Update compressed_tensors_w8a8_fp8_moe.py
TamirBaydasov 5f70889
Update compressed_tensors_w8a8_int8_moe.py
TamirBaydasov fa62578
Update compressed_tensors_wNa16_moe.py
TamirBaydasov 81886cb
Update layer.py
TamirBaydasov c2da0ea
Update compressed_tensors.py
TamirBaydasov d9b7829
Update __init__.py
TamirBaydasov ae85653
Create compressed_tensors_w4a4_mxint4_moe.py
TamirBaydasov 691bcf3
Merge branch 'main' into compressed_tensors_moe_schemes
TamirBaydasov 886a1eb
Update compressed_tensors_w4a4_mxint4_moe.py
TamirBaydasov edeb1fd
Update layer.py
TamirBaydasov a3cc9e4
Merge branch 'sgl-project:main' into compressed_tensors_moe_schemes
TamirBaydasov 5bb3f99
Update compressed_tensors.py
TamirBaydasov 5c71144
Update compressed_tensors_w4a4_mxint4_moe.py
TamirBaydasov 3ee1e8b
Update compressed_tensors_w4a4_nvfp4_moe.py
TamirBaydasov 1bd3b72
Update compressed_tensors_w4a8_int8_moe.py
TamirBaydasov 33acfb0
Update compressed_tensors_w8a8_fp8_moe.py
TamirBaydasov bceb9e5
Update compressed_tensors_w8a8_int8_moe.py
TamirBaydasov 08d4324
Update compressed_tensors_wNa16_moe.py
TamirBaydasov dc9db4d
Update compressed_tensors_w8a8_int8_moe.py
TamirBaydasov 71ac841
Update compressed_tensors.py
TamirBaydasov b0b0622
Update compressed_tensors_w4a4_mxint4_moe.py
TamirBaydasov e0f6d14
Update compressed_tensors_w4a4_nvfp4_moe.py
TamirBaydasov a5a0a5e
Update compressed_tensors_w4a8_int8_moe.py
TamirBaydasov 04ba6c3
Update compressed_tensors_w8a8_fp8_moe.py
TamirBaydasov 75f9f44
Update compressed_tensors_w8a8_int8_moe.py
TamirBaydasov e6adca3
Update compressed_tensors_wNa16_moe.py
TamirBaydasov 33a6f60
Merge branch 'main' into compressed_tensors_moe_schemes
TamirBaydasov 872e917
Merge branch 'sgl-project:main' into compressed_tensors_moe_schemes
TamirBaydasov e77a4c1
slight fixes
TamirBaydasov 320fe57
apply_without_routing_weights addition to compressedtensorsfusedmoe
TamirBaydasov 779244d
Merge branch 'main' into compressed_tensors_moe_schemes
TamirBaydasov 74c946d
Merge branch 'main' into compressed_tensors_moe_schemes
TamirBaydasov a5aada3
Merge branch 'main' into compressed_tensors_moe_schemes
ping1jing2 45d1daa
Merge branch 'main' into compressed_tensors_moe_schemes
TamirBaydasov 8ad6243
Merge branch 'main' into compressed_tensors_moe_schemes
TamirBaydasov 3480aa3
Merge branch 'main' into compressed_tensors_moe_schemes
ping1jing2 2043bf3
Merge branch 'main' into compressed_tensors_moe_schemes
ping1jing2 85d2c80
Merge branch 'main' into compressed_tensors_moe_schemes
TamirBaydasov 7e67240
Base scheme implementation
TamirBaydasov 6a7cc1f
Remove device capability from base schemes
TamirBaydasov 3633b77
DOcsting fix
TamirBaydasov ac55ea5
Merge branch 'main' into compressed_tensors_moe_schemes
TamirBaydasov 639d2c9
Merge branch 'main' into compressed_tensors_moe_schemes
ping1jing2 2ff3ac5
Merge branch 'main' into compressed_tensors_moe_schemes
AniZpZ 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| from abc import ABC, abstractmethod | ||
| from typing import TYPE_CHECKING, Optional | ||
|
|
||
| import torch | ||
|
|
||
| from sglang.srt.layers.moe import MoeRunnerConfig | ||
|
|
||
| if TYPE_CHECKING: | ||
| from sglang.srt.layers.moe.token_dispatcher import StandardDispatchOutput | ||
|
|
||
| __all__ = ["BaseLinearScheme", "BaseMoEScheme"] | ||
|
|
||
|
|
||
| class BaseLinearScheme(ABC): | ||
| """ | ||
| Abstract class used to describe the weight creation and forward pass | ||
| of different quantization schemes. | ||
| """ | ||
|
|
||
| @abstractmethod | ||
| def create_weights(self, *args, **kwargs): | ||
| """ | ||
| Weight creation for the particular scheme. Inputs to this function | ||
|
|
||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| @abstractmethod | ||
| def process_weights_after_loading(self, layer: torch.nn.Module): | ||
| """ | ||
| Called after weight loading is complete for any cleanup that | ||
| needs to occur. | ||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| @abstractmethod | ||
| def apply_weights( | ||
| self, layer: torch.nn.Module, x: torch.Tensor, bias: Optional[torch.Tensor] | ||
| ): | ||
| """ | ||
| Run the forward pass for the particular scheme. This is where | ||
| scheme-specific dequant/quant steps/kernels should be applied. | ||
|
|
||
| :param layer: torch.nn.Module with the registered weights and | ||
| other parameters relevant to the particular scheme. | ||
| :param x: input to the layer | ||
| :param bias: bias parameter | ||
|
|
||
| """ | ||
| raise NotImplementedError | ||
|
|
||
|
|
||
| class BaseMoEScheme(ABC): | ||
| """ | ||
| Abstract class used to describe the weight creation and forward pass | ||
| of different quantization schemes. | ||
| """ | ||
|
|
||
| @abstractmethod | ||
| def create_weights(self, *args, **kwargs): | ||
| """ | ||
| Weight creation for the particular scheme. Inputs to this function | ||
|
|
||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| @abstractmethod | ||
| def create_moe_runner( | ||
| self, layer: torch.nn.Module, moe_runner_config: MoeRunnerConfig | ||
| ): | ||
| raise NotImplementedError | ||
|
|
||
| @abstractmethod | ||
| def process_weights_after_loading(self, layer: torch.nn.Module): | ||
| """ | ||
| Called after weight loading is complete for any cleanup that | ||
| needs to occur. | ||
| """ | ||
| raise NotImplementedError | ||
|
|
||
| @abstractmethod | ||
| def apply_weights( | ||
| self, | ||
| layer: torch.nn.Module, | ||
| dispatch_output: "StandardDispatchOutput", | ||
| ): | ||
| """ | ||
| Run the forward pass for the particular scheme. This is where | ||
| scheme-specific dequant/quant steps/kernels should be applied. | ||
|
|
||
| :param layer: torch.nn.Module with the registered weights and | ||
| other parameters relevant to the particular scheme. | ||
| :param x: input to the layer | ||
| :param bias: bias parameter | ||
|
|
||
| """ | ||
| raise NotImplementedError |
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.