interplane.Get Omega
Read in your language

MojoLlama

Archived Mojo/MAX quantizer and serving research repository (read-only history)

Brought by drakestapleton

branch main Branches Tags History

MojoLlama / BENCHMARK_CHANGELOG.md

106 lines · 5089 bytes Raw Blame History Source

MojoLlama Performance Optimization Changelog

Systematic, benchmarked improvements to surpass llama.cpp performance. Every change is measured — no guessing.

System

Baseline (2026-05-20)

EngineModelThreadsPP tok/sTG tok/sTG median msTG p95 ms
v77Llama-3.2-1B Q4_03253.247.421.1521.71
v7_moeQwen3-30B-A3B Q4_K_M32—20.96*47.71*192.64*
v7_moeQwen3-30B-A3B Q4_K_M3217.716.361.0864.16

*First measurement was with 20 tokens, not representative. 30-token measurement is the real baseline.

Optimization Log

Step 1: P0.1 — Fix MoE atomic bottleneck in moe_forward_omp

Step 2: P0.2 — SIMD exp approximation for SiLU

Step 3: Remove np.clip + np.copyto overhead

Step 4: Replace numpy residual with C residual_add

Step 5: P1.1 — GQA Attention SIMD softmax + workspace buffer

Step 6: P1.2 — gpt-oss-20b support + MXFP4 kernel tuning

Latest Results

EngineModelThreadsPP tok/sTG tok/sTG median msTG p95 ms
v77Llama-3.2-1B Q4_03254.448.920.4320.99
v7_moeQwen3-30B-A3B Q4_K_M3217.716.560.5461.12
v7_moegpt-oss-20b-MXFP43222.221.646.1448.66

Benchmark Commands

# Single model baseline
python3 src/mojollama/benchmarks/bench_tok.py -m model.gguf -t 32 --measured 30

# Thread sweep
python3 src/mojollama/benchmarks/bench_tok.py -m model.gguf -t 1,2,4,8,16,24,32 --save results.json

# Compare with previous
python3 src/mojollama/benchmarks/bench_tok.py --load benchmarks/baseline.json --load benchmarks/step1.json

# Concurrency test
python3 src/mojollama/benchmarks/bench_tok.py -m model.gguf --concurrent "1,2,4,8,16"

# Kernel-level benchmark
python3 src/mojollama/kernels/benchmarks/bench_c_avx2.py

Rebuild Commands

# Rebuild all C kernels
cd src/mojollama/kernels && gcc -O3 -mavx2 -mfma -mf16c -fopenmp -shared -fPIC -o quant_kernels_omp.so quant_kernels_omp.c -lm
cd src/mojollama/kernels && gcc -O3 -mavx2 -mfma -fopenmp -shared -fPIC -o gqa_attention.so gqa_attention.c -lm
cd src/mojollama/kernels && gcc -O3 -mavx2 -mfma -mf16c -fopenmp -shared -fPIC -o simd_ops.so simd_ops.c -lm
cd src/mojollama/kernels && gcc -O3 -mavx2 -mfma -mf16c -fopenmp -shared -fPIC -o cengine_batch_instr.so cengine_batch_instr.c -lm