{"record":{"id":"2c83e29329a2f4bd","repo":"tensorflow/models","slug":"window-decay-should-be-in-0-0-1-0-and-not-none","errorCode":null,"errorMessage":"window_decay should be in (0.0, 1.0) and not None.","messagePattern":"window_decay should be in \\(0\\.0, 1\\.0\\) and not None\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/modeling/layers/kernel_attention.py","lineNumber":262,"sourceCode":"      k_winsum = weighted_window_sum(k_sum, window_length, decaying_weights)\n\n    numerator = tf.einsum(\n        \"BTCHD,BTHDO->BTCHO\", chunked_query_matrix, kp_v_winsum)\n\n    k_winsum = tf.squeeze(k_winsum, -3)\n    denominator = tf.einsum(\"BTCHD,BTHD->BTCH\", chunked_query_matrix, k_winsum)\n    denominator = tf.expand_dims(denominator, -1) + _NUMERIC_STABLER\n    attention = numerator / denominator\n    attention = tf.reshape(attention, new_shape)\n\n    start = tf.zeros([old_shape.shape[0]], dtype=old_shape.dtype)\n    attention = tf.slice(attention, start, old_shape)\n\n  # Queued window cache (drop instead of decay) not yet supported.\n  else:  # Streaming\n\n    if window_decay is None or window_decay > 1.0 or window_decay < 0.0:\n      raise ValueError(\"window_decay should be in (0.0, 1.0) and not None.\")\n    kv = window_decay * cache[\"kv\"] + tf.einsum(\n        \"BTHD,BTHO->BHOD\", key_matrix, value_matrix)\n    cache[\"kv\"] = kv\n    k_sum = window_decay * cache[\"k_sum\"] + tf.reduce_sum(key_matrix, axis=1)\n    cache[\"k_sum\"] = k_sum\n    denominator = tf.einsum(\"BTHD,BHD->BTH\", query_matrix, k_sum)\n    # The below is equivalent to but converts to TF Lite better than:\n    #   tf.einsum(\"BTHD,BTH->BTHD\",\n    #             query_matrix, 1.0 / (denominator + _NUMERIC_STABLER))\n    inverse_denominator = 1.0 / (denominator + _NUMERIC_STABLER)\n    # Add another dimension to align for the broadcast multiplication.\n    fused_query_denominator = query_matrix * tf.expand_dims(inverse_denominator,\n                                                            -1)\n    attention = tf.einsum(\"BTHD,BHOD->BTHO\", fused_query_denominator, kv)\n  return attention\n\n\ndef create_projection_matrix(m, d, seed=None):","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/modeling/layers/kernel_attention.py#L244-L280","documentation":"Error \"window_decay should be in (0.0, 1.0) and not None.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/modeling/layers/kernel_attention.py:262 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"}