|
| 1 | +# Copyright 2025 Tencent Inc. All Rights Reserved. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +"""Configuration dataclasses shared by the vLLM (online) and convert |
| 16 | +(offline) smooth pipelines. |
| 17 | +
|
| 18 | +These are *pure data containers* — keep the module free of any heavy |
| 19 | +imports so it can be loaded from CLI scripts without pulling in torch |
| 20 | +distributed / vLLM machinery. |
| 21 | +""" |
| 22 | + |
| 23 | +from dataclasses import dataclass |
| 24 | + |
| 25 | +__all__ = [ |
| 26 | + "SmoothAlphaSearchConfig", |
| 27 | +] |
| 28 | + |
| 29 | + |
| 30 | +@dataclass |
| 31 | +class SmoothAlphaSearchConfig: |
| 32 | + """Configuration for smooth alpha grid search.""" |
| 33 | + |
| 34 | + alpha_min: float = 0.3 |
| 35 | + alpha_max: float = 1.0 |
| 36 | + alpha_steps: int = 8 # [0.3, 0.4, ..., 1.0] |
| 37 | + act_quant_method: str = "per_token" # "per_tensor" | "per_token" |
| 38 | + act_quant_type: str = "int8" # "int8" | "fp8" |
| 39 | + weight_quant_method: str = ( |
| 40 | + "per_channel" # "per_tensor" | "per_channel" | "per_group" | "per_block" |
| 41 | + ) |
| 42 | + weight_quant_type: str = "int8" # "int8" | "int4" | "fp8" |
| 43 | + weight_quant_bits: int = 8 |
| 44 | + weight_group_size: int = 128 # per_group, -1 = per_channel |
| 45 | + block_size: int = 128 # per_block fp8 |
| 46 | + use_ema_for_absmax: bool = False |
| 47 | + smooth_search_mode: str = "default" # "default" | "per-tensor-act-first" |
| 48 | + act_mul_min: float = 0.1 # per-tensor-act-first: multiplier range min |
| 49 | + act_mul_max: float = 1.0 # per-tensor-act-first: multiplier range max |
| 50 | + smooth_min: float = 1e-6 # per-tensor-act-first: smooth clamp lower bound |
| 51 | + smooth_max: float = 1e6 # per-tensor-act-first: smooth clamp upper bound |
0 commit comments