Archived
A fourth processor family beside Qwen-VL, Gemma 4 and LFM2-VL, chosen by vision_config.model_type
glm5_next_vision, as transformers' Glm5NextImageProcessor (torchvision backend) computes it:
- The canvas: both sides rounded up to patch * merge (28), grown by the area ratio under
min_image_tokens, and fitted by the reference's binary search over the picture's height past
max_image_tokens, a token being two frames of 28 x 28 pixels.
- The picture keeps its aspect ratio, is never enlarged while it reaches the floor, is resized
with torchvision's fixed-point bicubic only when its size changes, and sits in the top left of a
canvas of zero bytes, which the normalisation turns into each channel's -mean / std as it does
the reference's padding. Patches as Qwen-VL's (merge-block order, (channel, frame, y, x), the
picture in both frames, CLIP's mean and deviation from processor_config.json).
- <|begin_of_image|>, one <|image|> a token, <|end_of_image|>; the tokens rotate at their
positions (the language model has no rotary). Pictures only.
The budget is in tokens and comes from processor.image_processor.{min,max}_image_tokens; one
encoder pass bounds it, so it is lowered to max_patches / merge^2, as a Qwen-VL pixel band is
(4096 tokens at --mm-max-patches auto, the checkpoint's 8000 at 32000). --image-tokens sets the
ceiling; the pixel-band and video flags, a request's image_tokens and a video are refused by name.
tests/mkglm5golden.py writes glm5_golden.h from Glm5NextProcessor; mm_test checks canvases over a
grid of sizes and both budgets, and whole pictures (padded only, grown under the floor, shrunk to
a budget) patch for patch and token for token, all bit-exact, and the processor read from a
container's keys.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>