You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: KV estimator over-sizes Gemma 3 when text_config omits head fields #1980
Found while validating PR #1978. attn_dims in src/execution/kv_arch.rs:148 falls back to head_dim = hidden_size / num_heads and num_kv_heads = num_heads (with num_heads defaulting to 1) when a config omits the head fields. Gemma 3 text_config often omits num_attention_heads, num_key_value_heads, head_dim, and sliding_window_pattern: gemma-3-4b-it-4bit carries only hidden_size 2560, intermediate_size 10240, num_hidden_layers 34, sliding_window 1024. HF Gemma3TextConfig defaults are num_attention_heads 8, num_key_value_heads 4, head_dim 256, sliding_window_pattern 6.
Measured: the real snapshot is about 139 KB/token while the estimate is about 348 KB/token (about 2.6x). The model-aware prompt-cache store default added in #1978 (15.9 GiB on GB10), estimate_total_memory, and mlxcel inspect all overstate for this family.
Fix
In classify / attn_dims, apply the Gemma 3 config defaults for model_typegemma3 and gemma3_text (checking both text_config and the top-level model_type, as kv_arch.rs:519 already does) when the fields are absent. Explicit config values keep priority. Other families are unchanged.
Acceptance Criteria
Unit test in kv_arch.rs using the real 4B text_config shape asserts 34 x 2 x 4 x 256 x 2 bytes per token for bf16 (fails on current code).
Existing kv_arch.rs tests pass unchanged.
On the real gemma-3-4b-it-4bit checkpoint, the startup line "Applied model-aware prompt-cache snapshot capacity default" reports the corrected figure; record it in the PR.
Activity
fix: apply HF Gemma 3 head-field defaults in the KV estimator (lablup…