Skip to content

[TAO-1796][Feature] video_clip: add InternVideo2-CLIP TensorRT deploy module - #36

Merged
christinayyw merged 5 commits into
mainfrom
dev/video-clip-trt-deploy
Aug 12, 2026
Merged

[TAO-1796][Feature] video_clip: add InternVideo2-CLIP TensorRT deploy module#36
christinayyw merged 5 commits into
mainfrom
dev/video-clip-trt-deploy

Conversation

@lianqiann

Copy link
Copy Markdown
Contributor

Summary

Adds the deploy-side counterpart of the tao-pytorch video_clip task: build a TensorRT engine from the exported InternVideo2-CLIP ONNX, then run retrieval inference and evaluation against it.

Changes

  • video_clip entrypoint with gen_trt_engine, inference and evaluate subtasks, the shipped experiment spec, and the config dataclasses under config/multimodal/video_clip/.
  • Dataloader mirroring the training-time contract — frame sampling, ImageNet (not CLIP) normalization, and optional text canonicalization gated on the exported model config — so deploy-time preprocessing matches training exactly. A mismatch here degrades retrieval silently rather than failing.
  • Retrieval evaluation — mAP, Recall@K, median and mean rank over the combined video and text embeddings.
  • EngineBuilder._extra_network_flags() — a new overridable hook on the shared builder, defaulting to 0, OR-ed into the create_network flags. video_clip overrides it to request a strongly-typed network, which is what stops TensorRT's weakly-typed fp16 path from re-interpreting the AutoCast mixed-precision ONNX. No behaviour change for any existing network.

Testing

  • Unit tests covering the config, dataloader preprocessing, engine builder, entrypoint wiring, retrieval metrics and inferencer.
  • pre-commit (docs supported-commands, license header, pylint, pydocstyle, flake8) clean over the full diff range.
  • End-to-end engine build, inference and evaluation validated against the exported InternVideo2-CLIP ONNX.

Migration provenance

Manual migration of GitLab MR !205 (branch alicli/iv2clip). The GitHub and GitLab repositories share no git history, so the branch's net diff was replayed onto main as three logical commits. Two notes:

  • The source branch had advanced past the MR snapshot — it now includes the strongly-typed TRT build and the fp16 normalization fix — so the current branch tip was ported, not the older MR diff.
  • docs/supported_commands.md is regenerated by the repo's own update-docs-supported-commands hook and is included here.

Depends on the tao-pytorch PR for the exported model this module consumes.

…ploy module

Add the deploy-side counterpart of the tao-pytorch video_clip task: build a
TensorRT engine from the exported InternVideo2-CLIP ONNX, then run retrieval
inference and evaluation against it.

- gen_trt_engine, inference and evaluate subtasks behind a video_clip
  entrypoint, with the shipped experiment spec and config dataclasses.
- A dataloader that mirrors the training-time frame sampling, ImageNet
  normalization and optional text canonicalization, so deploy-time
  preprocessing matches training exactly.
- Retrieval metrics (mAP, Recall@K, median/mean rank) over the combined
  video and text embeddings.
- EngineBuilder gains an overridable _extra_network_flags() hook, defaulting
  to 0, so this module can request a strongly-typed network. That is what
  keeps the AutoCast mixed-precision ONNX from being re-interpreted by the
  weakly-typed fp16 path.

Signed-off-by: Alice Li <alicli@nvidia.com>
Register the video_clip console entrypoint and regenerate
docs/supported_commands.md from it.

Signed-off-by: Alice Li <alicli@nvidia.com>
Cover the config dataclasses, the dataloader preprocessing, the engine
builder, the entrypoint wiring, the retrieval metrics and the inferencer.

Signed-off-by: Alice Li <alicli@nvidia.com>
@lianqiann
lianqiann requested review from a team as code owners August 11, 2026 00:20
@tao-pr-bot

tao-pr-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

For security reasons, CI does not run automatically on NVIDIA's runners — it must be triggered per commit.

  • Comment /build to run CI on your latest commit, and make sure blossom-ci is green before merging.
  • Re-run /build after each new push — CI is pinned to the head commit, so a stale run won't count.

Tip

Should this fix also ship in a release? Add a release/X.Y.Z label (matching the target release branch) and tao-cherry-pick-bot will backport it after merge.

Important

Before merging: every file needs a license header and every commit must be DCO signed-off — see the 📖 Contribution guide for details.

@lianqiann

Copy link
Copy Markdown
Contributor Author

Migrated from GitLab as part of the TAO GitHub-first cutover. This change lands across three repositories — the set is:

The tao-pytorch PR is self-contained and can merge independently: the module does not import nvidia_tao_core. tao-deploy consumes the ONNX that tao-pytorch exports, and tao-core only brings the API/microservices schema into parity.

