{"record":{"id":"6b4a8d3882937a76","repo":"facebookresearch/detectron2","slug":"conflicting-overrides-for-bias","errorCode":null,"errorMessage":"Conflicting overrides for 'bias'","messagePattern":"Conflicting overrides for 'bias'","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"detectron2/solver/build.py","lineNumber":198,"sourceCode":"    if overrides is None:\n        overrides = {}\n    defaults = {}\n    if base_lr is not None:\n        defaults[\"lr\"] = base_lr\n    if weight_decay is not None:\n        defaults[\"weight_decay\"] = weight_decay\n    bias_overrides = {}\n    if bias_lr_factor is not None and bias_lr_factor != 1.0:\n        # NOTE: unlike Detectron v1, we now by default make bias hyperparameters\n        # exactly the same as regular weights.\n        if base_lr is None:\n            raise ValueError(\"bias_lr_factor requires base_lr\")\n        bias_overrides[\"lr\"] = base_lr * bias_lr_factor\n    if weight_decay_bias is not None:\n        bias_overrides[\"weight_decay\"] = weight_decay_bias\n    if len(bias_overrides):\n        if \"bias\" in overrides:\n            raise ValueError(\"Conflicting overrides for 'bias'\")\n        overrides[\"bias\"] = bias_overrides\n    if lr_factor_func is not None:\n        if base_lr is None:\n            raise ValueError(\"lr_factor_func requires base_lr\")\n    norm_module_types = (\n        torch.nn.BatchNorm1d,\n        torch.nn.BatchNorm2d,\n        torch.nn.BatchNorm3d,\n        torch.nn.SyncBatchNorm,\n        # NaiveSyncBatchNorm inherits from BatchNorm2d\n        torch.nn.GroupNorm,\n        torch.nn.InstanceNorm1d,\n        torch.nn.InstanceNorm2d,\n        torch.nn.InstanceNorm3d,\n        torch.nn.LayerNorm,\n        torch.nn.LocalResponseNorm,\n    )\n    params: List[Dict[str, Any]] = []","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/facebookresearch/detectron2/blob/a2f4a8771ab77e8411c26b27f24f9489a28a2453/detectron2/solver/build.py#L180-L216","documentation":"get_default_optimizer_params already derives bias overrides from bias_lr_factor/weight_decay_bias; passing an explicit 'bias' entry in overrides conflicts with the computed one, so the function refuses to guess which wins.","triggerScenarios":"Calling build_optimizer with both an overrides dict containing key 'bias' and a non-default bias_lr_factor or weight_decay_bias.","commonSituations":"Custom build_optimizer that adds overrides={'bias': {...}} while bias_lr_factor/weight_decay_bias are still active from config.","solutions":["Remove the 'bias' key from overrides and let bias_lr_factor/weight_decay_bias control it","Or set bias_lr_factor=None and weight_decay_bias=None and keep the explicit overrides['bias']"],"exampleFix":"# before\nbuild_optimizer(cfg, model, overrides={'bias': {'lr': 0.02}}, bias_lr_factor=2.0)\n# after\nbuild_optimizer(cfg, model, overrides={'bias': {'lr': 0.02}}, bias_lr_factor=None)","handlingStrategy":"validation","validationCode":"if 'bias' in overrides:\n    assert bias_lr_factor in (None, 1.0) and weight_decay_bias is None, \"Conflicting overrides for 'bias'\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Choose one mechanism for bias hyperparameters","Document which path your custom optimizer uses"],"tags":["detectron2","optimizer","conflicting-config"],"backgroundTag":"conflicting-config-values","analyzedSha":"a2f4a8771ab77e8411c26b27f24f9489a28a2453","analyzedAt":"2026-08-27T12:08:21.260Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}