Skip to content

[Fix] glm4v: Clamp request video budgets to the deployment limit - #43871

Merged
ShangmingCai merged 7 commits into
sgl-project:mainfrom
cipheraxat:fix/glm-v-video-budget
Oct 18, 2026
Merged

ShangmingCai merged 7 commits into
sgl-project:mainfrom
cipheraxat:fix/glm-v-video-budget

Conversation

@cipheraxat

@cipheraxat cipheraxat commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Fixes #43705.

GLM-V video requests could raise fps, max_frames, max_tokens_per_frame, and max_image_tokens above the deployment budget before frames were decoded. A large request could then make the worker decode far more frames, at higher resolution, than the default config allows.

Modifications

  • Clamp each request knob to the deployment limit, so a request can only tighten the budget. Omitted knobs stay unset, so an fps-only request does not inject max_frames and bypass the HF sampler.
  • The max_frames limit comes from the processor's max_frames, or from --mm-process-config. GLM-4.1V/4.5V/4.6V processors have no max_frames; their HF sampler stops at max_duration * fps (600 by default), so that value is the limit there. It follows a server fps override.
    • Note: GLM-4.6V's own HF sampler allows up to 640 frames, so a request asking for 601-640 frames now gets 600. This is deliberate: the limit stays at or below what the default config samples.
  • At decode time, drop a request max_tokens_per_frame when its total pixels (cap * 28^2 * frame_count) exceed the shared presize budget. The frames then go through the shared presize path. A server-configured per-frame cap keeps per-frame mode.
  • On the DP encoder path, make that decision with the full clip length, so every shard picks the same resizer.
  • Reject non-positive, non-numeric, and non-finite values. ChatCompletionMessageContentVideoURL now declares gt=0 (and allow_inf_nan=False for fps), so OpenAI-path requests get a 400 before batching. The processor keeps the same check for the native /generate path.
  • Log a one-time warning when a request value is clamped.
  • Docs: multimodal_language_models.mdx now says GLM-V request knobs can only tighten the budget, and operators raise the limits with --mm-process-config.

Accuracy Tests

No model-forward or kernel change. Tests in test/registered/unit/multimodal/test_glm4v_mixed_offsets.py build budgets with the real glm_processor_video_config. They cover:

  • per-knob clamps, including the server-raised limit and the GLM-4.xV max_duration * fps limit;
  • a 1-hour clip where a request can no longer sample more frames than the default HF sampler;
  • the pixel-based per-frame drop and the DP full-clip count;
  • the server per-frame mode;
  • rejected values at both the processor and the API schema.

The GLM-4.xV frame-limit, per-frame pixel, and schema tests fail on the previous head and pass now.

Speed Tests and Profiling

No inference-speed change. The clamp bounds decode work that a request could otherwise raise.

Checklist

Accuracy and speed benchmarks do not apply because this does not change model outputs or kernels.

🤖 Generated with Claude Code


CI States

Latest PR Test (Base): ✅ Run #39040010390
Latest PR Test (Extra): ❌ Run #39040010177
Latest PR Test (AMD ROCm 10): ❌ Run #39040010354

Request fps, max_frames, max_tokens_per_frame, and max_image_tokens could
raise the processor budget before frames were decoded.

Fixes sgl-project#43705
…dget

A cap clamped to the token ceiling still skipped presize and applied that
ceiling to every frame. Drop it at decode time when the product exceeds
the shared budget, and use the full clip length on a DP shard.

Fixes sgl-project#43705
cipheraxat and others added 2 commits October 12, 2026 22:12
…per-frame caps in pixels

GLM-4.1V/4.6V processors have no max_frames, so a request max_frames was
clamped to 2048 while the HF sampler stops at max_duration * fps (600).
Use that as the ceiling.

The per-frame drop compared tokens counted at 784 px against a presize
budget counted at 1568 px, so caps that fit were dropped. Compare pixels.

Reject non-positive and non-finite video_url knobs in the OpenAI schema,
warn once when a request value is clamped, and document that request
values can only tighten the deployment budget.

Fixes sgl-project#43705

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added documentation Improvements or additions to documentation Multi-modal multi-modal language model labels Oct 14, 2026
@cipheraxat cipheraxat changed the title fix(glm): clamp request video budgets to the deployment ceiling [Fix] glm4v: Clamp request video budgets to the deployment limit Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for this part.

@ShangmingCai

Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Oct 17, 2026
@ShangmingCai
ShangmingCai merged commit 5a930cf into sgl-project:main Oct 18, 2026
166 of 177 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation Multi-modal multi-modal language model run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Request-controlled GLM-V video budgets can bypass deployment limits before decoding

2 participants