Skip to content

feat(videomae): add the masked video reconstruction family for VideoMAE base - #2674

Open
qikail-ctrl wants to merge 1 commit into
NVIDIA:mainfrom
qikail-ctrl:feat/videomae-family
Open

qikail-ctrl wants to merge 1 commit into
NVIDIA:mainfrom
qikail-ctrl:feat/videomae-family

Conversation

@qikail-ctrl

@qikail-ctrl qikail-ctrl commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Background

Closes #2673.

TensorRT-Model-Connect has no family for VideoMAE (MCG-NJU/videomae-base, VideoMAEForPreTraining), and no family implements the public masked_video_text_to_video Task yet. This PR adds the family videomae: given a 16-frame clip and a mask of whole 2 x 16 x 16 tubes, it returns the clip with the masked tubes reconstructed by the checkpoint's pixel decoder.

Exit Criteria

  • A bundle built from the pinned checkpoint serves masked_video_text_to_video through the C and C++ SDK.
  • The E2E matches transformers' VideoMAEForPreTraining (FP32) plus the authors' restoration within 1e-4 per pixel, and every conditioning tube keeps its source pixels.
  • Community CPU / Required and TRTMC Internal CI / Automated premerge gate pass on the head.

Boundaries: the pre-training head only; clips at the checkpoint's own size (16 frames of 224 x 224, no resampling); masks of whole tubes; FP32; batch 1; no new CLI command; no performance qualification.

Implementation

  • Builder (model.py, graph.py, config.py): one FP32 engine, TF32 off, with the tubelet embedding, the encoder on the visible tubes and the decoder on the visible tubes plus mask tokens, as in transformers; configurations, processors and checkpoint tensors it does not reproduce are refused.
  • Runtime (runtime/): IModel + IMaskedVideoTextToVideo, with strict checks of the request, and of runtime.json and the engine's I/O and profile at load; masked tubes are restored with their source mean and standard deviation (the checkpoint predicts tube-normalized pixels) and clamped to [0, 1].
  • Tests: configuration, request and E2E-selection checks; a C++ test of the tube math and bundle checks; engine-logit parity on small random checkpoints; C and C++ SDK consumers with four refused requests; the E2E with an evidence report.
  • Third-party sources are listed in families/videomae/NOTICE, the copied test photograph in ASSET_LICENSES.md.

Change categories

  • Model or runtime behavior
  • Public API
  • ABI
  • Bundle or artifact format
  • Dependencies
  • Documentation only
  • CI or developer tooling

Validation

Head f75d6b13 on main at 606c0ecc; 1x NVIDIA B300, CUDA 13.4, TensorRT 11.4, FP32.

Commands and Results

  • python3 -m tools.community_ci source-quality and impact, python3 -m tools.model_ci validate, python3 tools/test_impact.py --validate, git diff --check, pre-commit: pass.
  • python3 -m tools.community_ci unit: Python 2110 passed, 2 skipped; C++ 392/392 passed.
  • cd website && npm ci && npm run test:model-support && npm run build: model-support tests 15/15 passed, build succeeded.
  • ctest -R '^videomae_': 3/3 passed.
  • pytest families/videomae/tests/test_model.py families/videomae/tests/test_support.py -m "not gpu and not trt": 71 passed.
  • pytest families/videomae/tests/test_model.py -m "gpu or trt": 2 passed (engine logits within 1e-4 of transformers).
  • pytest families/videomae/tests/test_e2e.py --e2e-testcase videomae-base-box-mask,videomae-base-tube-mask, offline: 2 passed; largest pixel error 6.6e-6 and 2.1e-5 (bound 1e-4; single defects injected into the reference move pixels by 8.9e-4 or more); evidence report: 2/2 "Reference checks passed".

Hardware, Environment, and Revisions

  • 1x NVIDIA B300 (x86_64) in nvcr.io/nvidia/pytorch:26.10-py3, the CPU gates in the community CPU image, both with transformers==5.2.0; checkpoint MCG-NJU/videomae-base at revision dc740ceda42fce44faed2ea03c6d447db72f6af9 (CC BY-NC 4.0, not gated).

Not Run / Remaining Gaps

  • aarch64 and GB300 hosts, the wheel-packaged runtime, other VideoMAE checkpoints and performance were not exercised.

Contributor Self-Review

  • I have completed a self-review of this change.

Notes For Future Readers

The weights (CC BY-NC 4.0, like facebook/musicgen-medium in #2436) are not stored in the repository; the E2E reads the pinned revision from the Hugging Face cache. Masked tubes take their brightness and contrast from the source because the checkpoint predicts tube-normalized pixels; as the first implementation of masked_video_text_to_video, please confirm this Task is the right home for it.

Risk level

  • Low
  • Medium
  • High

Risk rationale: one new family directory and one asset-license line; no shared code, header, ABI or dependency changes.

Add the videomae family for MCG-NJU/videomae-base (VideoMAEForPreTraining)
on the masked_video_text_to_video Task, the first family bound to it.

- Builder: one float32 engine (TF32 off) with the Conv3d tubelet
  embedding, the encoder on the visible tubes only, and the decoder on the
  visible tubes followed by one mask token per masked tube, as in
  transformers. Dimensions come from config.json; the name, dtype and
  shape of every checkpoint tensor are checked against them from the
  safetensors header before the weights are read. Flags that change the
  computation, values that do not hold in float32 and processors that
  would resize or crop a clip of the model's size are refused.
- Runtime: IModel and IMaskedVideoTextToVideo. It checks runtime.json and
  the engine's inputs, outputs and profile at load, and the request (the
  model's frame count and frame size, 8-bit or float32 RGB, masks of whole
  tubes, an empty prompt, no Config). It normalizes like the checkpoint's
  processor and restores each masked tube with the tube's source mean and
  standard deviation (the checkpoint predicts tube-normalized pixels),
  clamped to [0, 1]. Conditioning tubes keep their source pixels; the
  source timeline is returned.
- Tests: configuration, request and checkpoint checks, the sinusoid table,
  a C++ test of the tube layout, the reconstruction and the bundle checks,
  GPU parity of the engine logits with transformers on small random
  checkpoints, C and C++ SDK consumers, and the E2E against the reference
  reconstruction with a tube mask and a box mask. An E2E selection that
  names the family but matches none of its cases fails.
- NOTICE for the transformers code it follows, installed with the
  library, and the copied test photograph in ASSET_LICENSES.md.

Signed-off-by: Qikai Li <qikail@nvidia.com>
@qikail-ctrl qikail-ctrl self-assigned this Nov 25, 2026
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary

This PR adds the videomae family. It supports VideoMAEForPreTraining (MCG-NJU/videomae-base, pinned revision, FP32, batch 1, 16 frames at 224×224). It implements masked_video_text_to_video in the C and C++ SDK. The runtime requires an empty prompt and no runtime Config. It validates the request and the engine I/O and profile. It restores masked tubes with source mean and standard deviation, then clamps to [0, 1]. Conditioning tubes keep their source pixels. ASSET_LICENSES.md records the test image.

Architecture impact

Family-owned files: 23 added files under families/videomae/. They cover the build, config, graph, runtime, support declaration, manifest, C and C++ consumers, test data, and tests.

Changed shared surfaces: One modified file, ASSET_LICENSES.md. It adds a licensing entry for the test image. It has no code effect.

New dependency directions: None found in the diff summaries. The family does not import other family code or artifacts. The E2E test reads the Hugging Face checkpoint from a cache. That cache is external to the repository and is not another family's artifact.

Affected consumers: The family's SDK consumers and E2E tests. No shared CLI, registry, or other family changed. The issue states that the shared CLI has no command for this task.

Unresolved blast-radius question: The diff does not show how the SDK discovers the family. The trtmc_create_family entry point suggests plugin-based loading. The support declaration and the loader would need to route the task without a shared edit. The file list alone cannot confirm this. Trace the loader and support discovery.

Verdict: HUMAN REVIEW REQUIRED. The reviewed evidence shows no standards or spec violation. The loader routing question above is unresolved.

This change adds VideoMAE pretraining support for masked_video_text_to_video. It builds a TensorRT engine from validated checkpoint data, adds a native runtime that reconstructs masked video tubes, and provides C and C++ SDK consumers with model and end-to-end tests.

Changes: VideoMAE masked-video reconstruction

Layer / File(s) Summary
Checkpoint configuration and TensorRT engine
families/videomae/config.py, families/videomae/graph.py, families/videomae/model.py, families/videomae/support.py, families/videomae/tests/test_model.py, families/videomae/tests/test_support.py, families/videomae/README.md, families/videomae/NOTICE, families/videomae/__init__.py
Adds VideoMAE checkpoint and processor validation, TensorRT graph operations, and engine construction for visible and masked tubes. Registers VideoMAEForPreTraining for the masked_video_text_to_video task. Tests cover configuration, checkpoint tensors, and engine output parity.
Runtime configuration and clip processing
families/videomae/runtime/bundle_config.h, families/videomae/runtime/bundle_config.cpp, families/videomae/runtime/clip.h, families/videomae/runtime/clip.cpp, families/videomae/tests/cpp/test_clip.cpp, families/videomae/runtime/CMakeLists.txt
Adds runtime configuration and engine validation, clip conversion and normalization, tube-mask selection, and masked-tube reconstruction. Host-side tests cover the runtime contracts and invalid inputs.
Runtime pipeline and family factory
families/videomae/runtime/pipeline.h, families/videomae/runtime/pipeline.cpp, families/videomae/runtime/plugin.cpp, families/videomae/runtime/CMakeLists.txt
Adds the runtime model and bundle factory. The pipeline submits normalized pixels and visible and masked tube indices to the engine, then returns reconstructed frames.
SDK consumers and end-to-end validation
families/videomae/tests/manifests/videomae-base.json, families/videomae/tests/sdk_consumer.c, families/videomae/tests/sdk_consumer.cpp, families/videomae/tests/test_e2e.py, ASSET_LICENSES.md, families/videomae/runtime/CMakeLists.txt
Adds C and C++ SDK consumers and manifest-selected end-to-end cases. Tests check request rejection, output properties, preservation of visible pixels, and agreement with a Transformers reference.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant SDKConsumer
  participant VideoMAEFactory
  participant MaskedVideoReconstruction
  participant TensorRTEngine
  SDKConsumer->>VideoMAEFactory: Load bundle sections
  VideoMAEFactory->>TensorRTEngine: Create backend module
  VideoMAEFactory-->>SDKConsumer: Return task
  SDKConsumer->>MaskedVideoReconstruction: Run masked-video request
  MaskedVideoReconstruction->>TensorRTEngine: Submit pixels and tube indices
  TensorRTEngine-->>MaskedVideoReconstruction: Return logits
  MaskedVideoReconstruction-->>SDKConsumer: Return reconstructed video
Loading
Merge Risk: Minimal · up to f75d6 · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Security architecture risk: Minimal · up to f75d6

The change adds a new way to reconstruct masked video without letting ordinary requests choose what gets loaded. The reviewed path validates inputs and keeps each request’s results separate. No material regression was established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The checked inference path reaches the engine already loaded for the selected model. Clip and mask values control tensors and the reconstruction region; they do not select a checkpoint, bundle, or native module.

Trust Boundaries and Controls

  • observed — The project places responsibility for artifact trust on the caller. The family passes plan bytes to the backend before checking the loaded engine’s interface, so those structural checks are compatibility controls, not provenance checks or protection against untrusted deserialization.

Resilience and Maintainability Implications

  • observed — The SDK holds the model mutex through engine use and result publication. Reconstruction writes to a request-local clip, and the SDK initializes the output to null before execution, so an exception during reconstruction cannot publish a partially modified clip.
Pre-merge checks: Passed 8

Check name Status Explanation
Title check Passed The title names the change: adding a new VideoMAE family that implements masked video reconstruction for the VideoMAE base checkpoint. The changeset adds the videomae family (builder, runtime, SDK con…
Description check Passed The description follows the template's main sections: Background, Exit Criteria, Implementation with change categories, Validation with commands, hardware/revisions, and remaining gaps, Contributor Se…
Linked Issues check Passed Directly linked issue #2673 requires a TensorRT engine for MCG-NJU/videomae-base (VideoMAEForPreTraining, FP32) and masked tube reconstruction through masked_video_text_to_video in the C/C++ SDK, matc…
Out of Scope Changes check Passed All changed paths fall within the VideoMAE family scope of #2673: families/videomae builder, runtime, support declaration, tests, manifest, README, NOTICE, and the ASSET_LICENSES.md line for the copie…
Family Ownership Boundary Passed The check fails only if this PR adds a dependency on another family's code, fixtures, or validation artifacts, or requires editing another family or a central family registry. The evidence shows neith…
Shared Semantic Neutrality Passed The check covers changed shared code outside model-owned directories. The changed-file inventory (git diff --name-status between the review base and head) lists 25 paths. Twenty-four are under `fami…
Benchmark Validation Integrity Passed The check applies because the PR adds validation behavior: families/videomae/tests/test_e2e.py adds a reference gate with thresholds, and the tests compare native output with a Transformers referenc…
Shared Change Blast Radius Passed The check applies only when a family PR changes a shared surface. This PR changes one shared file: ASSET_LICENSES.md, which gains a two-line entry for the family-local test photo `families/videomae/…
Full details: Title check

Explanation

The title names the change: adding a new VideoMAE family that implements masked video reconstruction for the VideoMAE base checkpoint. The changeset adds the videomae family (builder, runtime, SDK consumers, tests, docs), so the title matches the main change. It uses a conventional commit prefix, and the length is acceptable.

Full details: Description check

Explanation

The description follows the template's main sections: Background, Exit Criteria, Implementation with change categories, Validation with commands, hardware/revisions, and remaining gaps, Contributor Self-Review, and Notes For Future Readers with a risk level and rationale. It gives specific commands, results, and revisions. The template's Implementation section asks for public API, ABI, bundle, and dependency changes. The description says there is no shared code, header, ABI, or dependency change, but it does not state a bundle or artifact format change explicitly, so that point is only partly covered. Also, the Change categories list marks only Model or runtime behavior, though the PR adds a new bundle format and a public SDK task. Those gaps are minor, so the description is mostly complete.

Full details: Linked Issues check

Explanation

Directly linked issue #2673 requires a TensorRT engine for MCG-NJU/videomae-base (VideoMAEForPreTraining, FP32) and masked tube reconstruction through masked_video_text_to_video in the C/C++ SDK, matching the reference. The reviewed summary shows these implementations: (1) Builder: families/videomae/model.py build_engine/build and graph.py build the FP32 encoder and decoder graph with tubelet embedding, visible-tube encoding, and mask-token decoding, and config.py refuses unsupported configurations. (2) Runtime: runtime/pipeline.cpp MaskedVideoReconstruction implements IModel and IMaskedVideoTextToVideo, validates requests and engine I/O, and reconstructs masked tubes with source mean and standard deviation, clamped to [0,1]. clip.cpp implements tube selection and reconstruction. plugin.cpp registers the family factory. (3) Tests: test_model.py checks engine logits against transformers (1e-4 bound), test_e2e.py compares SDK output with a Transformers reference (max error at most 1e-4), and the C and C++ SDK consumers and test_clip.cpp cover the SDK path and refused requests. The author reports the E2E errors (6.6e-6 and 2.1e-5) and test counts. I did not re-run these checks. The excluded test image families/videomae/tests/data/test_img.jpeg is an input asset and does not change the implementation evidence. Non-coding criteria (CLI absence, performance non-goal) do not apply.

Full details: Out of Scope Changes check

Explanation

All changed paths fall within the VideoMAE family scope of #2673: families/videomae builder, runtime, support declaration, tests, manifest, README, NOTICE, and the ASSET_LICENSES.md line for the copied test photograph. The NOTICE and ASSET_LICENSES.md entries document third-party sources and licenses used by the family. The summary shows no changes to shared code, headers, ABI, dependencies, or other families. The excluded test image is a supporting asset for the E2E test. No unrelated change was identified in the summary.

Full details: Family Ownership Boundary

Explanation

The check fails only if this PR adds a dependency on another family's code, fixtures, or validation artifacts, or requires editing another family or a central family registry. The evidence shows neither. Scope of the change: all 24 changed paths are under families/videomae/, except ASSET_LICENSES.md (M). Changed-file inventory: git diff --name-status refs/coderabbit/pre-merge-check/base refs/coderabbit/pre-merge-check/head. Cross-family dependencies: none found. - Every families/ path literal in the new VideoMAE files points inside families/videomae/. Checked with a grep excluding families/videomae; no hits. - Python imports are limited to families.videomae and shared packages (tensorrt_model_connect, tools.e2e_evidence, numpy, pytest). test_model.py imports families.videomae only. test_e2e.py imports families.videomae.config plus the shared modules. - C/C++ includes resolve to families/videomae/... or shared trtmc/... headers, such as trtmc/runtime/trt_module.h, trtmc/internal/video.h, and trtmc/trtmc.h. None include another family. - The test photograph at families/videomae/tests/data/test_img.jpeg is the family's own copy. It does not read another family's file. - The ASSET_LICENSES.md change adds one line for the family's own asset (+2/-0). It does not change another family's entry. No registry edit is needed to add the family: - The root CMakeLists.txt discovers families by glob (families/*/runtime/CMakeLists.txt and families/*/cli.json). Its comment says "adding a family never changes a central source or target list." - families/__init__.py contains only a docstring. No family list or switch appears in it. - A search of shared code (core/, tools/, trtmc/, CMakeLists.txt) found no per-family list that this PR must edit. The only family names found were in tools/community_gpu_ci.py (SHARED_SMOKE_FAMILIES) and core/builder/tests/test_model_support.py. The PR does not edit either file. Shared mechanics: the code uses tools.e2e_evidence and the shared TensorRT/SDK headers. The check allows these. Residual note: ASSET_LICENSES.md is a central, repository-wide license inventory. This PR adds one line for its own asset, as other families do. Shared tests (tools/tests/test_architecture.py, tools/tests/test_family_impact.py) reference that file but do not require a per-family edit. This does not match the check's failure conditions.

Full details: Shared Semantic Neutrality

Explanation

The check covers changed shared code outside model-owned directories. The changed-file inventory (git diff --name-status between the review base and head) lists 25 paths. Twenty-four are under families/videomae/, which is family-owned and outside this check's scope. The only path outside that family is ASSET_LICENSES.md. Its diff adds one list entry, families/videomae/tests/data/test_img.jpeg, with a note that the E2E cuts a 16-frame camera pan from the image. This is license-attribution documentation. It adds no configuration, topology, tensor or output semantics, engine composition, runtime orchestration, preprocessing, postprocessing, reference behavior, metrics, thresholds, probes, or runtime strategies. No shared runtime, SDK, CLI, build, or common Python code changed. The check therefore has no shared semantic change to evaluate, so it passes.

Full details: Benchmark Validation Integrity

Explanation

The check applies because the PR adds validation behavior: families/videomae/tests/test_e2e.py adds a reference gate with thresholds, and the tests compare native output with a Transformers reference. No failure condition of the custom check is established. - Same semantic region on both sides. The native output comes from the C and C++ SDK consumers and is compared with the reference restoration. The reference uses VideoMAEForPreTraining predictions, restored with the unbiased source std plus 1e-6 and the source mean, then clamped to [0, 1]. The native reconstruct in runtime/clip.cpp uses the same steps: sample std with samples - 1.0, kStdEpsilon = 1e-6, the same mean, and a clamp to [0, 1]. Both sides compare the same masked-tube set (reconstructed). - Serialization and output validation. Both native consumers write float32 THWC output, which test_e2e.py reads back with np.fromfile. The reference stays in memory as float32. Both sides are float32 arrays before the numeric comparison, and the quality metric uses one shared formula (_quality) with one baseline (_tube_means). - No timing or performance comparison. The PR excludes performance qualification. inference_ms and the evidence stages are recorded, not gated, so no timed regions are compared. - Units are not conflated. The check counts frames, tubes and tubelets separately. The reconstructed_tubes and tubes values are reported separately from pixel metrics. - Evidence levels are kept. Checks carry explicit scopes (independent_reference for pixel and quality-gap checks, contract for conditioning and consumer agreement). The 1e-4 pixel bound is justified in the source with measured errors (6.6e-6, 2.1e-5) and injected-defect sensitivity. - No shared behavior change. The PR adds a new family directory and one ASSET_LICENSES.md line. No shared code changes. Minor observations, not failures: the reference derives its statistics from a normalize/denormalize round trip rather than the source pixels, which only causes float-rounding differences. The E2E skips unless explicitly selected; tools/ci/e2e.py passes premerge testcases through --e2e-testcase.

Full details: Shared Change Blast Radius

Explanation

The check applies only when a family PR changes a shared surface. This PR changes one shared file: ASSET_LICENSES.md, which gains a two-line entry for the family-local test photo families/videomae/tests/data/test_img.jpeg. The git name-status inventory shows every other changed path is under families/videomae/. No shared code, headers, public interfaces, dependencies, CI or tooling, or other families were modified. The masked_video_text_to_video Task and the internal IModel/IMaskedVideoTextToVideo interfaces are consumed, not changed. The asset-license entry is a per-asset record that follows the existing convention in that file. Other families' test photos are listed the same way (diff context). Its only consumers are license readers and audits. It introduces no behavior, compatibility, or ABI impact. The PR description names this line in the Background and Risk sections ("one asset-license line; no shared code, header, ABI or dependency changes"), so the change is identified and bounded. The remaining implementation is family-local under families/videomae/, which the check does not penalize. The description's open question about whether this Task is the right home for the implementation is a reviewer question. It does not alter any shared contract in this diff.

Warning

Some tools did not complete. Review the errors below.

Clang (23.1.4)

families/videomae/runtime/bundle_config.cpp

Clang-Tidy produced no recognizable diagnostics; analysis is incomplete

families/videomae/runtime/bundle_config.h

Clang-Tidy produced no recognizable diagnostics; analysis is incomplete

families/videomae/runtime/clip.cpp

Clang-Tidy produced no recognizable diagnostics; analysis is incomplete

  • 7 others
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 0c34044 and f75d6b1.

Files ignored due to path filters: 1

  • families/videomae/tests/data/test_img.jpeg is excluded by !**/*.jpeg
Files selected for processing: 24

  • ASSET_LICENSES.md
  • families/videomae/NOTICE
  • families/videomae/README.md
  • families/videomae/__init__.py
  • families/videomae/config.py
  • families/videomae/graph.py
  • families/videomae/model.py
  • families/videomae/runtime/CMakeLists.txt
  • families/videomae/runtime/bundle_config.cpp
  • families/videomae/runtime/bundle_config.h
  • families/videomae/runtime/clip.cpp
  • families/videomae/runtime/clip.h
  • families/videomae/runtime/pipeline.cpp
  • families/videomae/runtime/pipeline.h
  • families/videomae/runtime/plugin.cpp
  • families/videomae/support.py
  • families/videomae/tests/__init__.py
  • families/videomae/tests/cpp/test_clip.cpp
  • families/videomae/tests/manifests/videomae-base.json
  • families/videomae/tests/sdk_consumer.c
  • families/videomae/tests/sdk_consumer.cpp
  • families/videomae/tests/test_e2e.py
  • families/videomae/tests/test_model.py
  • families/videomae/tests/test_support.py

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 9 remain after this review.

@qikail-ctrl
qikail-ctrl marked this pull request as ready for review November 25, 2026 07:33
@qikail-ctrl qikail-ctrl added the run-internal-ci Maintainer-approved dispatch to internal CI label Nov 25, 2026
@github-actions github-actions Bot removed the run-internal-ci Maintainer-approved dispatch to internal CI label Nov 25, 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: support VideoMAE base (VideoMAEForPreTraining)

1 participant