tensorflow/models · error · KeyError

Found inconsistency between key

Error message

Found inconsistency between key `{}` and key `{}`.

What it means

Restriction check failure in ParamsDict.validate: a declared '==', '>=', or '>' relation between two config keys (or a key and a constant) does not hold for the current values, meaning the parameter combination is internally inconsistent.

Solutions

  1. Adjust the config values so the restriction relation holds
  2. Remove or correct the invalid restriction string
  3. Check dependencies like 'train_steps > warmup_steps' in your yaml
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at official/modeling/hyperparams/params_dict.py:294 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24). Data as JSON: /api/errors/49144d59c709c045. Report an issue: GitHub.

Appendix: source

Thrown at official/modeling/hyperparams/params_dict.py:294

        for t in tokenized_params:
          v = v[t]
        return tokenized_params[-1], v

    def _get_kvs(tokens, params_dict):
      if len(tokens) != 2:
        raise ValueError('Only support binary relation in restriction.')
      stripped_tokens = [t.strip() for t in tokens]
      left_k, left_v = _get_kv(stripped_tokens[0], params_dict)
      right_k, right_v = _get_kv(stripped_tokens[1], params_dict)
      return left_k, left_v, right_k, right_v

    params_dict = self.as_dict()
    for restriction in self._restrictions:
      if '==' in restriction:
        tokens = restriction.split('==')
        _, left_v, _, right_v = _get_kvs(tokens, params_dict)
        if left_v != right_v:
          raise KeyError(
              'Found inconsistency between key `{}` and key `{}`.'.format(
                  tokens[0], tokens[1]))
      elif '!=' in restriction:
        tokens = restriction.split('!=')
        _, left_v, _, right_v = _get_kvs(tokens, params_dict)
        if left_v == right_v:
          raise KeyError(
              'Found inconsistency between key `{}` and key `{}`.'.format(
                  tokens[0], tokens[1]))
      elif '<=' in restriction:
        tokens = restriction.split('<=')
        _, left_v, _, right_v = _get_kvs(tokens, params_dict)
        if left_v > right_v:
          raise KeyError(
              'Found inconsistency between key `{}` and key `{}`.'.format(
                  tokens[0], tokens[1]))
      elif '<' in restriction:
        tokens = restriction.split('<')

View on GitHub (pinned to e006f5f0d5)