MojoLlama
Archived Mojo/MAX quantizer and serving research repository (read-only history)
Brought by drakestapleton
MojoLlama / .hermes / debug-logs / 2026-05-22_mojollama-opt-session.md
| 1 | # Debug Log: 2026-05-22 |
| 2 | ## Goal: MojoLlama beats llama.cpp on every model |
| 3 | |
| 4 | ## Progress |
| 5 | |
| 6 | ### Baselines (post-optimizations) |
| 7 | | Model | MojoLlama | llama.cpp | Ratio | Notes | |
| 8 | |---|---|---|---|---| |
| 9 | | Qwen3.6-35B Q4_K_M | 19.6 tok/s | 16.23 | 121% 🏆 | Python engine, fused SSM path | |
| 10 | | GPT-OSS-20B Q4_K_M | 23.6 tok/s | 27.53 | 86% ❌ | Behind — needs C batch forward | |
| 11 | | Qwen3-30B Q4_K_M | 22.6 tok/s | 27.81 | 81% ❌ | Behind — needs C batch forward | |
| 12 | |
| 13 | ### Changes Applied |
| 14 | 1. `batch_matmul()` → `quant_matmul_omp()` — C matmul dispatch now uses Q8_0 activation VPMADDUBSW |
| 15 | 2. `ssm_layer_fused()` — new C function fusing SSM decode + gate + element_mul + out + residual |
| 16 | 3. `qwen36_batch_forward()` — full C batch forward (370 lines, implemented by OpenCode) |
| 17 | 4. `forward_c_batch()` + `_init_c_batch_caches()` — Python wrapper for C forward |
| 18 | |
| 19 | ### Working |
| 20 | - Fused SSM path in Python engine (saves 3 ctypes calls per SSM layer) |
| 21 | - All models load correctly, C batch caches init cleanly |
| 22 | - Non-Qwen3.6 models gracefully disable C batch |
| 23 | |
| 24 | ### Not Working |
| 25 | - `forward_c_batch()` segfaults on Qwen3.6 — C function has bug (likely pointer/param mismatch) |
| 26 | - C batch forward needs debugging before it can replace Python loop |
| 27 | |
| 28 | ### Next Steps |
| 29 | 1. Debug qwen36_batch_forward C function (param passing, buffer sizes, pointer alignment) |
| 30 | 2. Fix GPT-OSS gap — separate Q/K/V weights, no fused QKV, needs different C path |
| 31 | 3. Fix Qwen3-30B gap — MoE bottleneck, 288 OMP regions/layer saturates cores |
| 32 | 4. Batch B=4 concurrency |