qbcompiler.configs.mod_config¶
ModConfig¶
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 |
|
DEFAULTS |
|
py_to_cpp_name |
|
min_max_check |
optional¶
DEFAULTS¶
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,
"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": [],
"custom_loss_jit_path": "",
"mod_after_layer_name": "",
}
py_to_cpp_name¶
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",
"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",
"custom_loss_jit_path": "customLossJITPath",
"mod_after_layer_name": "modAfterLayerName",
}
min_max_check¶
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__ |
Initialize the ModConfig. |
default_config |
|
from_dict |
Create ModConfig from dictionary (JSON structure) |
to_dict |
__init__¶
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,
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],
custom_loss_jit_path: str,
mod_after_layer_name: str,
optional: bool = optional,
)
Initialize the 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.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.custom_loss_jit_path— str. Path to custom loss JIT file.mod_after_layer_name— str. Layer name to apply MOD after.optional— bool. Indicates whether this config is optional. Use the default value defined as a class variable.
default_config¶
from_dict¶
Create ModConfig from dictionary (JSON structure)
to_dict¶
Functions¶
| Name | Description |
|---|---|
get_mod_config |
Create ModConfig with partial parameters merged with defaults. |
get_mod_config¶
Create ModConfig with partial parameters merged with defaults.