Commit dac9c8f
fix(gemma4): partial fixes + diagnostic findings for E2B support
Fixed in quant.h:
- RoPE: remove incorrect /2 on rope_n_dims_full for Gemma 4
(split-source doesn't halve; quant.h was divergent)
- Attention softcap: exclude Gemma 4 from hardcoded 50.0
(Gemma 4 config has no attn_logit_softcapping)
Fixed in unified server:
- Chat template: add Gemma format (<start_of_turn>user/model)
with auto-detection from model filename
- Template token filtering: add <start_of_turn>, <end_of_turn>, <eos>
- 3-way template: ChatML / Phi-3 / Gemma
STILL BROKEN — Gemma 4 E2B produces garbage on ALL builds:
Root cause analysis:
1. NOT Metal (TQ_NO_METAL still garbage)
2. NOT Q4 conversion (TQ_NO_Q4 still garbage)
3. NOT chat template (CLI uses correct <start_of_turn> template)
4. Likely candidates:
a. KV cache sharing (num_kv_shared_layers=20) not implemented
b. Hybrid attention Q dim (8×512=4096) > hidden_dim (1536)
requires upscaling projection that may not exist
c. Proportional RoPE (partial_rotary_factor=0.25) for full
layers may interact incorrectly with rope_n_dims_full=512
HuggingFace config reference (google/gemma-4-E2B-it):
hidden_act: gelu_pytorch_tanh
hidden_size: 1536, global_head_dim: 512, head_dim: 256
sliding_window: 512, num_kv_shared_layers: 20
rope_theta: 1000000 (full), 10000 (sliding)
partial_rotary_factor: 0.25 (full layers only)
final_logit_softcapping: 30.0
attn_logit_softcapping: NOT present (=0)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent c1ddf13 commit dac9c8f
2 files changed
Lines changed: 123 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8364 | 8364 | | |
8365 | 8365 | | |
8366 | 8366 | | |
| 8367 | + | |
| 8368 | + | |
| 8369 | + | |
| 8370 | + | |
| 8371 | + | |
| 8372 | + | |
| 8373 | + | |
| 8374 | + | |
| 8375 | + | |
| 8376 | + | |
| 8377 | + | |
| 8378 | + | |
| 8379 | + | |
| 8380 | + | |
| 8381 | + | |
| 8382 | + | |
| 8383 | + | |
| 8384 | + | |
| 8385 | + | |
| 8386 | + | |
| 8387 | + | |
| 8388 | + | |
| 8389 | + | |
| 8390 | + | |
| 8391 | + | |
| 8392 | + | |
| 8393 | + | |
| 8394 | + | |
| 8395 | + | |
| 8396 | + | |
| 8397 | + | |
| 8398 | + | |
| 8399 | + | |
| 8400 | + | |
| 8401 | + | |
| 8402 | + | |
| 8403 | + | |
| 8404 | + | |
| 8405 | + | |
| 8406 | + | |
| 8407 | + | |
| 8408 | + | |
| 8409 | + | |
| 8410 | + | |
| 8411 | + | |
| 8412 | + | |
| 8413 | + | |
| 8414 | + | |
| 8415 | + | |
| 8416 | + | |
| 8417 | + | |
| 8418 | + | |
| 8419 | + | |
| 8420 | + | |
| 8421 | + | |
| 8422 | + | |
| 8423 | + | |
| 8424 | + | |
| 8425 | + | |
| 8426 | + | |
| 8427 | + | |
| 8428 | + | |
| 8429 | + | |
| 8430 | + | |
| 8431 | + | |
| 8432 | + | |
| 8433 | + | |
| 8434 | + | |
8367 | 8435 | | |
8368 | 8436 | | |
8369 | 8437 | | |
| |||
11394 | 11462 | | |
11395 | 11463 | | |
11396 | 11464 | | |
11397 | | - | |
11398 | | - | |
| 11465 | + | |
| 11466 | + | |
| 11467 | + | |
11399 | 11468 | | |
11400 | 11469 | | |
11401 | 11470 | | |
| |||
11449 | 11518 | | |
11450 | 11519 | | |
11451 | 11520 | | |
11452 | | - | |
| 11521 | + | |
11453 | 11522 | | |
11454 | | - | |
11455 | | - | |
| 11523 | + | |
| 11524 | + | |
| 11525 | + | |
| 11526 | + | |
| 11527 | + | |
| 11528 | + | |
| 11529 | + | |
11456 | 11530 | | |
11457 | 11531 | | |
11458 | 11532 | | |
| |||
11517 | 11591 | | |
11518 | 11592 | | |
11519 | 11593 | | |
11520 | | - | |
11521 | | - | |
11522 | | - | |
11523 | | - | |
| 11594 | + | |
| 11595 | + | |
| 11596 | + | |
11524 | 11597 | | |
11525 | | - | |
| 11598 | + | |
11526 | 11599 | | |
11527 | 11600 | | |
11528 | 11601 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
50 | 56 | | |
51 | | - | |
| 57 | + | |
52 | 58 | | |
53 | 59 | | |
54 | 60 | | |
| |||
61 | 67 | | |
62 | 68 | | |
63 | 69 | | |
64 | | - | |
| 70 | + | |
65 | 71 | | |
66 | 72 | | |
67 | 73 | | |
68 | 74 | | |
69 | 75 | | |
70 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
71 | 85 | | |
| 86 | + | |
72 | 87 | | |
73 | 88 | | |
74 | 89 | | |
75 | 90 | | |
76 | | - | |
| 91 | + | |
77 | 92 | | |
| 93 | + | |
| 94 | + | |
78 | 95 | | |
79 | 96 | | |
80 | 97 | | |
| |||
223 | 240 | | |
224 | 241 | | |
225 | 242 | | |
226 | | - | |
| 243 | + | |
227 | 244 | | |
228 | 245 | | |
229 | 246 | | |
230 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
231 | 250 | | |
232 | 251 | | |
233 | 252 | | |
| |||
257 | 276 | | |
258 | 277 | | |
259 | 278 | | |
260 | | - | |
| 279 | + | |
261 | 280 | | |
262 | 281 | | |
263 | 282 | | |
264 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
265 | 286 | | |
266 | 287 | | |
267 | 288 | | |
| |||
364 | 385 | | |
365 | 386 | | |
366 | 387 | | |
367 | | - | |
| 388 | + | |
368 | 389 | | |
369 | 390 | | |
370 | 391 | | |
| |||
546 | 567 | | |
547 | 568 | | |
548 | 569 | | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
553 | 573 | | |
554 | 574 | | |
555 | 575 | | |
556 | 576 | | |
557 | | - | |
| 577 | + | |
558 | 578 | | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
559 | 582 | | |
| 583 | + | |
560 | 584 | | |
561 | 585 | | |
562 | 586 | | |
| |||
570 | 594 | | |
571 | 595 | | |
572 | 596 | | |
| 597 | + | |
573 | 598 | | |
574 | 599 | | |
575 | 600 | | |
| |||
603 | 628 | | |
604 | 629 | | |
605 | 630 | | |
606 | | - | |
| 631 | + | |
| 632 | + | |
607 | 633 | | |
608 | 634 | | |
609 | 635 | | |
| |||
0 commit comments