Commit d91a8b2
fix(gemma4): PLE buffer overrun broke Gemma 4 E4B
The per-layer embedding (PLE) stack buffers were sized 8960 floats,
matching E2B exactly (35 layers × 256 ple_dim). E4B has 42 layers,
requiring 10752 elements — a 1792-float stack overrun that caused
the forward pass to hang indefinitely (stack corruption triggering
infinite loop somewhere downstream).
Fixed in both src/engine/tq_transformer.c and quant.h:
- temp_embd and temp_proj buffers bumped to 16384 floats
- Added safety guard for total_ple > 16384
Before: E4B Q8_0 prompt=5 tokens generates 0 tokens in 15 minutes
(stuck in stack-corruption-induced hang)
After: E4B Q8_0 generates "4. This is a mathematical fact."
E4B Q4_0 generates "4。请问,您能用更"
All 35 unit tests pass, all 7 model regression tests pass.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 5bf3e8e commit d91a8b2
2 files changed
Lines changed: 12 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15481 | 15481 | | |
15482 | 15482 | | |
15483 | 15483 | | |
15484 | | - | |
| 15484 | + | |
15485 | 15485 | | |
15486 | 15486 | | |
15487 | | - | |
| 15487 | + | |
| 15488 | + | |
15488 | 15489 | | |
15489 | 15490 | | |
15490 | 15491 | | |
| |||
15500 | 15501 | | |
15501 | 15502 | | |
15502 | 15503 | | |
15503 | | - | |
| 15504 | + | |
15504 | 15505 | | |
15505 | 15506 | | |
15506 | 15507 | | |
15507 | | - | |
| 15508 | + | |
15508 | 15509 | | |
15509 | 15510 | | |
15510 | 15511 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2342 | 2342 | | |
2343 | 2343 | | |
2344 | 2344 | | |
2345 | | - | |
| 2345 | + | |
2346 | 2346 | | |
2347 | 2347 | | |
2348 | 2348 | | |
2349 | 2349 | | |
2350 | 2350 | | |
2351 | 2351 | | |
2352 | | - | |
| 2352 | + | |
2353 | 2353 | | |
2354 | 2354 | | |
2355 | | - | |
| 2355 | + | |
| 2356 | + | |
2356 | 2357 | | |
2357 | 2358 | | |
2358 | 2359 | | |
| |||
2368 | 2369 | | |
2369 | 2370 | | |
2370 | 2371 | | |
2371 | | - | |
2372 | | - | |
| 2372 | + | |
| 2373 | + | |
2373 | 2374 | | |
2374 | 2375 | | |
2375 | | - | |
| 2376 | + | |
2376 | 2377 | | |
2377 | 2378 | | |
2378 | 2379 | | |
| |||
0 commit comments