@lianqiann

Copy link
Copy Markdown
Contributor Author

/build

1 similar comment
@hqtran-nv

Copy link
Copy Markdown
Contributor

/build

@svc-bcs-agent

Copy link
Copy Markdown
Contributor

Hi @lianqiann 👋💛

🤖✨ AIRE (NVIDIA's automated CI agent) here! ✨🤖

🔍🚨 I detected that the CI pipeline on your PR #36 has failed — but no worries, I'm already on it! 💪🔧

🛠️🔬 I'm automatically diagnosing the root cause right now and preparing a fix for you. ⏳✅

🔔💬 I'll ping you the moment the fix is ready to review — nothing you need to do for now. Sit back and relax! 🌿😌

💙🙏 Thanks for your patience — AIRE's got your back! 🚀🌟

@svc-bcs-agent

Copy link
Copy Markdown
Contributor

Hi @lianqiann 👋🎉

🤖✨ AIRE (NVIDIA's automated CI agent) here with great news! ✨🤖

✅🛠️ I've finished diagnosing and automatically fixed the CI failure on your PR #36! 🎯💚

What was wrong: tests/video_clip/ reuses the same test-module basenames as the existing tests/clip/ (test_config.py, test_dataloader.py, …). Neither directory had an __init__.py, so pytest imported both sets under bare module names and hit import file mismatch on all six — aborting collection with exit code 2 before any of the 275 tests could run.

The fix: add the missing __init__.py to tests/video_clip/ and tests/clip/, matching the convention used by all 24 other tests/ subpackages.

Verified green: the fix branch now collects 316 items and reports 296 passed, 20 skipped, 0 failed

🔗📦 The fix is ready in a dedicated PR → #38
👉 #38

🙏💪 Please take a quick look and merge it whenever you can, so the fix lands and your CI goes green again. ✅🌟

💙🎉 Thank you so much — merging AIRE's fix keeps CI healthy for the whole team! 🚀
🤗☀️ Have a wonderful day!

@vpraveen-nv vpraveen-nv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Alice — clean deploy module, and the preprocessing-contract documentation in the dataloader is exactly the right emphasis. I checked GitLab !205 (no prior review comments there) so nothing here is a repeat. One real bug in the AUC computation (inherited from the tao-pytorch twin — worth fixing in both), plus a few smaller items inline.

Comment thread nvidia_tao_deploy/multimodal/video_clip/evaluation/retrieval.py Outdated
Comment thread nvidia_tao_deploy/multimodal/video_clip/dataloader.py Outdated
Comment thread nvidia_tao_deploy/multimodal/video_clip/scripts/evaluate.py
Comment thread nvidia_tao_deploy/config/multimodal/video_clip/default_config.py Outdated
svc-bcs-agent and others added 2 commits August 12, 2026 10:23
tests/video_clip and tests/clip share test-module basenames; without __init__.py pytest imports both under bare module names and aborts collection with import file mismatch.

Signed-off-by: Alice Li <alicli@nvidia.com>
Fix the AUC computation and three review items from vpraveen-nv:

- retrieval.py: compute_auc() sorts its `scores` argument internally and
  indexes `labels` with the result, so both arrays must be in the same
  order. The call passed gallery-order `sims` with rank-order
  `sorted_labels`, pairing each score with the wrong item relevance. Pass
  `sims[sorted_idx]` so the two align. The reported AUC was not merely
  noisy but inverted: a query whose only relevant clip ranks last scored
  1.0 instead of 0.0. Covered by two new tests -- the AUC path had no
  coverage at all, since every existing case set compute_auc=False.

- dataloader.py: drop the hardcoded /media/wbf/ prefix remap. It is a
  leftover from the original dataset author machine and is already
  expressible via path_prefix_mapping, which is checked first. This
  matches the same removal in the tao-pytorch twin (PR #94).

- scripts/evaluate.py: warn when no *_config.yaml is found next to the
  engine instead of silently assuming canonicalize_text=False. A model
  exported with canonicalize_text: true would be queried with mismatched
  tokens and just score worse, with nothing in the log to say so.

- config/.../default_config.py: route path_prefix_mapping through
  DICT_FIELD like every other key in the schema, so its description and
  display name reach default_specs.

Signed-off-by: Alice Li <alicli@nvidia.com>
@lianqiann

Copy link
Copy Markdown
Contributor Author

/build

@christinayyw
christinayyw merged commit f353ae7 into main Aug 12, 2026
5 of 6 checks passed
@christinayyw
christinayyw deleted the dev/video-clip-trt-deploy branch August 12, 2026 19:10
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.

5 participants