bridge.diffusion.data.common.sequence_packing_utils#
Module Contents#
Functions#
Returns the bin-packing length of an item. |
API#
- bridge.diffusion.data.common.sequence_packing_utils.packing_length(item: Any) int#
Returns the bin-packing length of an item.
This is the only diffusion-specific piece of sequence packing: the bin-packing algorithms themselves live in
megatron.bridge.data.packing.algorithmsand are shared with LLM offline SFT packing. Diffusion packs liveDiffusionSampleobjects rather than integer lengths, so it computes each sample’s length with this adapter and passes the results asitem_lengthsto the shared packer.Items are either plain sequence lengths or objects that report their length by adding with an int –
DiffusionSampledoes this, returning its padded query sequence length when one is set and its unpadded length otherwise. Going through0 + itemkeeps this module free of a hard dependency on the sample type, and matches the length the previoussum(bin) + scapacity check used.- Parameters:
item – A sequence length, or an object implementing
__radd__against an int.- Returns:
The integer length used for bin-packing capacity accounting.