xai-org/x-algorithm · error · ValueError

Unused KV pairs: {k}

Error message

Unused KV pairs: {k}

What it means

replace_and_validate_cli_subs applies CLI overrides and then verifies every provided key actually matched a path in the config. Keys that matched zero paths raise this 'Unused KV pairs' ValueError; keys matching multiple paths only log a warning.

Source

Thrown at phoenix/xrex/configs/config_loader.py:60

def get_config_module(mod_name: str) -> dict[str, Config]:
    try:
        return importlib.import_module(f"xrex.configs.{mod_name}")
    except ImportError as e:
        raise ValueError(
            f"No config module found {mod_name!r} under 'xrex.configs', "
            f"or {mod_name!r} has another import issue: {traceback.format_exc()}"
        ) from e


def replace_cli_subs(config: Any, kvs: list[str]) -> tuple[Any, dict[str, list[str]]]:
    return xai_configlib.replace_cli_subs(config, kvs, PRESETS)


def replace_and_validate_cli_subs(config: Any, kvs: list[str]) -> Any:
    config, used = xai_configlib.replace_cli_subs(config, kvs, PRESETS)
    for k, v in used.items():
        if not v:
            raise ValueError(f"Unused KV pairs: {k}")
        elif len(v) > 1:
            logger.warning(f"{k} matches multiple paths: {v}")
    return config


_DEFAULT_AOT_CACHE_DIR = "/tmp/jax_aot_cache/"


def _apply_deployment_defaults(config: Config) -> Config:
    if settings.AOT_CACHE_DIR and getattr(config, "aot_cache_dir", None) == (
        _DEFAULT_AOT_CACHE_DIR
    ):
        config.aot_cache_dir = settings.AOT_CACHE_DIR
    return config


def get_named_config(name: str) -> Config:
    if ":" in name:

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Use the fully dotted path matching the config structure ('optimizer.lr=1e-4')
  2. Fix typos in the key
  3. After schema changes, update launch scripts' override lists

Example fix

# before
replace_and_validate_cli_subs(cfg, ["lr=1e-4"])  # field is cfg.optimizer.lr
# after
replace_and_validate_cli_subs(cfg, ["optimizer.lr=1e-4"])
Defensive patterns

Strategy: validation

Validate before calling

# dry-run: check each key matches at least one path
import dataclasses

def paths(obj, prefix=""):
    for f in dataclasses.fields(obj):
        p = f"{prefix}.{f.name}" if prefix else f.name
        v = getattr(obj, f.name)
        yield p
        if dataclasses.is_dataclass(v) and not isinstance(v, type):
            yield from paths(v, p)

all_paths = set(paths(config))
unused = [kv for kv in kvs if kv.split("=",1)[0] not in all_paths]
assert not unused, f"Unused overrides: {unused}"

Prevention

When it happens

Trigger: Passing 'lr=1e-4' when the config has no field whose path matches 'lr' (e.g. it's nested as optimizer.lr), or a typo'd key.

Common situations: Config schema refactors renaming fields, overrides written for a different config class, or wrong nesting level in the dotted key.

Related errors


AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28). Data as JSON: /api/errors/193af0218c60a527. Report an issue: GitHub.