Skip to content

fix(gym): preserve cached video timing from JSONL metadata - #4309

Open
goelarushi wants to merge 1 commit into
super-v3.5-posttrainingfrom
fix/cached-video-jsonl-timing
Open

goelarushi wants to merge 1 commit into
super-v3.5-posttrainingfrom
fix/cached-video-jsonl-timing

Conversation

@goelarushi

Copy link
Copy Markdown

Cached video rows can include source _video_frame_index and _video_fps, but preprocessing overwrites them with sequential indices at 1 FPS. The outbound vLLM manifest also discards that timing, so timestamp text describes cache positions rather than the sampled video times.

Preserve JSONL timing in both policy preprocessing and the lossless cached-video manifest. For example, source indices [0, 6] at approximately 23.976 FPS now render timestamps 0.00 and 0.25 seconds instead of 0.00 and 1.00. Caches with no timing retain the legacy 1 FPS fallback; partial, invalid, inconsistent, or decreasing timing is rejected. Repeated indices remain supported. Since JSONL frames do not record the original duration or frame count, manifest duration/frame count are derived as lower bounds from the last sampled source index.

Regression coverage includes timing preservation in extraction and outbound manifests, legacy fallback, invalid metadata, and repeated frames.

Validation:

  • Validated timing metadata for all 35,547 cached-video rows in the local training dataset.
  • Ran isolated checks of the changed functions against a real 64-frame JSONL entry, verifying policy/rollout timing parity, manifest serialization, and timestamp rendering; checked legacy fallback and 11 invalid timing cases.
  • All four changed Python files compile; git diff --check passes.
  • Full pytest execution is blocked in this environment because pytest/PyTorch are unavailable. No end-to-end training run was performed.

This PR contains code and regression tests only; datasets and unrelated launcher/configuration changes are excluded.

@goelarushi
goelarushi requested review from a team as code owners September 28, 2026 21:08
@copy-pr-bot

copy-pr-bot Bot commented Sep 28, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@pyf98

pyf98 commented Oct 1, 2026 •

Copy link
Copy Markdown

Hi @goelarushi , thanks for sharing this fix.

Correction: The problem described below is not from this PR, but exists in other places (Both NeMo-RL and vLLM truncate the frame duration before multiplication). I'm just sharing the finding.

Codex suggests there is a precision problem that will cause cumulative timestamp drift.

Timestamp rendering truncates each source frame’s duration to integer milliseconds before multiplying by the source frame index:

frame_duration_ms = int(1000.0 / fps)
timestamp = frame_index * frame_duration_ms / 1000.0

The discarded fraction accumulates across source frames, causing timestamps to underestimate elapsed time:

FPS Source frame index Correct timestamp Current timestamp Error
30 3,000 100.00 s 99.00 s 1.00 s early
60 6,000 100.00 s 96.00 s 4.00 s early
~23.976 3,832 159.83 s 157.11 s 2.71 s early

The last row comes from our actual caption dataset. The images remain correct, but inaccurate timestamp text could affect temporal localization or duration reasoning.

This issue occurs regardless of the sampling FPS (e.g., 1 or 2) or sampled frame count (e.g., 64), because timestamps use original source-frame indices and the video’s native FPS, so truncation error accumulates over source frames rather than sampled frames.

@terrykong terrykong added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Nov 5, 2026

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

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants