tensorflow/models · error · ValueError

Cache is not supported when begin_kernel is set since the ba

Error message

Cache is not supported when begin_kernel is set since the bahvior is too complicated.

What it means

Error "Cache is not supported when begin_kernel is set since the bahvior is too complicated." thrown in tensorflow/models.

Source

Thrown at official/nlp/modeling/layers/kernel_attention.py:775

        to masked positions. Note that the mask is only appied to the keys. User
        may want to mask the output if query contains pads.
      cache: Cache to accumulate history in memory. Used at inferecne time
        (streaming, decoding) for  causal attention.
      training: Python boolean indicating whether the layer should behave in
        training mode (adding dropout) or in inference mode (doing nothing).

    Returns:
      Multi-headed outputs of attention computation.
    """
    if cache is not None:
      if training:
        raise ValueError(
            "Cache is not supported when training is True.")
      if not self.use_causal_windowed:
        raise ValueError(
            "Cache is not supported for non use_causal_windowed case.")
      if self._begin_kernel:
        raise ValueError(
            "Cache is not supported when begin_kernel is set since the bahvior "
            "is too complicated.")
      if self._feature_transform in _NON_CAUSAL_SUPPORT_TRANSFORM_MAP:
        raise ValueError("Cache is not supported for feature_transform %s" %
                         (self._feature_transform))

    if not self._built_from_signature:
      self._build_from_signature(query=query, value=value, key=key)
    if key is None:
      key = value

    #   N = `num_attention_heads`
    #   H = `size_per_head`
    # `query` = [B, T, N ,H]
    query = self._query_dense(query)

    # `key` = [B, S, N, H]
    key = self._key_dense(key)

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/nlp/modeling/layers/kernel_attention.py:775 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/38811b9e894e89d9. Report an issue: GitHub.