Skip to content

Commit 12bdbab

Browse files
yingying0906makaveli10
authored andcommitted
doc(mtmd/qwen3vl): warn image_tile_mode zero-init selects batched, not the default
Addresses PR tetherto#175 review (tetherto#3): the shipped enum is 0=batched while the default mode is sequential, so a zero-initialized clip_context_params/mtmd_context_params silently selects the batched (unverified ne[3]) path instead of the intended default. Renumbering to 0=sequential would be the clean fix, but the values are already released as a string API ("0"/"1"/"2" in consumers), so renumbering would break existing callers. Instead, document the trap prominently in clip.h and mtmd.h and point callers at mtmd_context_params_default() (which sets sequential).
1 parent ffb6ef4 commit 12bdbab

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

tools/mtmd/clip.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,16 @@ enum clip_flash_attn_type {
4646
CLIP_FLASH_ATTN_TYPE_ENABLED = 1,
4747
};
4848

49+
// WARNING: value 0 is BATCHED, which is NOT the default mode (sequential is).
50+
// A zero-initialized clip_context_params/mtmd_context_params (`{}`, memset, calloc)
51+
// therefore selects BATCHED — the one-forward-pass path whose ne[3] batching is not
52+
// yet verified on every backend (see the NOTE in models/qwen3vl.cpp). Do not rely on
53+
// zero-init for the default: initialize via mtmd_context_params_default() (sets
54+
// sequential) or set image_tile_mode explicitly. These values are part of the shipped
55+
// API (string "0"/"1"/"2" in consumers), so they are intentionally not renumbered.
4956
enum clip_image_tile_mode {
50-
CLIP_IMAGE_TILE_MODE_BATCHED = 0,
51-
CLIP_IMAGE_TILE_MODE_SEQUENTIAL = 1,
57+
CLIP_IMAGE_TILE_MODE_BATCHED = 0, // NOT the default; zero-init lands here — see warning above
58+
CLIP_IMAGE_TILE_MODE_SEQUENTIAL = 1, // the default (via mtmd_context_params_default)
5259
CLIP_IMAGE_TILE_MODE_DISABLED = 2,
5360
};
5461

@@ -65,7 +72,7 @@ struct clip_context_params {
6572
mtmd_progress_callback progress_callback;
6673
void * progress_callback_user_data;
6774
const char * backend_device; // optional, if null will use env var or default GPU backend
68-
int image_tile_mode; // 0=batched, 1=sequential (default), 2=disabled
75+
int image_tile_mode; // 0=batched, 1=sequential (default), 2=disabled. NOTE: 0 (batched) is the zero value but NOT the default — init via mtmd_context_params_default() or set explicitly.
6976
int image_max_tiles; // override preproc_max_tiles; -1 = use GGUF/model default
7077
};
7178

tools/mtmd/mtmd.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ struct mtmd_context_params {
114114
void * progress_callback_user_data;
115115
const char * backend_device; // optional GPU backend name (e.g. "CUDA", "Metal", "Vulkan"), if null will use env var or default
116116

117-
// tile encoding mode for multi-tile vision models (Qwen3VL): 0=batched, 1=sequential (default), 2=disabled
117+
// tile encoding mode for multi-tile vision models (Qwen3VL): 0=batched, 1=sequential (default), 2=disabled.
118+
// WARNING: the DEFAULT is sequential, but the ZERO value is 0=batched — so a zero-initialized
119+
// params struct ({}, memset, calloc) selects BATCHED (the ne[3] one-pass path not yet verified on
120+
// all backends), NOT the default. Always initialize via mtmd_context_params_default() (which sets
121+
// sequential) or set image_tile_mode explicitly. Values are fixed API (consumers pass "0"/"1"/"2").
118122
int image_tile_mode;
119123

120124
// override preproc_max_tiles from GGUF; -1 = use model default (4 for Qwen3VL 2B/4B)

0 commit comments

Comments
 (0)