mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1327] [CLOSED] serve: opt-in finite video input #3386
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#3386
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/1327
Author: @constantindjonkam
Created: 10/7/2026
Status: ❌ Closed
Base:
main← Head:feat/video-support📝 Commits (10+)
f36250dfeat(media): add bounded visual transport and pinned video traces9c1fb25feat(api): preserve ordered video inputs and reject unsupported formsed335b1feat(media): validate Qwen4 spans and request binding before payload readsd359264fix(media): reject unbound visual pads in the Qwen4 profilea9dbb83feat(engine): bind SVE2 media in serial CUDA serving4d66607feat(vision): add opt-in temporal frame export and capability negotiation5c8de26feat(video): define finite CFR sampling and cumulative request budgetsb700be4feat(media): own and bound decoder subprocess lifetimes5a711cffeat(video): stage finite sources and decode owned RGB frame spools0404cbftest(video): record actual CPU rope and independent tokenizer parity📊 Changes
32 files changed (+7034 additions, -74 deletions)
View changed files
📝
CMakeLists.txt(+16 -1)➕
docs/MEDIA_FORMAT.md(+153 -0)➕
include/strata/program/media_embeddings.hpp(+79 -0)📝
serve/frontend.py(+72 -13)➕
serve/media.py(+426 -0)➕
serve/media_process.py(+184 -0)➕
serve/media_worker.py(+224 -0)📝
serve/responses.py(+18 -2)📝
serve/server.py(+268 -43)➕
serve/test_media.py(+326 -0)➕
serve/test_media_process.py(+61 -0)➕
serve/test_media_profile.py(+74 -0)📝
serve/test_server.py(+1 -0)➕
serve/test_video.py(+166 -0)➕
serve/test_video_encoder.py(+145 -0)➕
serve/test_video_frontend.py(+76 -0)➕
serve/test_video_policy.py(+98 -0)➕
serve/test_video_reference.py(+105 -0)➕
serve/test_video_server.py(+158 -0)➕
serve/video.py(+299 -0)...and 12 more files
📄 Description
In short: opt-in video for the existing Qwen4 vision path — sampling by presentation timestamp, budgets that fail closed, live preparation progress, and a Monitor that reports the queue. Off unless
vision.video.enabledis set and both encoder and engine advertise the profile. Not established here: temporal grounding or answer accuracy — see Scope at the end.What this adds
Opt-in video input on the existing Qwen4 vision path. Off by default; text and image-only requests keep their current path. Encoder and engine must both advertise
qwen4_exp_16x2x2_2560_v1.video_url, Anthropic/Responsesinput_video, Qwenvideo— user messages only.count_tokensdoes not guess the expanded length of video content.ffmpeg/ffprobe(executables, not linked libraries) and Pillow. Without them images still work and video reports itself unavailable.Sampling by timestamp
Frames are chosen on a fixed time grid by actual presentation timestamps: nearest frame wins, earlier frame on an exact tie, duplicate picks dropped. A variable-frame-rate clip is sampled by the time its frames really show — no constant-rate transcode. Each chosen frame keeps its own timestamp for temporal grouping and labels.
sample_indices()stays for the pinned index-based reference fixtures; it is not the serving path.0, 2, 4, 6, 8, 9, 110, 0.5, 1, 1.5, 2, 3, 3.5Selected RGB matched independently extracted reference images. A clip over budget is rejected, never silently thinned. Separately, a synthetic 512 s / 30 FPS clip selected 1,024 of 15,360 frames with 1.71 s CPU stage/probe/decode (FFmpeg 8.1; input generation excluded).
Defaults — configurable, all fail closed
2 FPS · 600 s clip · 1,024 selected frames · 32,768 source frames · 256 MiB source · 256 MiB RGB · 4 GiB streamed decoder output · 65,536 visual rows · 512 MiB wire · 2 GiB shared disk · 600 s deadlinemax_framescounts emitted frames after PTS deduplication; its configurable ceiling is 4,096. The default row budget reaches the 65,536-row code ceiling; wire defaults to 512 MiB below its 768 MiB ceiling. Separate clip-derived row, RGB, decoder-output and full-wire costs are checked before decode. Cadence is never silently lowered.FPS is server-wide (
vision.video.fps, restart to change) and now configurable to 24, up from 10; the sampling grid is bounded to 86,401 points by the 3,600 s / 24 FPS ceilings. Raising FPS does not raise any other budget: at 24 FPS a three-minute clip needs 4,320 frames, over the 1,024 default and the 4,096 ceiling, so it is rejected rather than thinned.Progress while a clip is prepared
Preparation is minutes of CPU work before the model sees a token, so the Monitor follows it instead of showing one label. Stages report counts, never a percentage or an ETA — neither can be promised across clips, codecs and cards.
Staging source · 12.4 MiB / 24.0 MiB— bytes copied; indeterminate when the source size is unknownChecking timestamps and selecting framesDecoding frames · 612 / 1,024Waiting for the vision encoderEncoding frames · 380 / 1,024Assembling video embeddings into the prompt,Submitting the prepared promptThe encoder reports frame groups on a new
VPROG <done> <total>line before its final reply. The server accepts only strictly increasing counts with a stable total and caps the number of lines; a malformed line ends the exchange exactly as any other malformed reply does. Staging and decoding counts reach the server asSTRATA_PROGRESSlines on the media worker's stderr and are validated before use.A request arriving while the model is busy reports
Queuedwith the waiting count. Preparation also takes a slot — one at a time, or the engine's batch slots when requests run in parallel — held from staging through handoff, so a third clip queues instead of starting a third FFmpeg worker; a clip waiting for a slot reads asQueuedas well. Codec work still runs outside the GPU FIFO, so a text request can take the model while a clip decodes. That gap is the one images have always had — download outside the FIFO, encode inside — short enough there never to have shown.Slots bound clip preparation, not media work in general. Text and image requests never take one, so 50 images sent alongside 3 clips are served at FIFO priority while the clips decode. Their encode already runs inside the FIFO, which is what bounds them.
Measured
8eaca97cMEDIA_TEST_EXEunset, nojsonschema, Windows-only job objects8eaca97cf075ba7fMEDIA_TEST_EXEand real ffmpeg set)PASS_CPU_TORCH, 6 ×PASS_RUST_TOKENIZERSstaging → probing → decoding 0/40 → encoding 0→40/40 → assembling → reading → generating, HTTP 200queued: 1and waited for the FIFO--batch 2; a clip waiting for a slot reportedqueued: 1One pre-existing flake:
test_responses.NoLeakedSamplerfails intermittently under full discovery. It reproduces on the base commitf075ba7fwith no local changes, so it is not from this branch.Native CPU vision rows against the pinned checkpoint BF16 vision implementation (BF16 weights computed in FP32):
Fixture measurements, not a universal tolerance. Encoding the full clip or separate frame pairs gave bitwise-identical reference embeddings on these clips.
A clip should not cost the conversation its text cache — four vision placements, same six-turn text series with a clip in the middle:
Those ran on an 8,192-token context, not the 262,144-token production context, with a 128×64 five-frame clip: a transport and cache smoke test.
Builds, inputs and the commands that re-run the host checks:
docs/VIDEO_VALIDATION.md.Scope: these cover sampling, frame extraction, transport, encoder rows, positions, preparation progress and cache behaviour. They do not establish general temporal grounding or video-answer accuracy — focused temporal QA fixtures have not consistently returned the requested word. Windows, HIP, SYCL, batched video requests and helper-drafter operation are out of scope.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.