mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1609] [Engine] Video input: video_url parts through strata-vision, in the Qwen3-VL layout #3559
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#3559
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/1609
Author: @Destrayon
Created: 10/8/2026
Status: 🔄 Open
Base:
main← Head:pr/video-understanding📝 Commits (6)
a9f382cstrata-vision: ENCV encodes a video in the Qwen3-VL layout267d55dserve: video parts (OpenAI video_url, Responses input_video, Anthropic video)565eedcweb: attach a video in the chat page (button, drop), sent as a video_url parta5290d6docs: videos (the layout, the keys, measured encoding and answers)2ab2751strata-vision: a pair's time label is its frames' real mean (ffmpeg's fps filter returns frame k at ~(k+0.5)/fps)f9827cfserve: a video's frame pairs default to at most 768 tokens, qwen-vl-utils' VIDEO_MAX_TOKEN_NUM📊 Changes
9 files changed (+680 additions, -42 deletions)
View changed files
📝
docs/DETAILS.md(+68 -2)📝
serve/frontend.py(+32 -1)📝
serve/responses.py(+6 -1)📝
serve/server.py(+168 -29)📝
serve/test_server.py(+151 -0)📝
serve/web/app.css(+1 -0)📝
serve/web/app.js(+31 -6)📝
serve/web/sprite.svg(+1 -0)📝
tools/vision/strata_vision.cpp(+222 -3)📄 Description
Problem and result
Qwen3.8-Flash-Next was trained on video (its template has
<|video_pad|>, its mmproj isqwen3vl_mergerwithtemporal merge 2), but Strata reads pictures only: a
video_urlpart is refused. With this change a video sent as anOpenAI
video_urlpart, a Responsesinput_videopart or an Anthropicvideoblock (asdata:, anhttp(s)URL ora local path, like images) is read by the model, and the web chat can attach one. The engine is unchanged: each frame
pair reaches it as an ordinary picture record through the existing
GENIpath.A video is laid out as transformers' Qwen3-VL processor (
processing_qwen3_vl.py) does it: frames sampled by ffmpeg,frames 0+1, 2+3, ... merged into one temporal patch (an odd last frame doubled), each pair preceded by its time as
text,
<1.2 seconds>(the mean of the two frames' real times), then<|vision_start|>image<|vision_end|>.Related discussion
none. DETAILS.md lists "no video" under the current limits. Follow-up work on top of this branch was in #2023.
Approach
ENCV <fps> <max_frames> <max_side> <pair_tokens> <total_tokens> <min_pair_tokens> <video> <out>, answeringOK <tokens> <pairs> <frames> <ms>andLAYOUT <T ids|I cells; ...>. It plans from the video'sprobed length within the whole-video budget: 2 fps at up to 768 tokens per pair (qwen-vl-utils' default) while it
fits, then smaller frames down to 128 per pair, then a lower frame rate, so any length is one request. It encodes 64
frames at a time (peak 859 MB for a 10-minute video at 158K tokens).
--ffmpeg-dirnames ffmpeg/ffprobe when theyare not on PATH.
ENCis unchanged.mtmd_helper_video) is not used for the layout: it writes aVideo:label and a[0m5.00s]timestamp every 5 s after the frame it marks, which leaves frame 0 unpaired and shifts every label; withit, answers placed events about 1 s late. Its ffmpeg reader is used for the frames.
<|vision_start|><|video_pad|><|vision_end|>with the layout (text ids and one<|image_pad|>per cell); the pairs' records join the request's embeddings file in prompt order with the images.The image rules apply: URL downloads outside the request queue, local files only from the server's own page or
trusted origins, the request's own files never evicted (#1072), offline mode refuses a video URL as it does an image
URL, and a client that hangs up stops the encoding between videos. Budget:
video_total_tokens0 = 60% of thecontext, at most 224K (the model card's hour-scale setting), shared by the request's videos;
video_fps,video_tokens,video_min_tokens,video_max_frames,video_max_sidein the"vision"section, and a part's ownfps,max_frames,max_side,tokens,total_tokensoverride them./healthhas"videos".img_keys, #2228). A video's file holds onerecord per frame pair, so a request with a video sends no keys and the engine keys each record by its embeddings'
hash, as it does when keys are absent. Requests with pictures only are unchanged.
/healthsays videos are read.ffmpegandffprobe(as llama.cpp's own videosupport does); without them a video is refused with
ERR cannot read the video ... (is ffmpeg/ffprobe installed?)and pictures are unaffected. Setup does not install them. A release's ready-made
strata-visionneeds rebuildingfor
ENCV.Validation
Rebased on main
f57c0adc; tested revisionf9827cfa(this branch). Windows 11, i9-13900K, RTX 5070 Ti, MSVC 14.51(Visual Studio 18).
Passed:
python -m pytest serve/test_server.py -qonf9827cfa: 347 passed, 3 skipped, 449 subtests passed. The 9video tests (
-k video: layout splicing, images and videos in prompt order, a literal marker kept as text, thethree APIs' request shapes, the budget, the ENCV line, the temp file removed on a broken pipe) all pass.
python -m pytest serve -q --ignore=serve/test_server.pyonf9827cfa: 526 passed, 14 skipped, 10,083 subtests passed.node --check serve/web/app.js: no errors.strata-visionfromf9827cfabuilt with MSVC against llama.cpp3cf0325(main's pinned commit), CPU backend:builds clean.
ENC test-1.jpeggivesOK 300 20 15(unchanged).ENCV 2 0 0 448 0 128on a 10 s 720x358 clip givesOK 2530 10 20(20 frames, 10 pairs, 2,530 tokens, 15 s on 16 CPU threads), labels 0.5, 1.5, ... s. Against thepre-rebase build on the same clip: same token count, pairs, frames and record headers; only the time labels
differ, which is this branch's label fix.
strata-visionfromf9827cfabuilt with CUDA 12.8 for sm_120 (MSVC 14.44), run with--gpuon the 5070 Ti:ENC test-1.jpeg300 tokens in 257 ms;ENCVon the same clip 2,530 tokens in 2.2 s, the LAYOUT line identicalto the CPU build's, embeddings rows at cosine similarity 0.9994 mean (0.959 lowest) to the CPU build's.
f9827cfa(main's engine source unchanged by this PR) builds with CUDA 12.8 for sm_120 (setup'sCUDA 12 options:
-DSTRATA_EXPERIMENTAL_SM60=ON -DSTRATA_Q6K_EXPERTS=ON -DSTRATA_MMQ_KQUANTS=ON).f9827cfaGPU encoder: the clip sent as avideo_urlpart, encoded on this PC (2.6 s) andanswered by IQ3_S on an RTX 2080 Ti in another Strata server (2,640 prompt tokens, 13.4 s, thinking off). That
server runs other code than this PR's
serve/(the encoder's records reached it as embeddings), so this checks the encoder and the layout, not this PR's server path. The first five seconds weredescribed right (a creature grabbing a scared man, a close-up of the chair's lever, the man on the floor), the
rest partly invented. Asked when the lever close-up appears: "3.0 seconds" (the shot runs 1.65-3.40 s, ffmpeg's
scene detection); the clippers close-up: "7.0" (the shot runs 6.07-7.07 s).
82f46a8, engine 0.1.39), end to end through the server with IQ2_XS on the 5070 Ti and theCPU encoder: on a 10 s clip the revolver placed at 6 s, right; on a 36 s HUD video the first HP change (87 to 41 at
6 s) right, the later four not named. Measurements from that revision:
tools/mtmd/test-3.mp4)(GPU: the encoder built with CUDA 12.8 for sm_120 on the 5070 Ti; at most 448 tokens per pair. A 10-minute
synthetic video with a 2-second banner at 7:13, on an RTX 2080 Ti with IQ3_S: the scene at 7:20 and the banner
right at 64K and at 256K context.)
Failed:
none observed.
Not run:
Limits
their embeddings' hash: a video encoded again with other bits does not match its checkpoints.
STRATA_VISION_VIDEO_S).🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.