Skip to content

fix(data): resize zero placeholder frames once in the action transform - #460

Open
jpohl-nv wants to merge 2 commits into
NVIDIA:mainfrom
jpohl-nv:fix/action-transform-resize-placeholder-frames
Open

jpohl-nv wants to merge 2 commits into
NVIDIA:mainfrom
jpohl-nv:fix/action-transform-resize-placeholder-frames

Conversation

@jpohl-nv

@jpohl-nv jpohl-nv commented Dec 4, 2026

Copy link
Copy Markdown

Summary

The RoboLab policy server builds a 33-frame uint8 clip per request: the camera image in frame 0 and 32 zero placeholder frames, which keep the prompt's duration and the number of latent frames. ActionTransformPipeline._prepare_video resizes and reflection-pads all 33 frames on the CPU, although 32 of them are identical zeros.

This PR adds a fast path to the single-view branch of _prepare_video. If the clip is [C,T,H,W] with T >= 3 and every frame after the first is zero, it resizes frame 0 and one zero frame and repeats the resized zero frame. Resize and reflection pad are per-frame, and the video tensor is the only output of video_resize that depends on T, so the result is identical to resizing all frames. Clips with a non-zero later frame, shorter clips and the multi-camera camera_videos path keep the existing code. The zero check costs about 0.1 ms per request.

Impact

Measured with nvidia/Cosmos3-Edge-Policy-DROID and the RoboLab server's settings on an RTX PRO 6000 Blackwell:

  • _build_sample: 27.1 → 10.4 ms per request, averaged over 301 recorded RoboLab requests.
  • Whole policy call, compiled bf16, BananaInBowlTask: 277.6 → 254.5 ms per call (mean of 2 interleaved runs each, same session).

Testing

  • New CPU tests in transforms_test.py (L0, CPU):
    • the fast path equals video_resize on all frames, for T = 3, 4 and 33, at a size that needs both resize and reflection padding, and the fast path is actually taken;
    • a clip with a non-zero later frame takes the full path and matches it;
    • 2-frame and 3-D inputs don't take the fast path.
  • A mutation check (repeating frame 0 instead of the zero frame) makes the equivalence tests fail.
  • transforms_test.py and action_policy_server_robolab_test.py pass.
  • On 301 recorded RoboLab requests across 5 tasks: _build_sample outputs are identical to the full path in every field, and the policy's actions are bit-identical to the unchanged server (uncompiled bf16, recorded seeds).
  • ruff format and pyrefly are clean on the changed files. ruff check reports two I001 import-order findings that are already on main.

Policy servers send a clip with one real frame and zero placeholder
frames; the RoboLab server sends 1 + 32. _prepare_video resized and
padded all of them on the CPU. Resize and reflection pad are per-frame,
so resizing frame 0 and one zero frame and repeating the latter gives
the same tensor. Other clips keep the full path.

Signed-off-by: John Pohl <jpohl@nvidia.com>
Signed-off-by: John Pohl <jpohl@nvidia.com>
@jpohl-nv
jpohl-nv marked this pull request as ready for review December 4, 2026 14:47

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant