tensorflow/models · error · ValueError
`reuse_length` and `seq_length` should both be a multiple of
Error message
`reuse_length` and `seq_length` should both be a multiple of `permutation_size`.
What it means
Error "`reuse_length` and `seq_length` should both be a multiple of `permutation_size`." thrown in tensorflow/models.
Source
Thrown at official/nlp/data/pretrain_dataloader.py:252
boundary = tf.sparse.to_dense(record['boundary_indices'])
else:
boundary = None
input_mask = self._online_sample_mask(inputs=inputs, boundary=boundary) # pyrefly: ignore[bad-argument-type]
if self._reuse_length > 0:
if self._permutation_size > self._reuse_length:
logging.warning(
'`permutation_size` is greater than `reuse_length` (%d > %d).'
'This may introduce data leakage.', self._permutation_size,
self._reuse_length)
# Enable the memory mechanism.
# Permute the reuse and non-reuse segments separately.
non_reuse_len = self._seq_length - self._reuse_length
if not (self._reuse_length % self._permutation_size == 0 and
non_reuse_len % self._permutation_size == 0):
raise ValueError('`reuse_length` and `seq_length` should both be '
'a multiple of `permutation_size`.')
# Creates permutation mask and target mask for the first reuse_len tokens.
# The tokens in this part are reused from the last sequence.
perm_mask_0, target_mask_0, tokens_0, masked_0 = self._get_factorization(
inputs=inputs[:self._reuse_length],
input_mask=input_mask[:self._reuse_length])
# Creates permutation mask and target mask for the rest of tokens in
# current example, which are concatenation of two new segments.
perm_mask_1, target_mask_1, tokens_1, masked_1 = self._get_factorization(
inputs[self._reuse_length:], input_mask[self._reuse_length:])
perm_mask_0 = tf.concat([
perm_mask_0,
tf.zeros([self._reuse_length, non_reuse_len], dtype=tf.int32)
],
axis=1)View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/nlp/data/pretrain_dataloader.py:252 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/6c6fce00436d1ead.
Report an issue: GitHub.