Expand description
2026-09-25: The GLM-5.3-Flash vision tower: ViT blocks with per-head QK-RMSNorm, 2D axial RoPE and clamped SwiGLU, then a 2×2 strided-conv downsample and a SwiGLU merger.
A separate type from super::VisionEncoder (the Qwen3-VL tower), with
its own kernel module (glm_vit); both use the gemm module’s
dense_gemm_bf16_pipelined and dense_gemm_bf16_f32out. Callers reach
either through super::VisionTower, which gives both the same
forward_batched result and out_row contract.
Owner: model-layers (vision). Invariants:
- Assumes every weight pointer is a BF16 tensor.
GlmVit::newdoes not check; the loader (load_glm5_next_vision) refuses other dtypes. - The scratch is set at most once, for
p_maxpatch rows.
Re-exports§
pub use init::GlmVitGeometry;
Modules§
- init
- 2026-09-25:
GlmVit::newand the device scratch allocated on first use.
Structs§
- GlmVit
- GlmVit
Block - 2026-09-25: One ViT block’s BF16 weights.
- GlmVit
Merger - 2026-09-25: Everything after the last block: the post-norm, the 2×2 conv
downsample and the merger MLP whose output fills
buf_out. - GlmVit
Scratch - 2026-09-25: Device scratch, allocated by
scratch_initon first use rather than at load.buf_scoresandbuf_probsholdp_max²elements.
Functions§
- block_
major_ position_ ids - 2026-09-25: Per-token
(h_id, w_id)in block-major order: the outer loops walk themerge × mergeblocks in raster order, the inner loops the positions inside a block. This is the ordervision_preprocess_glm::block_major_patch_indexgives the pixel patches. - build_
axial_ rope_ tables - 2026-09-25:
(cos, sin)tables of[num_tokens, head_dim]f32, in the layoutglm_vit_qknorm_rope_deintreads.