nemo_automodel.components.datasets.vlm.pp_media
nemo_automodel.components.datasets.vlm.pp_media
Module Contents
Functions
Data
API
Return whether the next schedule step will probe stage 0 with a real forward.
Both the legacy _configure_outputs_meta API and the newer populated
_user_meta API provide analytical stage metadata, so neither needs a
forward probe. An unpopulated _user_meta still uses dynamic inference.
Chunk image tensors with per-sample patch counts for PP microbatches.
Step3 processors emit one full image per sample in pixel_values and a
flat list of optional crop patches in patch_pixel_values. num_patches
maps samples to the flat patch tensor. Processors may also emit
pixel_values itself as a flat patch tensor using the same mapping.
Parameters:
Either [batch, ...] (one image tensor per sample) or a
row-flattened [total_patches, ...] tensor whose patches are
concatenated along axis 0 in sample order, where
total_patches == sum(num_patches).
Number of samples in the batch.
Number of PP microbatches to split the batch into.
Tensor of shape [batch]; entry i is the patch count
for sample i. Defaults to all-zeros when the processor emits no
crop patches.
Optional row-flattened crop patches of shape
[total_patches, ...] indexed by num_patches.
Optional tensor of shape [total_patches] marking
patch-row newline positions, indexed by num_patches.
Returns: dict[str, list[torch.Tensor]]
dict[str, list[torch.Tensor]]: Per-microbatch slices keyed by
Split VLM pixel values and media metadata into PP microbatch chunks.
Explicit image counts take precedence over a coincidental equality between the number of images and documents. Text-only documents own empty chunks.
Parameters:
Image-major pixels [images, channels, height, width], padded patches [images, max_patches, features], flat patches [total_patches, features] or [total_patches, channels, patch_height, patch_width], or a list of [channels, height, width] tensors with possibly different image sizes.
Per-image metadata [images, coordinates]. For flat patches, the product of each grid gives the corresponding patch count.
Number of batch documents owning the media.
Number of document-axis chunks used by the PP schedule.
Optional image counts [batch]. Without counts, exactly one image per document is assumed.
Returns: list[torch.Tensor | list[torch.Tensor]]
Pixel and metadata lists in microbatch order, retaining each input’s
Move VLM media tensors into pre-chunked PP media storage on the batch.
This is intended to run from VLM collate/dataloader code when PP is enabled.
The returned batch no longer carries raw media tensors that PyTorch PP would
chunk by row incorrectly; instead it carries VLM_PP_MEDIA_KEY with
per-microbatch media chunks.
Attach dataloader-prepared VLM media chunks to PP stage 0 for one schedule call.
Wrap a VLM collate function so it prepares media tensors for PP.