Skip to content

qwen3_vl: per-group timestamped video prompt + t=1 MRoPE planes (3.8-27B video-fidelity 13/13; video gate back on the NVIDIA checkpoint) - #202

Merged
AzeezIsh merged 3 commits into
mainfrom
fix/qwen3vl-video-timestamps
Oct 21, 2026
Merged

AzeezIsh merged 3 commits into
mainfrom
fix/qwen3vl-video-timestamps

Conversation

@AzeezIsh

Copy link
Copy Markdown
Contributor

Summary

The bug: Atlas rendered Qwen3.5/3.6/3.8 video in the Qwen2-VL shape: one <|vision_start|> + all temporal groups' pads + <|vision_end|>, no timestamps, with T = base + g. The checkpoints' own processor does something else:

  • HF Qwen3VLProcessor.replace_video_token emits, per temporal group, <{t:.1f} seconds><|vision_start|> + the group's pads + <|vision_end|>, inside the item's outer start/end pair.
  • Qwen3VLModel.get_rope_index splits video_grid_thw into one t=1 plane per group.
  • Verified tonight by running HF's processor on the gate fixture inside the vLLM container. Output: <|vision_start|> <0.2 seconds><|vision_start|> pad×49 <|vision_end|> … <3.6 seconds><|vision_start|> pad×49 <|vision_end|> <|vision_end|>.

What it cost. On nvidia/Qwen3.8-27B-NVFP4, video-fidelity mixed-media (a gray still, then a 4-colour clip) read red, blue, yellow (green missing) on every build, GIF and MP4 alike. That one-colour miss is why the gate's subject was moved to the unsloth 3.6-27B pack on 2026-08-15. Same request, same box (sparky, GB10):

server clip alone image + clip mixed-media answer
Atlas main (e29809db9) 240 tok 286 tok red, blue, yellow (×4, GIF and MP4)
vLLM (eugr/spark-vllm-b12x, model-card flags) 272 tok 333 tok red, green, blue, yellow (×4)
Atlas + this PR 272 tok 318 tok red, green, blue, yellow (×4)

The remaining 15 tokens are the still image. HF's shortest_edge minimum upscales the 224 px gray still to 256 px (64 tokens; Atlas uses 49). That's a separate image-side difference, not touched here.

Changes:

  • Gate: the checkpoint's video_preprocessor_config.json / preprocessor_config.json / processor_config.json (video_processor_type: Qwen3VLVideoProcessor or processor_class: Qwen3VLProcessor), read at serve time. No new flag. Other families are untouched; GLM-5's per-frame path is unchanged and its tests are green.
  • Prompt (tokenizer/chat_impl/qwen3vl_vision.rs): nested per-group expansion with HF-rule timestamps. Each group's time is the mean of its first and last kept frame's source time, {:.1}. Images expand exactly as before.
  • MRoPE (prefill_b/mrope_pos.rs::build_qwen3vl): each group is a t=1 plane (T = base, H/W = base + row/col, advance max(gh, gw)). Timestamp and marker tokens are text positions. Built over the full prompt and sliced per chunk, like GLM-5, so a chunk boundary between groups is safe. The stale "matches Qwen3-VL" claim on the Qwen2-VL build is corrected.
  • Splice: already maps the k-th pad to the k-th encoder row by global pad count; verified, unchanged.
  • Benchmark (atlas-plugin video geometry::check_proportional):
    • The premise: the leg's own docs say pass/fail does not depend on plane, but it required (t2 − t1) % plane == 0. That premise ("one group = plane tokens") only holds for flat formats; a Qwen3-VL group costs plane + 8 (timestamp + inner marker pair).
    • The change: it now takes the smallest per-group text k in 0..=16, so legacy formats resolve at k=0 exactly as before, and the 30-token non-multiple case is still refused. Linearity (t4 − t2 == 2·(t2 − t1)) and the overhead consistency check are unchanged.
  • Gate policy (second commit, BENCH.toml only, outside the closure hash):
    • video-fidelity's required subject goes back to nvidia/Qwen3.8-27B-NVFP4. unsloth/Qwen3.6-27B-NVFP4 becomes a non-default measured record.
    • The two never-measured unsloth declarations, dense concurrency-sweep (which was default = true) and agentic-webserver, are removed. Both gates' dense halves are measured on the NVIDIA 27B.
    • Thresholds unchanged.

Evidence

sparky, 2026-10-21, this branch (binary 0be1bf12f1c3a1a1):

  • video-fidelity --pull-request-gate --checkpoint nvidia/Qwen3.8-27B-NVFP4: PASS 13/13, run-1792578413095376992.
    • group-proportionality: 1s=75, 2s=132, 4s=246 → 1/2/4 groups at 49+8 tok/group, overhead 18.
    • MP4/GIF parity at 246; mixed 318; two-videos 501; video-before-image 320; video-in-history 285.
    • Reversed clip read Yellow, Blue, Green, Red.
  • video-fidelity --pull-request-gate --checkpoint Qwen/Qwen3.6-35B-A3B-FP8: PASS 13/13, run-1792578198608303669.
  • Non-gate video-fidelity against a manual serve of 3.8-27B with its recipe flags: PASS 13/13.
  • Not run here: the old default subject (unsloth/Qwen3.6-27B-NVFP4), which is not on this box.

Supporting experiments from the same session, same request:

  • Speculation off changed nothing.
  • Keeping the checkpoint's FP8 attention as exact BF16 (Atlas requantizes it to NVFP4 today) flipped the GIF case to 4/4 but the MP4 case got worse (red, blue). Attention precision moves an edge case both ways; the prompt format is the structural difference.

Test plan

  • Unit tests: mrope_pos 17/17 (new Qwen3-VL two-group, image-is-t1, chunk-boundary cases), qwen3vl_vision 3/3, GLM-5 14/14, atlas-plugin video 44/44 (new Qwen3-VL proportionality + k>16 refusal), atlas-plugin gate 225/225
  • cargo fmt --all -- --check (1.93.1), cargo clippy -p spark-server -p spark-model -p atlas-plugin --tests
  • video-fidelity on the NVIDIA 3.8-27B and the 35B FP8 (gate), plus a manual 3.8 serve (above)
  • Required-gate campaign at the final tip (the change touches prefill MRoPE and the request path)

Generated with Devin

AzeezIsh and others added 3 commits October 21, 2026 06:07
…its own MRoPE plane

HF's Qwen3VLProcessor replaces the video's compact
vision_start/pad/vision_end triple with timestamp text + an inner
start/pads/end per temporal group, and get_rope_index splits
video_grid_thw into t=1 planes per group. Atlas emitted a flat pad run
with one T-per-group video plane, which dropped per-group ordering
information the model uses — the video-fidelity mixed-media leg lost a
colour (red, blue, yellow on Atlas; 4/4 through vLLM).

