pad_to_multiple¶
- jaxrens.utils.padding.pad_to_multiple(tree, axis_len, chunk)[source]¶
Pad a pytree’s leading axis up to the next multiple of
chunk.Each leaf’s last entry is repeated
n_padtimes along axis 0. Returns(tree, 0)unchanged when already divisible — no allocation, no copy. Works on plain arrays (treated as singleton pytrees) and on nested pytrees (e.g. MCState).The repeated leaf is a valid copy of the existing last entry, which is important when the padded slots will be run through code that cannot tolerate dummy zero-state (e.g. an energy backend on coincident atoms).