Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/MojoLlama/blob/main/src/mojollama/mojo_engine/bench_fast.sh # MojoLlama Archived Mojo/MAX quantizer and serving research repository (read-only history) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `MojoLlama / src / mojollama / mojo_engine / bench_fast.sh` 50 lines · 1395 bytes Raw Blame History 1 #!/bin/bash 2 # Fast benchmark: thread × batch sweep 3 set -e 4 5 SRC="tinyllama_gen_q8.mojo" 6 cd "$(dirname "$0")" 7 8 MOJO_LIB="$HOME/.local/share/uv/tools/mojo/lib/python3.11/site-packages/modular/lib" 9 NW_VALUES=(1 2 4 8 12 16 24 32) 10 B_VALUES=(2 4 8) 11 RPW=8 12 13 echo "=== Thread × Batch Sweep (Q8_0, RPW=$RPW) ===" 14 printf "%-4s %-4s %s\n" "B" "nw" "tok/s" 15 printf "%-4s %-4s %s\n" "--" "---" "-----" 16 17 for b in "${B_VALUES[@]}"; do 18 # Build for this B 19 cp "$SRC" "${SRC}.bak" 20 sed -i "s/comptime B: Int = [0-9]*/comptime B: Int = $b/" "$SRC" 21 sed -i "s/comptime RPW: Int = [0-9]*/comptime RPW: Int = $RPW/" "$SRC" 22 23 OBJ="${SRC%.mojo}_B${b}.o" 24 BIN="${SRC%.mojo}_B${b}" 25 26 echo "Building B=$b..." 27 mojo build "$SRC" --emit object -o "$OBJ" 2>/dev/null 28 gcc -o "$BIN" "$OBJ" \ 29 -L"$MOJO_LIB" \ 30 -lKGENCompilerRTShared \ 31 -lAsyncRTRuntimeGlobals \ 32 -lMSupportGlobals \ 33 -lAsyncRTMojoBindings \ 34 -lm -lpthread -ldl -lstdc++ 2>/dev/null 35 36 for nw in "${NW_VALUES[@]}"; do 37 out=$(LD_LIBRARY_PATH="$MOJO_LIB" timeout 120 "./$BIN" "$nw" 2>&1 | grep "tok/s" | tail -1) 38 tok_s=$(echo "$out" | grep -oP '\(\s*[\d.]+' | tail -1 | sed 's/(//') 39 printf "%-4s %-4s %s\n" "$b" "$nw" "${tok_s:-ERR}" 40 done 41 42 rm -f "$OBJ" "$BIN" 43 mv "${SRC}.bak" "$SRC" 44 done 45 46 echo "" 47 echo "=== Sequential Baseline (nw=1) ===" 48 echo "B=2 nw=1 provides single-stream throughput" 49 echo "" 50 echo "=== Done ==="