|
23 | 23 | MarlinFP8ScaledMMLinearKernel, |
24 | 24 | ) |
25 | 25 | from vllm.model_executor.layers.fused_moe import RoutedExperts |
| 26 | +from vllm.model_executor.layers.fused_moe.config import FusedMoEConfig |
26 | 27 | from vllm.model_executor.layers.fused_moe.oracle.fp8 import ( |
27 | 28 | select_fp8_moe_backend, |
28 | 29 | ) |
@@ -111,7 +112,7 @@ def _is_tp_sharded(layer: Module, *, reduces_output_dim: bool = True) -> bool: |
111 | 112 | return is_row_parallel or (reduces_output_dim and is_column_parallel) |
112 | 113 |
|
113 | 114 |
|
114 | | -class _Fp8OnlineLinearBase(LinearMethodBase): |
| 115 | +class OnlineLinearBase(LinearMethodBase): |
115 | 116 | """Shared base for online FP8 linear methods. Loads fp16/bf16 checkpoint |
116 | 117 | weights onto meta device and materializes them just-in-time.""" |
117 | 118 |
|
@@ -155,7 +156,7 @@ def create_weights( |
155 | 156 | initialize_online_processing(layer) |
156 | 157 |
|
157 | 158 |
|
158 | | -class Fp8PerTensorOnlineLinearMethod(_Fp8OnlineLinearBase): |
| 159 | +class Fp8PerTensorOnlineLinearMethod(OnlineLinearBase): |
159 | 160 | """Online tensorwise FP8 linear quantization. |
160 | 161 | Loads fp16/bf16 weights and quantizes them per-tensor during loading.""" |
161 | 162 |
|
@@ -256,7 +257,7 @@ def apply( |
256 | 257 | return self.fp8_linear.apply_weights(layer, x, bias) |
257 | 258 |
|
258 | 259 |
|
259 | | -class Fp8PerBlockOnlineLinearMethod(_Fp8OnlineLinearBase): |
| 260 | +class Fp8PerBlockOnlineLinearMethod(OnlineLinearBase): |
260 | 261 | """Online blockwise FP8 linear quantization. |
261 | 262 | Loads fp16/bf16 weights and quantizes them per-block during loading.""" |
262 | 263 |
|
@@ -336,7 +337,7 @@ def apply( |
336 | 337 | ) |
337 | 338 |
|
338 | 339 |
|
339 | | -class Fp8PtpcOnlineLinearMethod(_Fp8OnlineLinearBase): |
| 340 | +class Fp8PtpcOnlineLinearMethod(OnlineLinearBase): |
340 | 341 | """Online PTPC FP8 linear quantization. |
341 | 342 |
|
342 | 343 | Per-output-channel weight scale + dynamic per-token activation scale. The |
@@ -443,12 +444,12 @@ def __init__( |
443 | 444 | self, |
444 | 445 | *, |
445 | 446 | weight_block_size: list[int] | None, |
446 | | - layer: torch.nn.Module, |
| 447 | + moe: FusedMoEConfig, |
447 | 448 | weight_key: "QuantKey | None" = None, |
448 | 449 | activation_key: "QuantKey | None" = None, |
449 | 450 | allow_vllm_cutlass: bool = False, |
450 | 451 | ): |
451 | | - super().__init__(layer.moe_config) |
| 452 | + super().__init__(moe) |
452 | 453 | self.weight_block_size = weight_block_size |
453 | 454 | self.block_quant: bool = self.weight_block_size is not None |
454 | 455 | self.weight_scale_name = ( |
@@ -555,11 +556,11 @@ class Fp8PerTensorOnlineMoEMethod(_Fp8OnlineMoEBase): |
555 | 556 | def __init__( |
556 | 557 | self, |
557 | 558 | *, |
558 | | - layer: torch.nn.Module, |
| 559 | + moe: FusedMoEConfig, |
559 | 560 | ): |
560 | 561 | super().__init__( |
561 | 562 | weight_block_size=None, |
562 | | - layer=layer, |
| 563 | + moe=moe, |
563 | 564 | ) |
564 | 565 |
|
565 | 566 | def process_weights_after_loading(self, layer: Module) -> None: |
@@ -612,11 +613,11 @@ class Fp8PerBlockOnlineMoEMethod(_Fp8OnlineMoEBase): |
612 | 613 | def __init__( |
613 | 614 | self, |
614 | 615 | *, |
615 | | - layer: torch.nn.Module, |
| 616 | + moe: FusedMoEConfig, |
616 | 617 | ): |
617 | 618 | super().__init__( |
618 | 619 | weight_block_size=[128, 128], |
619 | | - layer=layer, |
| 620 | + moe=moe, |
620 | 621 | ) |
621 | 622 |
|
622 | 623 | def maybe_roundup_sizes( |
@@ -716,13 +717,13 @@ class Fp8PtpcOnlineMoEMethod(_Fp8OnlineMoEBase): |
716 | 717 | def __init__( |
717 | 718 | self, |
718 | 719 | *, |
719 | | - layer: torch.nn.Module, |
| 720 | + moe: FusedMoEConfig, |
720 | 721 | ): |
721 | 722 | from vllm.model_executor.layers.fused_moe.oracle.fp8 import Fp8MoeBackend |
722 | 723 |
|
723 | 724 | super().__init__( |
724 | 725 | weight_block_size=None, |
725 | | - layer=layer, |
| 726 | + moe=moe, |
726 | 727 | weight_key=kFp8StaticChannelSym, |
727 | 728 | activation_key=kFp8DynamicTokenSym, |
728 | 729 | allow_vllm_cutlass=True, |
|
0 commit comments