nemo_rl.environments.nemotron_utils#

Module Contents#

Functions#

_required_config_value

load_nemotron_video_model_config

_nemotron_video_target_resolution

Return the SFT/vLLM-compatible (width, height) for a video frame.

_resize_and_normalize_nemotron_video_frame

Resize one frame with the same numeric order as stock vLLM.

_flatten_nemotron_video_frame_messages

Replace locally decoded frame items with ordered <image> markers.

_render_nemotron_video_prompt

_expand_nemotron_video_placeholders

Match vLLM’s timestamped one-wrapper-per-tubelet video replacement.

process_nemotron_video_frames

Port the source branch’s dynamic video-frame preprocessing contract.

Data#

API#

nemo_rl.environments.nemotron_utils.NEMOTRON_VIDEO_PROCESSOR_NAMES#

‘frozenset(…)’

nemo_rl.environments.nemotron_utils._required_config_value(config: Any, name: str) Any#
nemo_rl.environments.nemotron_utils.load_nemotron_video_model_config(model_name: str) Any#
nemo_rl.environments.nemotron_utils._nemotron_video_target_resolution(
*,
original_width: int,
original_height: int,
target_num_patches: int,
patch_size: int,
downsample_ratio: float,
maintain_aspect_ratio: bool,
) tuple[int, int]#

Return the SFT/vLLM-compatible (width, height) for a video frame.

nemo_rl.environments.nemotron_utils._resize_and_normalize_nemotron_video_frame(
frame: PIL.Image.Image,
*,
target_height: int,
target_width: int,
norm_mean: torch.Tensor,
norm_std: torch.Tensor,
) torch.Tensor#

Resize one frame with the same numeric order as stock vLLM.

nemo_rl.environments.nemotron_utils._flatten_nemotron_video_frame_messages(
messages: list[dict[str, Any]],
) tuple[list[dict[str, Any]], list[PIL.Image.Image], list[int], float]#

Replace locally decoded frame items with ordered <image> markers.

nemo_rl.environments.nemotron_utils._render_nemotron_video_prompt(
processor: Any,
messages: list[dict[str, Any]],
template_kwargs: dict[str, Any],
) str#
nemo_rl.environments.nemotron_utils._expand_nemotron_video_placeholders(
rendered_text: str,
*,
embeddings_per_tubelet: list[int],
frame_indices: list[int],
fps: float,
temporal_patch_size: int,
) str#

Match vLLM’s timestamped one-wrapper-per-tubelet video replacement.

nemo_rl.environments.nemotron_utils.process_nemotron_video_frames(
processor: Any,
messages: list[dict[str, Any]],
*,
template_kwargs: dict[str, Any],
temporal_patch_size: int,
target_num_patches: int,
maintain_aspect_ratio: bool,
) dict[str, torch.Tensor]#

Port the source branch’s dynamic video-frame preprocessing contract.