{"record":{"id":"6c6fce00436d1ead","repo":"tensorflow/models","slug":"reuse-length-and-seq-length-should-both-be-a-m","errorCode":null,"errorMessage":"`reuse_length` and `seq_length` should both be a multiple of `permutation_size`.","messagePattern":"`reuse_length` and `seq_length` should both be a multiple of `permutation_size`\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/data/pretrain_dataloader.py","lineNumber":252,"sourceCode":"      boundary = tf.sparse.to_dense(record['boundary_indices'])\n    else:\n      boundary = None\n\n    input_mask = self._online_sample_mask(inputs=inputs, boundary=boundary)  # pyrefly: ignore[bad-argument-type]\n\n    if self._reuse_length > 0:\n      if self._permutation_size > self._reuse_length:\n        logging.warning(\n            '`permutation_size` is greater than `reuse_length` (%d > %d).'\n            'This may introduce data leakage.', self._permutation_size,\n            self._reuse_length)\n\n      # Enable the memory mechanism.\n      # Permute the reuse and non-reuse segments separately.\n      non_reuse_len = self._seq_length - self._reuse_length\n      if not (self._reuse_length % self._permutation_size == 0 and\n              non_reuse_len % self._permutation_size == 0):\n        raise ValueError('`reuse_length` and `seq_length` should both be '\n                         'a multiple of `permutation_size`.')\n\n      # Creates permutation mask and target mask for the first reuse_len tokens.\n      # The tokens in this part are reused from the last sequence.\n      perm_mask_0, target_mask_0, tokens_0, masked_0 = self._get_factorization(\n          inputs=inputs[:self._reuse_length],\n          input_mask=input_mask[:self._reuse_length])\n\n      # Creates permutation mask and target mask for the rest of tokens in\n      # current example, which are concatenation of two new segments.\n      perm_mask_1, target_mask_1, tokens_1, masked_1 = self._get_factorization(\n          inputs[self._reuse_length:], input_mask[self._reuse_length:])\n\n      perm_mask_0 = tf.concat([\n          perm_mask_0,\n          tf.zeros([self._reuse_length, non_reuse_len], dtype=tf.int32)\n      ],\n                              axis=1)","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/data/pretrain_dataloader.py#L234-L270","documentation":"Error \"`reuse_length` and `seq_length` should both be a multiple of `permutation_size`.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/data/pretrain_dataloader.py:252 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"}