Repository navigation
vision, gpu-gates, tools: EmbeddingGemma 2 video clips sampled at 1 FPS from decoded frames, checked against llama.cpp - #383
Conversation
There was a problem hiding this comment.
Verdict: CLEAN: No must-fix defect was found in the sampler, gate, or collector.
Non-blocking
⚠ Verify reference sampling independently: tools/ref/emb2/video_oracle.py:110. The oracle receives PNGs already selected by video_clips.py. Its vector comparison cannot detect a different frame choice by llama.cpp's video helper. Record one run of the helper or its FFmpeg filter on the complete fixtures, with the executable version and selected indices, before these expectations become an established reference.
Checked
Duplicates: 7 new functions checked by purpose; no duplicate owner found. Dryer reported no vision pairs.
Complexity: clips is new at 41, combining fixture parsing/validation and encoding. run rose from 23 to 30 through argument parsing and clip dispatch.
Silent failure: 3 sites followed: the index clamp and two HTTP exception handlers. Sampling stays in bounds; unavailable servers reach startup errors or the readiness timeout.
Tests: Static mutation check: changing media.rs:88 from next - 1 to next would fail the index assertion at mod.rs:39. Removing EOF rounding's + num at media.rs:76 would fail the half-second acceptance assertion at mod.rs:60. The PR reports a GPU FAIL-first for the index mutant. Rust tests and GPU gates were not run during validation.
Gates: no existing band, pin, or test removed or relaxed; the new clip path has reported FAIL-first evidence.
Escape catalog: no C1–C4 pattern matched. No new unsafe block or engine hot-path change.
Notes
Dryer skipped gpu-gates; its changed code was checked manually with Grep.
GPU results are summarized, but the exact gate command and its output are absent. Attach that transcript with both tested commit hashes to complete the hardware evidence.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_gemma_embedding2_e2e.rs and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
The review is done and the contribution check passed, so I'm merging this. |
Part of #59 (plan and PR order in #190), item V2: which frames of a decoded video clip EmbeddingGemma 2 sees, and a check of that choice against llama.cpp. It builds on V1 (#374) and has one commit.
What and why
Release notes: internal: the Gemma4 vision path can pick the 1 FPS frames of a constant-rate decoded clip, and the EmbeddingGemma 2 end-to-end gate checks that choice and the resulting vectors on three clips against llama.cpp. HTTP video input and decoding are not part of it.
V1 took frames the caller had already chosen. llama.cpp starts from a whole clip and keeps one frame per second. If Bloomery picks different frames, the vectors differ even when the tower is right. This PR adds the pick and a way to compare it with the reference.
crates/vision/src/arch/gemma4v/{media.rs,mod.rs}).prepare_cliptakes the decoded RGB frames of a zero-origin constant-rate clip and a rational FPS, and keeps one frame per output second. It rounds to the nearest output tick, with the same end-of-clip rounding as FFmpeg n7.1, which the reference helper delegates to. It allows 1 to 32 output frames and names an invalid FPS, an empty clip and a 33rd output frame as errors.prepare_framesholds the preprocessing thatprepare_clipand V1'sprepare_videoshare. The 32-frame limit is Bloomery's own V1 interface limit; llama.cpp has no such cap.crates/gpu-gates/src/bin/gate_gemma_embedding2_e2e.rs). The new--video-clips <clips.tsv>path checks each full RGB stream's size and digest, calls the production sampler, and compares the chosen indices, the PNG pixels, the frame count and the position count with the manifest. It rejects duplicate clip names and requires exactly one matching video record in each reference set. Then it runs the tower and the text encoder. This path and V1's sharevideo_passfor span checks and pooling.tools/ref/emb2/{video_clips.py,video_oracle.py,README.md}).video_clips.pywrites three RGB clips with different lengths, frame rates and aspect ratios, with expected indices derived from the FFmpeg source rule, not from the Bloomery sampler.video_oracle.pychecks the llama.cpp pin and the model digests, then runs a CUDA server and a CPU twin one after the other for each clip. The CUDA card header comes from the CUDA driver's visible devices, so ordinal, UUID and MIG selections use the same device enumeration as the server. A missing or invalid model profile, a missing driver, a failed CUDA query or an empty visible set stops collection. The README states the constant-rate contract and the commands.Code shape
prepare_framesis the one owner of frame preprocessing forprepare_clipandprepare_video, andvideo_passis the one owner of span and pooling checks for both gate paths. The collector reuses the existing model profile,server_vectors.pyand the image comparison helper.unsafeblock was added.cargo clippyand the security scan were not run. The fullcontrib-check --tier t0run includes formatting, pure-crate tests and comment checks.Duplication removed: the clip gate now takes its per-frame token limit from
gemma4v::VIDEO_TOKENS, which preprocessing also uses. Bothvideo_passcallers use the fixed reference key owned by the helper.What I ran
The focused regression exercises the current collector with a synthetic CUDA driver, writes its device header through the production manifest writer and reads it back. It also compiles and runs the production Rust video-header and clip-row validation blocks without the encoder or a GPU. The before/after cases use
42b3c982and the source now committed at0bf9f8cb.The device cases cover an unset visibility mask, one and several visible devices, numeric ordering, full and partial UUIDs, MIG, an empty visible set and failed CUDA calls. These are synthetic driver responses, not a multi-GPU hardware test. The Rust cases cover missing, foreign, duplicate and malformed video records, wrong position counts, wrong image counts and invalid fixture rows.
CUDA checks on
0bf9f8cbI collected new mainline CUDA and CPU-twin reference sets for all three clips with this head's collector, rebuilt the CUDA gate with the sampler mutant and with the restored source, and reran the Hugging Face distance calculation against those new CUDA vectors. Only the build cache, model files and isolated Hugging Face environment were reused.
gate_gemma_embedding2_e2ewith the sampler edited to take the wrong frame, then the gate on clipclip_1s24source indices [12], expected [11]gate_gemma_embedding2_e2e, then the gate on all three clips at0bf9f8cbjust contrib-check --tier t0on Linux at0bf9f8cbDONE tier=t0 total=86 red=0 wall=431sThe edit that makes the first row fail changes
(next - 1)tonextin the production sampler. Pixel and position checks are in the gate, so one wrong index is enough to stop it.Comparison with the reference
The reference is mainline llama.cpp
6868a52cb337450658006ad2f9281c2eb63f1666,llama-server /v1/embeddings, built with CUDA for architecture120a. The model isembeddinggemma-2-Q8_0.gguf(SHA2562188ac1deca4b77dffefd603c2776a9d76d9d74ec01841392982ebb840b09135) with the BF16 projectormmproj-embeddinggemma-2-BF16.gguf(SHA256d2033b3cd0223cfb2e7a2b50dc80a664c78c816d375f5b017ec3ef80ee0bc766). The flags are--embeddings --pooling mean -c 8192 -b 8192 -ub 8192 -np 1 -t 8 --image-max-tokens 140 --video-fps 1 --video-timestamp-interval 0. The CPU twin runs withCUDA_VISIBLE_DEVICES=and-ngl 0 --no-mmproj-offload. The gate band is unchanged: 2.5 times the CPU twin's relative L2 distance.The table records the fresh CUDA/CPU oracle collection, Bloomery gate and Hugging Face run at
0bf9f8cb. "Mainline/Bloomery indices" is the shared choice. The indices are the FFmpeg-derived expectation that the gate checks Bloomery's sampler against. llama.cpp returns no list of its own chosen frames, so the vector match is what supports them. The last three columns show the Hugging Face processor, described below.All six vector comparisons are below the unchanged band.
[derived] Minimum band minus observed relative L2 across six comparisons: 1.203812804100e-02. HF distances are diagnostic only.
Clips 1, 7 and 16 seconds long have 87, 557 and 1268 prompt positions. Within a clip every frame takes the same number of positions (81 for the 1 second clip, 77 for the others). The first frame starts at position 4, and no timestamp or separator sits between frames. The PR makes no speed claim.
The Hugging Face columns are a distance record, not an acceptance criterion. They were measured with the
google/embeddinggemma-2checkpoint at revision914f7f89142e33e77833254d9c9b90c3cef7303band transformers5.21.0.dev0(source revision551122ae8e709cc36a4f2b14900fac8964ef22df). The model ran in BF16 with eager attention and the promptVideo:<|video|>, with the real source FPS and duration. The output rows were mean pooled in float32 and L2 normalized. The distance is to the same llama.cpp CUDA vector. The Hugging Face processor picked frames 0, 30, 60 and so on where llama.cpp picked the nearest tick, and it also differs in resize and checkpoint precision, so I do not attribute the gap to one cause. Nothing in the gate depends on it.Hardware (if the change is for a machine)
RTX 5090:
NVIDIA GeForce RTX 5090, 595.99.02, 12.0, 32607 MiB, 400.00 W, compute capability 12.0, CUDA 13.0. The Bloomery gate was built through the pinned cuda-oxide path. No kernel and no device arithmetic changed, so I did not run a DGX Spark.What I ran into
None of this blocks the PR.
video_passcompiled and ran in the new path.t0tier ran on Linux. Clippy and the security scan remain outside these runs.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.