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 / src / mojollama / mojo_engine / bench_batch.sh

31 lines · 938 bytes Raw Blame History
1#!/bin/bash
2set -e
3MOJO_LIB="$HOME/.local/share/uv/tools/mojo/lib/python3.11/site-packages/modular/lib"
4SRC="tinyllama_gen_batch.mojo"
5
6for B in 2 4 8; do
7 echo ""
8 echo "=============================="
9 echo " Building B=$B"
10 echo "=============================="
11 sed -i "s/comptime B: Int = [0-9]*/comptime B: Int = $B/" "$SRC"
12 mojo build "$SRC" --emit object -o "tinyllama_gen_batch.o"
13 gcc -o "tinyllama_gen_batch_${B}" "tinyllama_gen_batch.o" \
14 -L"$MOJO_LIB" \
15 -lKGENCompilerRTShared \
16 -lAsyncRTRuntimeGlobals \
17 -lMSupportGlobals \
18 -lAsyncRTMojoBindings \
19 -lm -lpthread -ldl -lstdc++
20
21 echo ""
22 echo "--- Running B=$B (3 runs) ---"
23 for run in 1 2 3; do
24 LD_LIBRARY_PATH="$MOJO_LIB" "./tinyllama_gen_batch_${B}" 2>&1 | grep "B="
25 done
26done
27
28# Restore to B=4
29sed -i "s/comptime B: Int = [0-9]*/comptime B: Int = 4/" "$SRC"
30echo ""
31echo "Done."