-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TritonScaledMMLinearKernel implementation
Signed-off-by: Randall Smith <[email protected]>
- Loading branch information
Showing
2 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
38 changes: 38 additions & 0 deletions
38
vllm/model_executor/layers/quantization/kernels/scaled_mm/triton.py
This file contains 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,38 @@ | ||
from typing import Optional, Tuple | ||
|
||
import torch | ||
|
||
from vllm.platforms import current_platform | ||
|
||
from .cutlass import CutlassScaledMMLinearKernel | ||
from .ScaledMMLinearKernel import ScaledMMLinearLayerConfig | ||
|
||
|
||
class TritonScaledMMLinearKernel(CutlassScaledMMLinearKernel): | ||
|
||
@classmethod | ||
def get_min_capability(cls) -> int: | ||
return 75 | ||
|
||
@classmethod | ||
def can_implement( | ||
cls, c: ScaledMMLinearLayerConfig) -> Tuple[bool, Optional[str]]: | ||
if current_platform.is_cpu(): | ||
return ( | ||
False, | ||
"TritonScaledMMLinearKernel requires Triton which is not " + | ||
"currently supported on CPU.") | ||
if not c.input_symmetric: | ||
return (False, | ||
"TritonScaledMMLinearKernel only supports symmetric " + | ||
"quantization.") | ||
return True, None | ||
|
||
def process_weights_after_loading(self, layer: torch.nn.Module) -> None: | ||
super().process_weights_after_loading(layer) | ||
|
||
def apply_weights(self, | ||
layer: torch.nn.Module, | ||
x: torch.Tensor, | ||
bias: Optional[torch.Tensor] = None) -> torch.Tensor: | ||
return super().apply_weights(layer, x, bias) |