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/www/docs/index.html # 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 / www / docs / index.html` 948 lines · 47775 bytes Raw Blame History 1 2 3 4 5 6 MojoLlama Documentation 7 8 9 10 11 12 13 14 329 330 331 332 333 334 353 354 355 356
357 358 449 450 451
452 453

MojoLlama Documentation CLI reference, Docker guide, model support, and troubleshooting

454

v0.5.0 — Last updated May 2026

455 456 457

Recommended topics

458
459
460 Quick start 461

Get started in 5 minutes

462

Install MojoLlama, download a model, and run your first inference.

463
464
465 CLI 466

Serving models via API

467

Start an OpenAI-compatible API server with concurrent users.

468
469
470 Docker 471

Docker deployment guide

472

Run MojoLlama in containers with auto-tune and model download.

473
474
475 Models 476

Architecture support

477

Supported model architectures and quantization types.

478
479
480 CLI 481

Benchmark models

482

Measure tok/s throughput and compare against llama.cpp.

483
484
485 Guide 486

Troubleshooting

487

Common issues and solutions for CLI and Docker.

488
489
490 491 492

Getting Started

493 494

Installation

495

Clone 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.0
501 502

Quick start

503

Download 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.gguf
506

Or use an existing GGUF file:

507
$ mojollama chat -m /path/to/model.gguf
508 509

CLI overview

510

The mojollama command provides a unified interface for all operations:

511
$ 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 operations
523 524 525

CLI Reference

526 527

mojollama 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 2048
531
532 533 534 535 536 537 538 539
FlagDefaultDescription
-m, --model—Path to GGUF model file (required)
--temp0.7Sampling temperature (0–2)
--max-tokens512Maximum generation tokens
--top-p0.9Top-p nucleus sampling
--repeat-penalty1.1Repeat penalty
540
541 542

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:8080
547
548 549 550 551 552 553 554
FlagDefaultDescription
-p, --port8080Server port
--workers1Number of worker processes
--batch-size1Batch size for inference
--cors-allow-origin—CORS origin (use * for all)
555
556 557

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.cpp
562 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_m
567 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.gguf
572 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=10
578 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: 291
587 588 589

Docker Guide

590 591

Quick start

592

Pull 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 chat
596 597

Docker Compose profiles

598
599 600 601 602 603 604 605 606 607
ProfileCommandDescription
mojollamadocker compose --profile mojollama upAPI server
chatdocker compose --profile chat upInteractive chat
benchdocker compose --profile bench upRun benchmarks
quantizedocker compose --profile quantize upQuantize models
autotunedocker compose --profile autotune upHardware auto-tune
llama-cppdocker compose --profile llama-cpp upllama.cpp fallback
608
609 610

Environment variables

611
612 613 614 615 616 617 618 619 620 621
VariableDefaultDescription
MODEL/models/model.ggufPath to the GGUF model file
PORT8080Server port
OMP_NUM_THREADS32OpenMP threads for inference
AUTO_TUNEtrueEnable 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
622
623 624

Model auto-download

625

The entrypoint script downloads models from HuggingFace on first run. Set HF_REPO and HF_FILE to auto-download:

626
$ 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 chat
630 631

Hardware auto-tune

632

Set 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.

633 634 635

Model Support

636 637

Supported architectures

638

MojoLlama supports 50+ model architectures through architecture-specific forward passes.

639 640
641 642 643 644 645 646 647 648 649 650 651 652 653 654
ArchitectureStatusNotable features
Llama 2/3/4, MistralFullDense, GQA, SwiGLU, RoPE
Qwen2, Qwen3FullTNT embedding, partial rotary
GPT-OSSFullMoE 32 experts, bias attention — on par with llama.cpp
Qwen3 MoEFull128 experts top-8, shared expert, SwiGLU
Qwen3.6-35BFullHybrid SSM+Attention, MXFP4, 256 experts
Gemma 4FullPer-layer proj, GeGLU, sliding window, softcapping
ZAYA1-8BFull80 layers, ATTN/CCA/SSM + MoE+MoD
DeepSeek V2/V3SupportedMulti-head Latent Attention, DeepSeekMoE
Mixtral, DBRXSupportedStandard MoE with gated FFN
FalconIn developmentParallel attention+FFN, fused QKV
Phi-3/4In developmentFused QKV, long RoPE
655
656 657

Quantization types

658
659 660 661 662 663 664 665 666 667
TypeBitsDescription
Q4_044-bit, no K-quant (fast, compact)
Q4_K_M44-bit K-quant medium (recommended)
Q5_K55-bit K-quant
Q6_K66-bit K-quant (near lossless)
Q8_088-bit (accurate)
MXFP444-bit MXFP4 (expert weights)
668
669 670

Model tips

671 677 678 679

Troubleshooting

680 681

CLI issues

682 683

mojollama 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.0
688 689
Tip: If using a virtual environment, activate it first: source .venv/bin/activate
690 691

ImportError: No module named 'mojollama'

692

Run from the src/ directory or reinstall with pip install -e .

693 694

Benchmark crashes or shows 0 tok/s

695 700 701

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 port
705 706

Chat UI can't connect

707
    708
  1. Ensure server is running: mojollama serve -m model.gguf -p 8080
  2. 709
  3. Open studio.html and enter the server URL in the connection bar
  4. 710
  5. Click Connect — status should turn green
  6. 711
712
Note: If using a browser from a different machine, use the server's IP/hostname. For cross-origin access, start the server with --cors-allow-origin "*".
713 714

Docker issues

715 716

Container exits immediately

717

Check the logs:

718
$ docker logs <container-name>

719 $ docker compose logs mojollama
720

Common causes:

721 726 727

Model auto-download fails

728 733 734

Performance issues

735
736 737 738 739 740 741 742 743
ProblemFix
OMP_NUM_THREADS too lowSet to number of physical cores (e.g., 32 for Threadripper 3970X)
OMP_NUM_THREADS too highFor models <10B, 1 thread is optimal (OpenMP overhead)
Slow first tokenFirst inference includes model load time. Subsequent tokens faster.
CPU throttlingMonitor: watch -n1 "grep MHz /proc/cpuinfo"
Low throughputRun mojollama autotune --quick for optimized config
744
745 746

Model loading

747

"Unknown architecture" error

748

Check what architecture the model reports:

749
$ mojollama info -m model.gguf | grep architecture
750

If unsupported, MojoLlama falls back to a generic forward pass — results may be incorrect. See the architecture table for supported list.

751 752

NaN values in output

753

NaN indicates a computation error. Common causes:

754 760 761 762

API Reference

763 764

OpenAI-compatible API

765

MojoLlama serves an OpenAI-compatible API at /v1/chat/completions, compatible with the OpenAI Python client, LangChain, and any OpenAI SDK.

766 767

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
Note: The API supports streaming (stream: true), temperature, top_p, max_tokens, frequency_penalty, and presence_penalty parameters.
778 779
780 784 785
786
787 788 789 792 793 947 948