facebookresearch/detectron2 · error · NotImplementedError

deletion is not yet a supported override

Error message

deletion is not yet a supported override

What it means

apply_overrides parses Hydra-style overrides; when an override uses the deletion syntax key~value or ~key, detectron2 explicitly raises NotImplementedError because deletion support is a TODO.

Source

Thrown at detectron2/config/lazy.py:361

                    )
            OmegaConf.update(cfg, key, value, merge=True)

        try:
            from hydra.core.override_parser.overrides_parser import OverridesParser

            has_hydra = True
        except ImportError:
            has_hydra = False

        if has_hydra:
            parser = OverridesParser.create()
            overrides = parser.parse_overrides(overrides)
            for o in overrides:
                key = o.key_or_group
                value = o.value()
                if o.is_delete():
                    # TODO support this
                    raise NotImplementedError("deletion is not yet a supported override")
                safe_update(cfg, key, value)
        else:
            # Fallback. Does not support all the features and error checking like hydra.
            for o in overrides:
                key, value = o.split("=")
                try:
                    value = ast.literal_eval(value)
                except NameError:
                    pass
                safe_update(cfg, key, value)
        return cfg

    @staticmethod
    def to_py(cfg, prefix: str = "cfg."):
        """
        Try to convert a config object into Python-like psuedo code.

        Note that perfect conversion is not always possible. So the returned

View on GitHub (pinned to a2f4a8771a)

Solutions

  1. Instead of deleting, set the key to a null/None value the config logic already handles (e.g. model.aux_head=null)
  2. Modify the config object in Python: cfg.pop('aux_head') / OmegaConf.update with merge=False
  3. Edit the base config file to remove the key for this experiment

Example fix

# before
LazyConfig.apply_overrides(cfg, ["~model.aux_head"])
# after
LazyConfig.apply_overrides(cfg, ["model.aux_head=null"])  # downstream treats None as disabled
Defensive patterns

Strategy: validation

Validate before calling

for o in overrides:
    assert '~' not in o.split('=')[0], f"deletion not supported: {o}"

Type guard

def has_deletion_override(overrides) -> bool:
    return any(o.strip().startswith('~') or '~' in o.split('=')[0] for o in overrides)

Prevention

When it happens

Trigger: LazyConfig.apply_overrides(cfg, ['~model.aux_head']) or a CLI arg like 'train.dataset=~' using Hydra deletion syntax.

Common situations: Porting Hydra command lines that use ~ deletion; attempting to remove keys before instantiating; users assuming full Hydra grammar support.

Related errors


AI-assisted analysis of facebookresearch/detectron2@a2f4a8771a (2026-08-27). Data as JSON: /api/errors/184eac871a8a5b40. Report an issue: GitHub.