- PreprocessedVideo.timestamps_hf: HF's mean-of-first/last-frame rule
  per group (GLM's floor timestamps untouched).
- expand_qwen3vl_vision_placeholders: the nested expansion, images
  unchanged.
- mrope_pos::build_qwen3vl: every contiguous pad run is a t=1 plane;
  boundary/timestamp tokens are text positions. Dispatch on
  is_qwen3vl_video, resolved from the checkpoint's preprocessor config.
- Fixes the stale Qwen2-VL doc on mrope_pos::build.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…the unmeasured unsloth declarations

With the Qwen3-VL reference video prompt, the NVIDIA 3.8-27B passes video-fidelity 13/13 under its own gate recipe
(run-1792578413095376992), so it takes the gate's required subject back from the unsloth 3.6-27B pack, which stood in
for it only because Atlas's flat video prompt made 3.8 look one colour short. The unsloth video entry stays as a
non-default measured record. The two never-measured unsloth declarations (dense concurrency-sweep, default=true, and
agentic-webserver) are removed: the dense halves of both gates are measured on the NVIDIA 3.8-27B. Thresholds unchanged;
BENCH.toml is outside the closure hash.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The Qwen3-VL timestamp work pushed the file past CI's cap. The timestamp
rules (GLM floor, HF mean) live in timestamps.rs, the payload type and
frame-index arithmetic in types.rs. Behaviour unchanged.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@AzeezIsh
AzeezIsh merged commit 2ffe063 into main Oct 21, 2026
20 of 23 checks passed
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
…video bounds

Port of Enntity/atlas 6f3d0a7 + 95d20a2 + 170540e + 0eef403
(AGPL-3.0-only), on top of #202's already-landed expansion machinery.

- decode_with_plan returns each emitted frame's real PTS from ffmpeg's
  showinfo instead of the plan's assumed positions — identical on CFR,
  materially different on VFR.
- The decoded scale bounds by pixel AREA, not per-side (a 1xN strip has a
  huge side inside any per-side bound).
- read_declared_pixels reads both bounds of one modality from whichever
  processor file declares the max: image min_pixels beside longest_edge,
  video_processor's from video_preprocessor_config.json or
  processor_config.json [video_processor]. Startup installs them on
  VisionConfig (min_pixels, video_pixels) next to max_pixels; the
  operator's --vision-max-pixels still overrides the image max only.

#202 already covered: the per-group timestamp expansion machinery
(qwen3vl_vision.rs), QwenVisionPlaceholder.timestamps, the explicit
timestamp sample plan, and the decode_frames/decode_with_plan shape.

Their tests ported where our surface matches (the frames.rs-dependent
cases are Enntity's separate refactor and stay out).
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
…video bounds

Port of Enntity/atlas 6f3d0a7 + 95d20a2 + 170540e + 0eef403
(AGPL-3.0-only), on top of #202's already-landed expansion machinery.

- decode_with_plan returns each emitted frame's real PTS from ffmpeg's
  showinfo instead of the plan's assumed positions — identical on CFR,
  materially different on VFR.
- The decoded scale bounds by pixel AREA, not per-side (a 1xN strip has a
  huge side inside any per-side bound).
- read_declared_pixels reads both bounds of one modality from whichever
  processor file declares the max: image min_pixels beside longest_edge,
  video_processor's from video_preprocessor_config.json or
  processor_config.json [video_processor]. Startup installs them on
  VisionConfig (min_pixels, video_pixels) next to max_pixels; the
  operator's --vision-max-pixels still overrides the image max only.

#202 already covered: the per-group timestamp expansion machinery
(qwen3vl_vision.rs), QwenVisionPlaceholder.timestamps, the explicit
timestamp sample plan, and the decode_frames/decode_with_plan shape.

Their tests ported where our surface matches (the frames.rs-dependent
cases are Enntity's separate refactor and stay out).
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
…video bounds

Port of Enntity/atlas 6f3d0a7 + 95d20a2 + 170540e + 0eef403
(AGPL-3.0-only), on top of #202's already-landed expansion machinery.

- decode_with_plan returns each emitted frame's real PTS from ffmpeg's
  showinfo instead of the plan's assumed positions — identical on CFR,
  materially different on VFR.
- The decoded scale bounds by pixel AREA, not per-side (a 1xN strip has a
  huge side inside any per-side bound).
- read_declared_pixels reads both bounds of one modality from whichever
  processor file declares the max: image min_pixels beside longest_edge,
  video_processor's from video_preprocessor_config.json or
  processor_config.json [video_processor]. Startup installs them on
  VisionConfig (min_pixels, video_pixels) next to max_pixels; the
  operator's --vision-max-pixels still overrides the image max only.

#202 already covered: the per-group timestamp expansion machinery
(qwen3vl_vision.rs), QwenVisionPlaceholder.timestamps, the explicit
timestamp sample plan, and the decode_frames/decode_with_plan shape.

Their tests ported where our surface matches (the frames.rs-dependent
cases are Enntity's separate refactor and stay out).
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
…video bounds

Port of Enntity/atlas 6f3d0a7 + 95d20a2 + 170540e + 0eef403
(AGPL-3.0-only), on top of #202's already-landed expansion machinery.

- decode_with_plan returns each emitted frame's real PTS from ffmpeg's
  showinfo instead of the plan's assumed positions — identical on CFR,
  materially different on VFR.
- The decoded scale bounds by pixel AREA, not per-side (a 1xN strip has a
  huge side inside any per-side bound).
- read_declared_pixels reads both bounds of one modality from whichever
  processor file declares the max: image min_pixels beside longest_edge,
  video_processor's from video_preprocessor_config.json or
  processor_config.json [video_processor]. Startup installs them on
  VisionConfig (min_pixels, video_pixels) next to max_pixels; the
  operator's --vision-max-pixels still overrides the image max only.

#202 already covered: the per-group timestamp expansion machinery
(qwen3vl_vision.rs), QwenVisionPlaceholder.timestamps, the explicit
timestamp sample plan, and the decode_frames/decode_with_plan shape.

Their tests ported where our surface matches (the frames.rs-dependent
cases are Enntity's separate refactor and stay out).
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
…video bounds

Port of Enntity/atlas 6f3d0a7 + 95d20a2 + 170540e + 0eef403
(AGPL-3.0-only), on top of #202's already-landed expansion machinery.

- decode_with_plan returns each emitted frame's real PTS from ffmpeg's
  showinfo instead of the plan's assumed positions — identical on CFR,
  materially different on VFR.
- The decoded scale bounds by pixel AREA, not per-side (a 1xN strip has a
  huge side inside any per-side bound).
- read_declared_pixels reads both bounds of one modality from whichever
  processor file declares the max: image min_pixels beside longest_edge,
  video_processor's from video_preprocessor_config.json or
  processor_config.json [video_processor]. Startup installs them on
  VisionConfig (min_pixels, video_pixels) next to max_pixels; the
  operator's --vision-max-pixels still overrides the image max only.

#202 already covered: the per-group timestamp expansion machinery
(qwen3vl_vision.rs), QwenVisionPlaceholder.timestamps, the explicit
timestamp sample plan, and the decode_frames/decode_with_plan shape.

Their tests ported where our surface matches (the frames.rs-dependent
cases are Enntity's separate refactor and stay out).
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
…video bounds

Port of Enntity/atlas 6f3d0a7 + 95d20a2 + 170540e + 0eef403
(AGPL-3.0-only), on top of #202's already-landed expansion machinery.

- decode_with_plan returns each emitted frame's real PTS from ffmpeg's
  showinfo instead of the plan's assumed positions — identical on CFR,
  materially different on VFR.
- The decoded scale bounds by pixel AREA, not per-side (a 1xN strip has a
  huge side inside any per-side bound).
- read_declared_pixels reads both bounds of one modality from whichever
  processor file declares the max: image min_pixels beside longest_edge,
  video_processor's from video_preprocessor_config.json or
  processor_config.json [video_processor]. Startup installs them on
  VisionConfig (min_pixels, video_pixels) next to max_pixels; the
  operator's --vision-max-pixels still overrides the image max only.

#202 already covered: the per-group timestamp expansion machinery
(qwen3vl_vision.rs), QwenVisionPlaceholder.timestamps, the explicit
timestamp sample plan, and the decode_frames/decode_with_plan shape.

Their tests ported where our surface matches (the frames.rs-dependent
cases are Enntity's separate refactor and stay out).
AzeezIsh added a commit that referenced this pull request Oct 29, 2026
…video bounds

Port of Enntity/atlas 6f3d0a7 + 95d20a2 + 170540e + 0eef403
(AGPL-3.0-only), on top of #202's already-landed expansion machinery.

- decode_with_plan returns each emitted frame's real PTS from ffmpeg's
  showinfo instead of the plan's assumed positions — identical on CFR,
  materially different on VFR.
- The decoded scale bounds by pixel AREA, not per-side (a 1xN strip has a
  huge side inside any per-side bound).
- read_declared_pixels reads both bounds of one modality from whichever
  processor file declares the max: image min_pixels beside longest_edge,
  video_processor's from video_preprocessor_config.json or
  processor_config.json [video_processor]. Startup installs them on
  VisionConfig (min_pixels, video_pixels) next to max_pixels; the
  operator's --vision-max-pixels still overrides the image max only.

#202 already covered: the per-group timestamp expansion machinery
(qwen3vl_vision.rs), QwenVisionPlaceholder.timestamps, the explicit
timestamp sample plan, and the decode_frames/decode_with_plan shape.

Their tests ported where our surface matches (the frames.rs-dependent
cases are Enntity's separate refactor and stay out).
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.

1 participant