> Documentation Index
> Fetch the complete documentation index at: https://docs.mobilint.com/compiler/kr/v0.12.0.0/llms.txt
> Use this file to discover all available pages before exploring further.
> Append index.md to any page URL for its Markdown.
> All Mobilint manuals: https://docs.mobilint.com/llms.txt

# qubee.configs.mod\_config

## ModConfig

```python
class ModConfig(ConfigABC)
```

Configuration for Minimum Output Difference algorithm.

Defines parameters controlling whether and how Mod is applied during quantization, including layer-level inclusion/exclusion lists.

### Attributes

| Name | Description |
| --- | --- |
| [`optional`](<#modconfig-optional>) |  |
| [`DEFAULTS`](<#modconfig-defaults>) |  |
| [`py_to_cpp_name`](<#modconfig-py-to-cpp-name>) |  |
| [`min_max_check`](<#modconfig-min-max-check>) |  |

#### optional

```python
optional = True
```

#### DEFAULTS

```python
DEFAULTS = {
    "apply": False,
    "epochs": 4,
    "warmup_epochs": 1,
    "lr_act_scale": 0.0,
    "lr_zeropoint": 0.0,
    "lr_weight_scale": 0.0,
    "lr_weight": 4e-6,
    "lr_bias": 4e-6,
    "lr_min_ratio": 1e-4,
    "batch_size": 1,
    "q_drop": 0.0,
    "quantize_weight": True,
    "weight_scale_init": "MinMax",
    "downresol_mode": "STE",
    "post_processing": "",
    "box_conf_thres": 0,
    "box_iou_thres": 0,
    "loss_type": "MSE",
    "use_outputs": False,
    "kl_temperature": 1.0,
    "recon_prob": 1.0,
    "recon_coeff": 1.0,
    "lambda_0": 1.0,
    "lambda_1": 1.0,
    "lambda_2": 1.0,
    "anchors": [
        [[12, 16], [19, 36], [40, 28]],
        [[36, 75], [76, 55], [72, 146]],
        [[142, 110], [192, 243], [459, 401]],
    ],
    "use_xyxy": False,
    "save_dir": "",
    "seed": 0,
    "apply_layers": [],
    "exclude_layers": [],
}
```

#### py\_to\_cpp\_name

```python
py_to_cpp_name = {
    "apply": "apply",
    "epochs": "epochs",
    "warmup_epochs": "warmupEpochs",
    "lr_min_ratio": "lrMinRatio",
    "lr_act_scale": "actScaleLR",
    "lr_zeropoint": "zeropointLR",
    "lr_weight_scale": "weightScaleLR",
    "lr_weight": "weightLR",
    "lr_bias": "biasLR",
    "batch_size": "batchSize",
    "q_drop": "qDrop",
    "quantize_weight": "quantizeWeight",
    "weight_scale_init": "weightScaleInit",
    "downresol_mode": "downresolMode",
    "post_processing": "post",
    "box_conf_thres": "boxConfThres",
    "box_iou_thres": "boxIoUThres",
    "loss_type": "lossType",
    "use_outputs": "useOutputs",
    "kl_temperature": "KLTemperature",
    "recon_prob": "reconProb",
    "recon_coeff": "reconCoeff",
    "lambda_0": "lambda_0",
    "lambda_1": "lambda_1",
    "lambda_2": "lambda_2",
    "use_xyxy": "useXYXY",
    "save_dir": "saveDir",
    "seed": "seed",
}
```

#### min\_max\_check

```python
min_max_check = {
    "epochs": [0, None],
    "warmup_epochs": [0, None],
    "lr_min_ratio": [0, None],
    "lr_act_scale": [0, None],
    "lr_zeropoint": [0, None],
    "lr_weight_scale": [0, None],
    "lr_weight": [0, None],
    "lr_bias": [0, None],
    "batch_size": [0, None],
    "q_drop": [0, 1],
    "box_conf_thres": [0, None],
    "box_iou_thres": [0, None],
    "kl_temperature": [0, None],
    "recon_prob": [0, 1],
    "recon_coeff": [0, None],
    "lambda_0": [0, None],
    "lambda_1": [0, None],
    "lambda_2": [0, None],
    "seed": [0, None],
}
```

### Methods

| Name | Description |
| --- | --- |
| [`__init__`](<#modconfig-init>) | Initialize the [ModConfig](<https://docs.mobilint.com/compiler/kr/v0.12.0.0/api/python/qubee.configs.mod_config/#modconfig>). |
| [`default_config`](<#modconfig-default-config>) |  |
| [`from_dict`](<#modconfig-from-dict>) | Create [ModConfig](<https://docs.mobilint.com/compiler/kr/v0.12.0.0/api/python/qubee.configs.mod_config/#modconfig>) from dictionary (JSON structure) |
| [`to_dict`](<#modconfig-to-dict>) |  |

#### \_\_init\_\_

```python
def __init__(
    self,
    apply: bool,
    epochs: int,
    warmup_epochs: int,
    lr_act_scale: numbers.Number,
    lr_zeropoint: numbers.Number,
    lr_weight_scale: numbers.Number,
    lr_weight: numbers.Number,
    lr_bias: numbers.Number,
    lr_min_ratio: numbers.Number,
    batch_size: int,
    q_drop: numbers.Number,
    quantize_weight: bool,
    weight_scale_init: str,
    downresol_mode: str,
    post_processing: str,
    box_conf_thres: numbers.Number,
    box_iou_thres: numbers.Number,
    loss_type: str,
    use_outputs: bool,
    kl_temperature: numbers.Number,
    recon_prob: numbers.Number,
    recon_coeff: numbers.Number,
    lambda_0: numbers.Number,
    lambda_1: numbers.Number,
    lambda_2: numbers.Number,
    anchors: List,
    use_xyxy: bool,
    save_dir: str,
    seed: int,
    apply_layers: List[str],
    exclude_layers: List[str],
    optional: bool = optional,
)
```

Initialize the [ModConfig](<https://docs.mobilint.com/compiler/kr/v0.12.0.0/api/python/qubee.configs.mod_config/#modconfig>).

**Parameters**

- `apply` — bool. Whether to apply MOD.
- `epochs` — int. Number of training epochs.
- `warmup_epochs` — int. Number of warmup epochs.
- `lr_act_scale` — float. Learning rate for activation scale.
- `lr_zeropoint` — float. Learning rate for zeropoint.
- `lr_weight_scale` — float. Learning rate for weight scale.
- `lr_weight` — float. Learning rate for weight.
- `lr_bias` — float. Learning rate for bias.
- `lr_min_ratio` — float. Minimum learning rate ratio for scheduler.
- `batch_size` — int. Batch size for training.
- `q_drop` — float. QDrop ratio.
- `quantize_weight` — bool. Quantize weight during training.
- `weight_scale_init` — str. Weight scale initialization method.
- `downresol_mode` — str. Down-resolution mode for fake quantization.
- `post_processing` — str. Post-processing function.
- `box_conf_thres` — float. Box confidence threshold for NMS.
- `box_iou_thres` — float. Box IoU threshold for NMS.
- `loss_type` — str. Loss function type.
- `use_outputs` — bool. Compare only intermediate layers.
- `kl_temperature` — float. Temperature for KL divergence loss.
- `recon_prob` — float. Sampling probability for intermediate layers.
- `recon_coeff` — float. Coefficient for intermediate layer loss.
- `lambda_0` — float. First coefficient for AnchorlessDetection loss.
- `lambda_1` — float. Second coefficient for AnchorlessDetection loss.
- `lambda_2` — float. Third coefficient for AnchorlessDetection loss.
- `anchors` — List. Anchor boxes configuration.
- `use_xyxy` — bool. Use XYXY format.
- `save_dir` — str. Directory to save results.
- `seed` — int. Random seed.
- `apply_layers` — List\[str\]. Layers to apply MOD.
- `exclude_layers` — List\[str\]. Layers to exclude from MOD.
- `optional` — bool. Indicates whether this config is optional. Use the default value defined as a class variable.

#### default\_config

```python
def default_config(cls)
```

#### from\_dict

```python
def from_dict(cls, config_dict: dict)
```

Create [ModConfig](<https://docs.mobilint.com/compiler/kr/v0.12.0.0/api/python/qubee.configs.mod_config/#modconfig>) from dictionary (JSON structure)

#### to\_dict

```python
def to_dict(self)
```

## Functions

| Name | Description |
| --- | --- |
| [`get_mod_config`](<#get-mod-config>) | Create [ModConfig](<https://docs.mobilint.com/compiler/kr/v0.12.0.0/api/python/qubee.configs.mod_config/#modconfig>) with partial parameters merged with defaults. |

### get\_mod\_config

```python
def get_mod_config(**kwargs) -> ModConfig
```

Create [ModConfig](<https://docs.mobilint.com/compiler/kr/v0.12.0.0/api/python/qubee.configs.mod_config/#modconfig>) with partial parameters merged with defaults.
