Quantization controls for a single attribute.
| 49 | |
| 50 | @dataclass |
| 51 | class AttributeQuantizerConfig: |
| 52 | """Quantization controls for a single attribute.""" |
| 53 | |
| 54 | enabled: bool = True |
| 55 | bitwidth: Optional[int] = None |
| 56 | clamp_range: Optional[Tuple[float, float]] = None |
| 57 | warmup_steps: Optional[int] = 10_000 |
| 58 | warmup_bitwidth: Optional[int] = 8 |
| 59 | mode: str = "noise" |
| 60 | |
| 61 | def to_dict(self) -> Dict[str, Any]: |
| 62 | return { |
| 63 | "enabled": self.enabled, |
| 64 | "bitwidth": self.bitwidth, |
| 65 | "clamp_range": list(self.clamp_range) if self.clamp_range is not None else None, |
| 66 | "warmup_steps": self.warmup_steps, |
| 67 | "warmup_bitwidth": self.warmup_bitwidth, |
| 68 | "mode": self.mode, |
| 69 | } |
| 70 | |
| 71 | |
| 72 | def _default_attribute_configs() -> Dict[str, AttributeQuantizerConfig]: |
no outgoing calls