MojoLlama Documentation CLI reference, Docker guide, model support, and troubleshooting
454v0.5.0 — Last updated May 2026
455 456 457Recommended topics
458Get started in 5 minutes
462Install MojoLlama, download a model, and run your first inference.
463Serving models via API
467Start an OpenAI-compatible API server with concurrent users.
468Docker deployment guide
472Run MojoLlama in containers with auto-tune and model download.
473Getting Started
493 494Installation
495Clone the repository and install with pip in development mode:
496$ git clone https://github.com/a730/MojoLlama.git 497 $ cd MojoLlama/src && pip install -e .498
Verify the installation:
499$ mojollama --version 500 mojollama v0.5.0501 502
Quick start
503Download a GGUF model and run chat inference:
504$ mojollama convert --hf meta-llama/Llama-3.2-1B --outtype q4_0 505 $ mojollama chat -m model.gguf506
Or use an existing GGUF file:
507$ mojollama chat -m /path/to/model.gguf508 509
CLI overview
510The mojollama command provides a unified interface for all operations:
$ mojollama 512 chat Interactive chat with a model 513 serve OpenAI-compatible API server 514 bench Run benchmarks (tok/s, latency) 515 convert HuggingFace → GGUF conversion 516 quantize Quantize models (Q4_0, Q8_0, etc.) 517 autotune Hardware auto-tuning sweep 518 info Display model metadata 519 eval Run evaluation benchmarks 520 train LoRA fine-tuning 521 export Export to safetensors, ONNX 522 hub HuggingFace Hub operations523 524 525
CLI Reference
526 527mojollama chat
528 Interactive chat session with a loaded model.
529$ mojollama chat -m model.gguf 530 $ mojollama chat -m model.gguf --temp 0.8 --max-tokens 2048531
| Flag | Default | Description |
|---|---|---|
| -m, --model | — | Path to GGUF model file (required) |
| --temp | 0.7 | Sampling temperature (0–2) |
| --max-tokens | 512 | Maximum generation tokens |
| --top-p | 0.9 | Top-p nucleus sampling |
| --repeat-penalty | 1.1 | Repeat penalty |
mojollama serve
543 Start an OpenAI-compatible API server for concurrent requests.
544$ mojollama serve -m model.gguf -p 8080 545 $ mojollama serve -m model.gguf -p 8080 --workers 4 546 ✓ Server started on http://0.0.0.0:8080547
| Flag | Default | Description |
|---|---|---|
| -p, --port | 8080 | Server port |
| --workers | 1 | Number of worker processes |
| --batch-size | 1 | Batch size for inference |
| --cors-allow-origin | — | CORS origin (use * for all) |
mojollama bench
558 Measure throughput and compare against llama.cpp.
559$ mojollama bench -m model.gguf 560 $ mojollama bench -m model.gguf --prompt-tokens 512 --gen-tokens 128 561 $ mojollama bench -m model.gguf --compare # vs llama.cpp562 563
mojollama convert
564 Convert a HuggingFace model to GGUF format.
565$ mojollama convert --hf meta-llama/Llama-3.2-1B --outtype q4_0 566 $ mojollama convert --hf mistralai/Mistral-7B --outtype q4_k_m567 568
mojollama quantize
569 Quantize an existing GGUF model to a different precision.
570$ mojollama quantize -m model.gguf -t q4_k_m 571 $ mojollama quantize -m model.gguf -t q8_0 -o model-q8.gguf572 573
mojollama autotune
574 Sweep hardware parameters to find optimal settings for your model:
575$ mojollama autotune -m model.gguf 576 $ mojollama autotune -m model.gguf --quick 577 ✓ Optimal: threads=32, batch=512, concurrency=10578 579
mojollama info
580 Display model metadata, architecture, and tensor layout without running inference.
581$ mojollama info -m model.gguf 582 Architecture: llama 583 Parameters: 7.24B 584 Quantization: Q4_K_M 585 Context length: 8192 586 Tensors: 291587 588 589
Docker Guide
590 591Quick start
592Pull the latest image and run with a model:
593$ docker pull ghcr.io/a730/mojollama:latest 594 $ docker run -e MODEL=/models/model.gguf -v /path/to/model.gguf:/models/model.gguf \ 595 ghcr.io/a730/mojollama:latest mojollama chat596 597
Docker Compose profiles
598| Profile | Command | Description |
|---|---|---|
| mojollama | docker compose --profile mojollama up | API server |
| chat | docker compose --profile chat up | Interactive chat |
| bench | docker compose --profile bench up | Run benchmarks |
| quantize | docker compose --profile quantize up | Quantize models |
| autotune | docker compose --profile autotune up | Hardware auto-tune |
| llama-cpp | docker compose --profile llama-cpp up | llama.cpp fallback |
Environment variables
611| Variable | Default | Description |
|---|---|---|
MODEL | /models/model.gguf | Path to the GGUF model file |
PORT | 8080 | Server port |
OMP_NUM_THREADS | 32 | OpenMP threads for inference |
AUTO_TUNE | true | Enable hardware auto-tune |
HF_REPO | — | HuggingFace repo for model download |
HF_FILE | — | GGUF filename in the HF repo |
HF_TOKEN | — | HuggingFace token for gated models |
Model auto-download
625The entrypoint script downloads models from HuggingFace on first run. Set HF_REPO and HF_FILE to auto-download:
$ docker run -e HF_REPO=QuantFactory/Meta-Llama-3-8B-GGUF \ 627 -e HF_FILE=Meta-Llama-3-8B.Q4_K_M.gguf \ 628 -e MODEL=/models/Meta-Llama-3-8B.Q4_K_M.gguf \ 629 ghcr.io/a730/mojollama:latest mojollama chat630 631
Hardware auto-tune
632Set AUTO_TUNE=true (default) to run a hardware sweep on first model load. Results are cached per-model hash in /root/.cache/mojollama/ so subsequent runs use the optimal config immediately.
Model Support
636 637Supported architectures
638MojoLlama supports 50+ model architectures through architecture-specific forward passes.
639 640| Architecture | Status | Notable features |
|---|---|---|
| Llama 2/3/4, Mistral | Full | Dense, GQA, SwiGLU, RoPE |
| Qwen2, Qwen3 | Full | TNT embedding, partial rotary |
| GPT-OSS | Full | MoE 32 experts, bias attention — on par with llama.cpp |
| Qwen3 MoE | Full | 128 experts top-8, shared expert, SwiGLU |
| Qwen3.6-35B | Full | Hybrid SSM+Attention, MXFP4, 256 experts |
| Gemma 4 | Full | Per-layer proj, GeGLU, sliding window, softcapping |
| ZAYA1-8B | Full | 80 layers, ATTN/CCA/SSM + MoE+MoD |
| DeepSeek V2/V3 | Supported | Multi-head Latent Attention, DeepSeekMoE |
| Mixtral, DBRX | Supported | Standard MoE with gated FFN |
| Falcon | In development | Parallel attention+FFN, fused QKV |
| Phi-3/4 | In development | Fused QKV, long RoPE |
Quantization types
658| Type | Bits | Description |
|---|---|---|
| Q4_0 | 4 | 4-bit, no K-quant (fast, compact) |
| Q4_K_M | 4 | 4-bit K-quant medium (recommended) |
| Q5_K | 5 | 5-bit K-quant |
| Q6_K | 6 | 6-bit K-quant (near lossless) |
| Q8_0 | 8 | 8-bit (accurate) |
| MXFP4 | 4 | 4-bit MXFP4 (expert weights) |
Model tips
671-
672
- Small models (<10B): Use 1 thread — OpenMP overhead kills performance on small matrix multiplications (e.g., ZAYA1-8B optimal at 1 thread) 673
- Large models (>10B): Use all physical cores (e.g., 32 threads on Threadripper 3970X) 674
- MoE models: MojoLlama excels here — GPT-OSS reaches 0.94x llama.cpp throughput 675
- Check architecture: Use
mojollama info -m model.ggufto verify a model is recognized
676
Troubleshooting
680 681CLI issues
682 683mojollama command not found
684 Install the package in your active Python environment:
685$ cd MojoLlama/src && pip install -e . 686 $ mojollama --version 687 mojollama v0.5.0688 689
source .venv/bin/activateImportError: No module named 'mojollama'
692 Run from the src/ directory or reinstall with pip install -e .
Benchmark crashes or shows 0 tok/s
695-
696
- Verify the model file path is correct and accessible 697
- Check it's a valid GGUF:
head -c 4 model.gguf | xxdshould show`46474755`("GGUF")
698 - MXFP4 models require the MXFP4 engine path 699
Server fails to start (address in use)
702$ lsof -i :8080 703 $ kill -9 <PID> 704 $ mojollama serve -m model.gguf -p 8081 # use different port705 706
Chat UI can't connect
707-
708
- Ensure server is running:
mojollama serve -m model.gguf -p 8080
709 - Open
studio.htmland enter the server URL in the connection bar
710 - Click Connect — status should turn green 711
--cors-allow-origin "*".Docker issues
715 716Container exits immediately
717Check the logs:
718$ docker logs <container-name> 719 $ docker compose logs mojollama720
Common causes:
721-
722
- No model specified — set
MODELenv var or mount a GGUF at/models/
723 - Model file not found — verify the path in
MODEL
724 - Out of memory — model requires more RAM than available 725
Model auto-download fails
728-
729
- Check internet:
docker run --rm ghcr.io/a730/mojollama:latest curl -I https://huggingface.co
730 - Gated models need
HF_TOKENenv var set
731 - File names are case-sensitive on HuggingFace 732
Performance issues
735| Problem | Fix |
|---|---|
| OMP_NUM_THREADS too low | Set to number of physical cores (e.g., 32 for Threadripper 3970X) |
| OMP_NUM_THREADS too high | For models <10B, 1 thread is optimal (OpenMP overhead) |
| Slow first token | First inference includes model load time. Subsequent tokens faster. |
| CPU throttling | Monitor: watch -n1 "grep MHz /proc/cpuinfo" |
| Low throughput | Run mojollama autotune --quick for optimized config |
Model loading
747"Unknown architecture" error
748Check what architecture the model reports:
749$ mojollama info -m model.gguf | grep architecture750
If unsupported, MojoLlama falls back to a generic forward pass — results may be incorrect. See the architecture table for supported list.
751 752NaN values in output
753NaN indicates a computation error. Common causes:
754-
755
- Attention softmax — overflow/underflow. Try smaller context or non-zero attention mask 756
- RMSNorm — near-zero variance. MojoLlama clamps RMS sum to [-1000, 1000] 757
- MXFP4 — scale overflow in 4-bit arithmetic 758
- Unsupported architecture — needs a specialized forward pass 759
API Reference
763 764OpenAI-compatible API
765MojoLlama serves an OpenAI-compatible API at /v1/chat/completions, compatible with the OpenAI Python client, LangChain, and any OpenAI SDK.
Chat Completions
768$ curl http://localhost:8080/v1/chat/completions \ 769 -H "Content-Type: application/json" \ 770 -d '{"model":"default","messages":[{"role":"user","content":"Hello!"}]}' 771 {"id":"chat-...","choices":[{"index":0,"message":{"role":"assistant","content":"Hi there!"},"finish_reason":"stop"}],"usage":...}772 773
Model listing
774$ curl http://localhost:8080/v1/models 775 {"object":"list","data":[{"id":"default","object":"model","created":...,"owned_by":"mojollama"}]}776 777
stream: true), temperature, top_p, max_tokens, frequency_penalty, and presence_penalty parameters.780 784 785