Commit 886a470
fix(gemma4): correct chat template + layer_output_scale revert
Chat template (CRITICAL discovery):
- Gemma 4 uses <|turn>/<turn|> tokens, NOT <start_of_turn>/<end_of_turn>
- System prompt requires <|think|> for thinking mode
- Reference: llama.cpp apply-template confirms the correct format
- Updated unified server and CLI templates
layer_output_scale:
- Reverted "x *= los" back to residual-separation formula
- "x *= los" with los=0.0178 destroys the residual signal
- Correct: x = x_input + los * (x_current - x_input)
llama.cpp reference test:
- llama.cpp produces "Four" (correct) for "What is 2+2?"
- GGUF file is VALID — our forward pass has a remaining bug
- Both our builds (split-source and quant.h) produce garbage
- Template fix alone doesn't resolve it
Status: forward pass still produces garbage despite correct template.
The bug is in the transformer computation itself, not in tokenization
or chat formatting. Layer-by-layer numeric comparison with llama.cpp
is the next step.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent a86a837 commit 886a470
2 files changed
Lines changed: 29 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1241 | 1241 | | |
1242 | 1242 | | |
1243 | 1243 | | |
1244 | | - | |
1245 | | - | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
1246 | 1251 | | |
1247 | 1252 | | |
1248 | 1253 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
67 | 78 | | |
68 | 79 | | |
69 | 80 | | |
| |||
75 | 86 | | |
76 | 87 | | |
77 | 88 | | |
78 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
79 | 92 | | |
80 | | - | |
| 93 | + | |
81 | 94 | | |
82 | | - | |
| 95 | + | |
83 | 96 | | |
84 | | - | |
| 97 | + | |
85 | 98 | | |
86 | 99 | | |
87 | 100 | | |
| |||
91 | 104 | | |
92 | 105 | | |
93 | 106 | | |
94 | | - | |
| 107 | + | |
95 | 108 | | |
96 | 109 | | |
97 | 110 | | |
| |||
246 | 259 | | |
247 | 260 | | |
248 | 261 | | |
| 262 | + | |
| 263 | + | |
249 | 264 | | |
250 | 265 | | |
251 | 266 | | |
| |||
282 | 297 | | |
283 | 298 | | |
284 | 299 | | |
| 300 | + | |
| 301 | + | |
285 | 302 | | |
286 | 303 | | |
287 | 304 | | |
| |||
0 commit comments