Repository navigation
[Multimodal] Add lossy keyframe-only video loader (pyav_keyframes) - #45203
WindChimeRan wants to merge 5 commits into
Conversation
Signed-off-by: ran <hzz5361@psu.edu>
|
Documentation preview: https://vllm--45203.org.readthedocs.build/en/45203/ |
Signed-off-by: ran <hzz5361@psu.edu>
d6d5f64 to
d44a58f
Compare
Signed-off-by: ran <hzz5361@psu.edu>
Signed-off-by: ran <hzz5361@psu.edu>
6d8225b to
f2517b3
Compare
|
I'm hesitant to merge this PR, because each model has different frames sampling method for best video accuracy: Lines 699 to 714 in 0cd9b7a I think the ground truth in your experiment should be model-specific video loader with correct frames sampling strategy, instead of the default opencv fallback. Otherwise the video benchmark accuracy will still be distorted. |
|
Why the This loader cannot displace a model-specific one. the env var is a no-op for models with a mapped loader; Motivating workload. This came out of an eBay-scale video classification pipeline: large volume, small label set, not motion/temporal-order sensitive, ~1 output token — where CPU-side video decode is the measured bottleneck, not the GPU. Keyframe extraction is nearly free because the container already indexes I-frames; no P/B-frame is ever decoded. Intended use: gated by a cheap A/B on the target data. The loss is data-dependent (−52.7 pt on |
Signed-off-by: ran <hzz5361@psu.edu>
Actually, Qwen2.5-VL has no processor-mapped loader in vLLM is just because I don't have bandwidth to implement it recently. 😅 You can refer to processor implementation in Transformers which provides a correct frames sampling strategy: |
|
@Isotr0py Thanks for pointing me to the HF reference. I'll build the Qwen2.5-VL processor-mapped loader as a separate PR, then rerun accuracy against it as the ground truth |
- Rename loader pyav_keyframes_v2 -> pyav_keyframes (matches upstream vllm-project/vllm#45203); update backend, infer.py, docs. - Collapse the run1..run6 tuning ladder to two presets: baseline (best lossless: cv2 + tuned pixels/frames + ViT compile + parallel renderer) and keyframes (baseline + pyav_keyframes loader). The baseline->keyframes delta isolates the loader's contribution. - Add upstream_bench/bench_real_loader.py: synthetic decode-speed microbench (lossless full-decode vs keyframe-only) backing the PR speed claim and the link in its description. - Rewrite LARGE_SPEED_LOG.md and README.md to the two-config story. - Archive journey docs (MINI_SPEED_LOG, RENDERER_WORKERS_TUNING, PREPROCESSING_BOTTLENECK_HANDOFF) as local *.backup (gitignored); drop bench_opt/ and the keyframe plugin package. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
close because #46609 supersede this. and seek_mode="approximate" is exactly what we want. |
Purpose
Add an opt-in, lossy video loader
pyav_keyframesthat samples only bitstream keyframes: one header-only demux pass to enumerate keyframe PTS, then seek-decode exactly those frames. No P/B-frame is ever decoded.Targets prefill-heavy workloads where CPU video decoding, not the GPU, dominates the pipeline. All results below are from single-token multiple-choice video QA (classification-style,
max_tokens=1), and motion-/temporal-order-sensitive tasks measurably degrade (see Accuracy). Clips with fewer keyframes than the budget get balanced duplication, with true source indices inframes_indices.Documented in
docs/features/multimodal_inputs.md.Builds on the PyAV codec (#39986, #42586). #44598 (draft) pursues the complementary lossless goal — decoding the same exact frames faster — while this PR changes which frames are sampled; happy to rebase onto its
_demux_keyframes()if it lands first.Exp setting
LLM.chat, single-token MC video QA, Qwen2.5-VL-7B-Instruct, 1×A100-80GB, bf16,max_tokens=1,num_frames=16,max_pixels=256·28²; N=1990 = NExTQA MC test (1000) + MVBench 55×18 subtasks (990); baseline = lossless cv2 loader, identical settings.Results
Qwen2.5-VL-7B, offline single-token MC video-QA (
max_tokens=1), N=1990 (NExTQA 1000 + MVBench 990), 1×A100-80GB, identical resolution/engine settings — vs the faithfulqwen2_vl(fps=2) baseline:qwen2_vl(faithful, #45555)pyav_keyframes(this PR)~3–5× throughput for −3.1 pt NExTQA / −14.4 pt MVBench. NExTQA (scene/state QA) holds within ~3 pt; the MVBench cost is real and concentrates in motion / temporal-order subtasks (
action_antonym−47.3,moving_attribute−38.2,object_existence−36.4). The decode win is data-independent: a synthetic H.264 microbench extracts 16 frames in near-constant tens of ms whether the clip is 30 s or 10 min (vs the lossless path growing with clip length).Full reproducible experiments: https://github.com/WindChimeRan/offline_video_vllm
Test Plan
2 CPU tests (
pytest tests/multimodal/test_video.py -k pyav_keyframes):frames_indices.Test Result
pytest tests/multimodal/test_video.py -k pyav_keyframes -v # 2 passedEssential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.