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/mojollama # 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 / mojollama` 96 lines · 3127 bytes Raw Blame History 1 #!/bin/bash 2 # mojollama — Unified CLI (replaces Python __main__.py) 3 # Sets MOJOLLAMA_CMD env var and dispatches to native Mojo binaries, 4 # or falls back to Python for commands without Mojo backend. 5 set -e 6 7 VERSION="0.5.0" 8 MOJO_ENGINE="/onedev-workspace/work/src/mojollama/mojo_engine" 9 10 build_if_needed() { 11 local name="$1" 12 local src="$name.mojo" 13 shift 14 cd "$MOJO_ENGINE" 15 if [ ! -f "$name" ] || [ "$src" -nt "$name" ]; then 16 echo "[mojollama] Building $src..." >&2 17 mojo build "$src" 2>&1 || echo "[mojollama] Build failed, using Python fallback" >&2 18 fi 19 } 20 21 case "${1:-help}" in 22 serve) 23 shift 24 build_if_needed server 25 if [ -f "$MOJO_ENGINE/server" ]; then 26 exec "$MOJO_ENGINE/server" "$@" 27 fi 28 ;; 29 quantize|q) 30 shift 31 build_if_needed mojo_quantize 32 if [ -f "$MOJO_ENGINE/mojo_quantize" ]; then 33 exec "$MOJO_ENGINE/mojo_quantize" "$@" 34 fi 35 ;; 36 bench|benchmark) 37 shift 38 build_if_needed mojollama_bench 39 if [ -f "$MOJO_ENGINE/mojollama_bench" ]; then 40 exec "$MOJO_ENGINE/mojollama_bench" "$@" 41 fi 42 ;; 43 info) 44 echo "MojoLlama v${VERSION}" 45 echo "Mojo engine dir: $MOJO_ENGINE" 46 echo "Mojo: $(mojo --version 2>/dev/null || echo 'not found')" 47 echo "CPU: $(grep 'model name' /proc/cpuinfo | head -1 | sed 's/.*: //')" 48 echo "Cores: $(nproc)" 49 echo "" 50 echo "Build commands:" 51 echo " mojollama serve — HTTP server" 52 echo " mojollama quantize — Quantize model" 53 echo " mojollama bench — Benchmark" 54 echo "" 55 echo "Mojo files (${MOJO_ENGINE}):" 56 for f in "$MOJO_ENGINE"/*.mojo; do 57 printf " %-30s %4d lines\n" "$(basename $f)" $(wc -l < "$f") 58 done 59 ;; 60 help|--help|-h|"") 61 cat << HELP 62 ╔═══════════════════════════════════════════╗ 63 ║ MojoLlama v${VERSION} ║ 64 ║ Unified CLI — pure Mojo engine ║ 65 ╚═══════════════════════════════════════════╝ 66 67 USAGE: mojollama [options] 68 69 INFERENCE: 70 serve Start API server (Mojo native) 71 72 MODEL OPS: 73 quantize Quantize GGUF (Mojo native: Q4_0/Q8_0/MXFP4) 74 75 BENCHMARK: 76 bench Benchmark inference (Mojo native) 77 78 SYSTEM: 79 info System info (shell) 80 chat Interactive chat → python3 -m mojollama 81 autotune Auto-tune → python3 -m mojollama 82 imatrix Imatrix → python3 -m mojollama 83 convert HF→GGUF → python3 -m mojollama 84 hub Hub ops → python3 -m mojollama 85 eval Eval → python3 -m mojollama 86 train Train → python3 -m mojollama 87 export Export → python3 -m mojollama 88 89 Run 'mojollama --help' for detailed options. 90 HELP 91 ;; 92 *) 93 cd /onedev-workspace/work 94 exec python3 -m mojollama "$@" 95 ;; 96 esac