{"record":{"id":"38811b9e894e89d9","repo":"tensorflow/models","slug":"cache-is-not-supported-when-begin-kernel-is-set-si","errorCode":null,"errorMessage":"Cache is not supported when begin_kernel is set since the bahvior is too complicated.","messagePattern":"Cache is not supported when begin_kernel is set since the bahvior is too complicated\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/modeling/layers/kernel_attention.py","lineNumber":775,"sourceCode":"        to masked positions. Note that the mask is only appied to the keys. User\n        may want to mask the output if query contains pads.\n      cache: Cache to accumulate history in memory. Used at inferecne time\n        (streaming, decoding) for  causal attention.\n      training: Python boolean indicating whether the layer should behave in\n        training mode (adding dropout) or in inference mode (doing nothing).\n\n    Returns:\n      Multi-headed outputs of attention computation.\n    \"\"\"\n    if cache is not None:\n      if training:\n        raise ValueError(\n            \"Cache is not supported when training is True.\")\n      if not self.use_causal_windowed:\n        raise ValueError(\n            \"Cache is not supported for non use_causal_windowed case.\")\n      if self._begin_kernel:\n        raise ValueError(\n            \"Cache is not supported when begin_kernel is set since the bahvior \"\n            \"is too complicated.\")\n      if self._feature_transform in _NON_CAUSAL_SUPPORT_TRANSFORM_MAP:\n        raise ValueError(\"Cache is not supported for feature_transform %s\" %\n                         (self._feature_transform))\n\n    if not self._built_from_signature:\n      self._build_from_signature(query=query, value=value, key=key)\n    if key is None:\n      key = value\n\n    #   N = `num_attention_heads`\n    #   H = `size_per_head`\n    # `query` = [B, T, N ,H]\n    query = self._query_dense(query)\n\n    # `key` = [B, S, N, H]\n    key = self._key_dense(key)","sourceCodeStart":757,"sourceCodeEnd":793,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/modeling/layers/kernel_attention.py#L757-L793","documentation":"Error \"Cache is not supported when begin_kernel is set since the bahvior is too complicated.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/modeling/layers/kernel_attention.py:775 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}