{"record":{"id":"4f1526b5f51208f0","repo":"tensorflow/models","slug":"there-is-nothing-to-redraw-when-num-random-feature","errorCode":null,"errorMessage":"There is nothing to redraw when num_random_features <= 0.","messagePattern":"There is nothing to redraw when num_random_features <= 0\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/modeling/layers/kernel_attention.py","lineNumber":605,"sourceCode":"        causal_windowed_performer_attention function docstring for more details.\n      causal_chunk_length: Length of each chunk in tokens.\n      causal_window_length: Length of attention window in chunks.\n      causal_window_decay: Float window decay factor or `None`. If set,\n        exponentially decay past attention window values by this factor before\n        summation.\n      causal_padding: Pad the query, value and key input tensors across the axis\n        from either left or right if padding is set to \"left\" or \"right\"; apply\n        no padding if padding is set to None. In the latter case, the axis\n        dimension of the query, value and key input tensors must be divisible by\n        the chunk_length.\n      **kwargs: The same arguments `MultiHeadAttention` layer.\n    \"\"\"\n    if feature_transform not in _TRANSFORM_MAP:\n      raise ValueError(\"Unsupported feature_transform. The supported \"\n                       \"feature_transform are %s. \"\n                       \"Got '%s'.\" % (_TRANSFORM_MAP.keys(), feature_transform))\n    if num_random_features <= 0 and redraw:\n      raise ValueError(\n          \"There is nothing to redraw when num_random_features <= 0.\")\n    self._feature_transform = feature_transform\n    self._num_random_features = num_random_features\n    self._redraw = redraw\n    self._is_short_seq = is_short_seq\n    self._begin_kernel = begin_kernel\n    self._scale_by_length = scale_by_length\n    # We use the seed for two scenarios:\n    # 1. inference\n    # 2. no redraw\n    self._seed = seed\n    super().__init__(**kwargs)\n    if scale is None:\n      self._scale = 1.0 / math.sqrt(float(self._key_dim))\n    else:\n      self._scale = scale\n    self._projection_matrix = None\n    if num_random_features > 0:","sourceCodeStart":587,"sourceCodeEnd":623,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/modeling/layers/kernel_attention.py#L587-L623","documentation":"Error \"There is nothing to redraw when num_random_features <= 0.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/modeling/layers/kernel_attention.py:605 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"}