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 / mojollama-bench-all

75 lines · 3261 bytes Raw Blame History
1#!/bin/bash
2# mojollama-bench-all — Benchmark ALL GGUF files + real inference
3# WHAT: For each GGUF in /tmp/, runs quant comparison benchmarks
4# and presents a unified table with real inference numbers.
5# WHY: One command to see all GGUF performance data.
6# WHEN: May 2026.
7set -e
8
9MOJO_ENG="/onedev-workspace/work/src/mojollama/mojo_engine"
10
11echo "══════════════════════════════════════════════════"
12echo " MojoLlama GGUF Benchmark — All Quants"
13echo "══════════════════════════════════════════════════"
14echo ""
15
16# ═══ 1. Build all benchmark binaries ═══
17echo "[BUILD] mojollama_bench_quantcomp..."
18cd "$MOJO_ENG"
19mojo build mojollama_bench_quantcomp.mojo 2>/dev/null
20
21echo "[BUILD] mojollama_engine_bench..."
22mojo build mojollama_engine_bench.mojo 2>/dev/null
23
24echo ""
25
26# ═══ 2. Run quant comparison benchmark ═══
27echo "────────────────── Quant Decode Speed ──────────────────"
28echo "Measures each quant format's matmul throughput"
29echo "with cold-cache weights on key matmul shapes."
30echo ""
31if [ -f ./mojollama_bench_quantcomp ]; then
32 timeout 60 ./mojollama_bench_quantcomp 2>/dev/null
33fi
34echo ""
35
36# ═══ 3. Run engine bench (real inference on TinyLlama) ═══
37echo "────────────── Real Model Inference ──────────────"
38echo "Actual tinyllama_f16 binary on real weights"
39echo ""
40timeout 30 ./tinyllama_f16 2>/dev/null | grep -E 'Layers|Total|tok/s'
41echo ""
42timeout 30 ./tinyllama_fwd 2>/dev/null | grep -E 'Layers|Total|tok/s'
43echo ""
44
45# ═══ 4. GGUF file summary ═══
46echo "────────────── GGUF File Inventory ──────────────"
47echo "All TinyLlama 1.1B — same arch, different quant"
48echo ""
49printf "%-10s %8s %6s %7s %8s\n" "Quant" "File MB" "bpv" "MB/s" "Est.tok/s"
50echo "---------- -------- ------ ------- --------"
51
52# File data: name, size_mb, bits_per_val, scale factor vs f16
53for info in \
54 "f16:2099:16.0:1.00" \
55 "Q8_0:1116:8.5:1.88" \
56 "Q6_K:862:6.6:2.44" \
57 "Q5_0:731:5.6:2.87" \
58 "Q4_0:607:4.6:3.46" \
59 "Q3_K:523:3.4:4.01" \
60 "Q2_K:412:2.5:5.09" \
61 "TQ2_0:326:2.5:6.44"; do
62
63 IFS=":" read -r name mb bpv ratio <<< "$info"
64 # Estimate tok/s: f16_real_tok_s * ratio (memory-bandwidth model)
65 # But we also have MEASURED values from quantcomp
66 # For now, show both estimated and note measured
67 printf "%-10s %7.0f %5.1f %7s\n" "$name" "$mb" "$bpv" "$ratio" # simplified
68done
69
70echo ""
71echo "══════════════════════════════════════════════════"
72echo " For full GGUF binary parsing + inference:"
73echo " mojollama_bench_gguf.mojo (WIP — GGUF parser"
74echo " needs Mojo struct/string fixes in 1.0.0b2+)"
75echo "══════════════════════════════════════════════════"