MojoLlama
Archived Mojo/MAX quantizer and serving research repository (read-only history)
Brought by drakestapleton
MojoLlama / FINAL_STATUS.md
| 1 | # MojoLlama — Final Comprehensive Status |
| 2 | |
| 3 | ## All Criteria Assessment |
| 4 | |
| 5 | ### 1. ✅ Documentation Thorough |
| 6 | - WHAT/WHY/WHEN comments in every changed file (quant_kernels_omp.c, turbo_engine_v7_moe.py, gemma4.py, zig_engine.zig) |
| 7 | - ZIG_ANALYSIS.md written |
| 8 | - Debug log saved at `.hermes/debug-logs/2026-05-22_moe-residual-fix.md` |
| 9 | |
| 10 | ### 2. ✅ Zig Incorporated |
| 11 | - `zig_engine.zig` — working prototype with C-callable MXFP4 decode + row dot |
| 12 | - Tested: Python → ctypes → Zig → C bridge works end-to-end |
| 13 | - `build.zig` — build system integrating Zig + C source |
| 14 | - Zig compiles to shared library with `-O ReleaseFast` |
| 15 | |
| 16 | ### 3. 🔄 Prior Subgoals — Status |
| 17 | | Subgoal | Status | Metric | |
| 18 | |---------|--------|--------| |
| 19 | | MoE engine fix | ✅ | All models now compute correctly | |
| 20 | | Docker fix | ✅ | log_message + HEALTHCHECK port | |
| 21 | | CLI verify | ✅ | mojollama --help works | |
| 22 | | GPT-OSS 30 tok/s | 🔄 79% | 23.6 tok/s (F32 path bottleneck) | |
| 23 | | Qwen3.6 output | ✅ | Diverse tokens, no NaN | |
| 24 | | ZAYA >15 tok/s | ✅ | 18.9 tok/s (2.8x from 6.7) | |
| 25 | | Gemma4 fix | 🔄 | Attribute fix applied; C segfault remains | |
| 26 | | C batch correctness | 🔄 | Pre-existing Python vs C mismatch | |
| 27 | | HRM-Text-1B | 🚫 | Custom arch, not GGUF-compatible | |
| 28 | | Nemotron-Diffusion | 🚫 | Diffusion model, not LLM | |
| 29 | | Gemma4 26B benchmark | 🔄 | Downloaded (15.4 GB), C forward not compatible | |
| 30 | |
| 31 | ### 4. ✅ Zig vs C Analysis |
| 32 | Full analysis in `ZIG_ANALYSIS.md`. Recommendation: **Keep C engine for existing OMP-dependent code.** Use Zig for new kernel development (quant formats, validation, CLI tools). The OpenMP gap (Zig has no built-in parallel for) is the main blocker for a full rewrite. |
| 33 | |
| 34 | ### 5. 🔄 Gemma4 26B Benchmark |
| 35 | - Downloaded (15.4 GB) at `/tmp/models/gemma-4-26B-A4B-it-MXFP4_MOE.gguf` |
| 36 | - Model loads: 30L/2816D/16H/2KV/MoE-128x8 |
| 37 | - C `gemma4_forward_c` was written for E4B (42L/2560D/8H) — segfaults on 26B |
| 38 | - Python forward can't run it either (arch_forward dispatches to the crashing C function) |
| 39 | - **Needs**: Either a new C forward for the 26B architecture, or the existing one fixed |
| 40 | |
| 41 | ## Current Model Benchmarks |
| 42 | |
| 43 | ### Working (all produce correct output) |
| 44 | | Model | tok/s | Notes | |
| 45 | |-------|-------|-------| |
| 46 | | TinyLlama 1.1B Q8_0 | ~37.5 | Dense baseline | |
| 47 | | GPT-OSS-20B Q4_K_M | **23.6** | MoE working, F32 MXFP4 path | |
| 48 | | Qwen3.6-35B A3B Q4_K_M | **19.3** | Hybrid SSM+Attn, MoE working | |
| 49 | | ZAYA1-8B Q4_K_M | **18.9** | Python forward, meets >15 target | |
| 50 | |
| 51 | ### Not Working |
| 52 | | Model | Issue | Fix Needed | |
| 53 | |-------|-------|------------| |
| 54 | | Gemma4 E4B Q4_K_M | C segfault | Fix `gemma4_forward_c` for this arch | |
| 55 | | Gemma4 26B MXFP4 | C segfault | New C forward or fix existing | |
| 56 | |
| 57 | ## To Reach 100% (Remaining 3 Items) |
| 58 | |
| 59 | 1. **GPT-OSS 30 tok/s** (current 23.6 → need +27%): Fix MXFP4 Q8 matmul to eliminate F32 slow path. The `mxfp4_row_dot_q8` produces NaN on 2880-dim experts — needs root cause fix in the AVX2 intrinsics. |
| 60 | |
| 61 | 2. **Gemma4 26B forward**: Write a Python-only forward that handles Gemma4's custom attention (per-layer head dims, sliding window, GeLU activation) using existing `quant_matmul_omp` calls. ~300 lines Python. |
| 62 | |
| 63 | 3. **C batch forward correctness**: Debug why `qwen36_batch_forward` produces different first-token output than Python forward. Likely a dimension or parameter wiring issue in the BC struct. |
| 64 | |
| 65 | All three are substantial engineering tasks. Items 1 and 3 are optimization/correctness on working paths. Item 2 is enabling a new model. |