Configuration for adaptive mask stage.
| 152 | |
| 153 | @dataclass |
| 154 | class MaskConfig: |
| 155 | """Configuration for adaptive mask stage.""" |
| 156 | |
| 157 | enabled: bool = False |
| 158 | strategy: Optional[str] = "learnable" |
| 159 | start_step: int = 10_000 |
| 160 | regularization_weight: float = 1.0 |
| 161 | cap_max: Optional[int] = None |
| 162 | learnable: LearnableMaskSettings = field(default_factory=LearnableMaskSettings) |
| 163 | gradient: GradientMaskSettings = field(default_factory=GradientMaskSettings) |
| 164 | |
| 165 | def to_dict(self) -> Dict[str, Any]: |
| 166 | return { |
| 167 | "enabled": self.enabled, |
| 168 | "strategy": self.strategy, |
| 169 | "start_step": self.start_step, |
| 170 | "regularization_weight": self.regularization_weight, |
| 171 | "cap_max": self.cap_max, |
| 172 | "learnable": { |
| 173 | "start_temp": self.learnable.start_temp, |
| 174 | "end_temp": self.learnable.end_temp, |
| 175 | "total_iters": self.learnable.total_iters, |
| 176 | "target_sparsity": self.learnable.target_sparsity, |
| 177 | "lr": self.learnable.lr, |
| 178 | }, |
| 179 | "gradient": { |
| 180 | "grad_threshold": self.gradient.grad_threshold, |
| 181 | }, |
| 182 | } |
| 183 | |
| 184 | |
| 185 | @dataclass |
no outgoing calls