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 / ARCHITECTURE_COVERAGE.md

190 lines · 7646 bytes Raw Blame History Source

MojoLlama Studio — Architecture Coverage & Per-Architecture Performance

Overview

MojoLlama Studio supports 10+ model architectures via the llama.cpp backend. This document tracks each architecture's support level, known performance, and architecture-specific considerations.

Architecture Support Matrix

ArchitectureStatusllama.cppAutoBackendTraining TemplateQuantNotes
Llama 3/3.1/3.2✅ FullNative✓llama3All typesReference arch for all others
Mistral 7B/Mixtral✅ FullNative✓mistralAll typesSliding window attention, MoE variant
Qwen2/Qwen3✅ FullNative✓qwenAll typesMoE on Qwen3-30B tested 28.5 tok/s
Gemma 2/4✅ FullNative✓gemmaAll typesGeLU activation, RoPE scaling in v2/v4
Phi-3/Phi-4✅ FullNative✓phiAll typesSmall models, lower rank recommended
DeepSeek V2/V3/R1✅ FullNative✓deepseekAll typesMLA attention (latent KV), needs higher rank
ChatGLM / GLM-4✅ FullNative✓chatglmAll typesPrefix-encoder arch, custom attention masking
Command R / R+✅ FullNative✓command-rAll typesLarge FFN layers, high capacity
Falcon✅ FullNative——All typesMulti-query attention variant
StarCoder✅ FullNative——All typesCode-optimized GPT-NeoX
Baichuan✅ FullNative——All typesChinese LLM family

llama.cpp Architecture Support

The llama.cpp GGUF inference engine natively supports all listed architectures without any code changes. The general.architecture field in each GGUF model determines the tensor naming convention and attention/layer computation path. llama.cpp's internal architecture dispatch handles:

Training Template Recommendations

Llama 3/3.1/3.2

LoRA rank: 16, alpha: 32, LR: 2e-4, scheduler: cosine
Modules: q_proj, v_proj, k_proj, o_proj
Format: alpaca, ctx: 2048

Best for: General instruction tuning, chat fine-tuning.

Mistral / Mixtral

LoRA rank: 32, alpha: 64, LR: 1e-4, scheduler: cosine
Modules: q_proj, v_proj, k_proj, o_proj, gate_proj, up_proj, down_proj
Format: sharegpt, ctx: 4096

Higher rank due to sliding window attention. MoE variant needs full feed-forward module adaptation.

Qwen2 / Qwen3

LoRA rank: 16, alpha: 32, LR: 2e-4, scheduler: linear
Modules: q_proj, v_proj
Format: alpaca, ctx: 2048

MoE variant (Qwen3-30B-A3B): uses router + expert dispatch via TurboEngine v4 universal. ~28.5 tok/s on CPU (Threadripper 3970X).

DeepSeek V2/V3/R1

LoRA rank: 64, alpha: 128, LR: 1e-4, scheduler: cosine
Modules: q_proj, v_proj, k_proj, o_proj, gate_proj, up_proj, down_proj
Format: sharegpt, ctx: 4096

Multi-head Latent Attention (MLA) compresses KV cache via latent vectors. Higher rank recommended for reasoning-heavy tasks. Needs 2x-4x grad accumulation for stability.

Gemma 2/4

LoRA rank: 16, alpha: 32, LR: 2e-4, scheduler: cosine
Modules: q_proj, v_proj, k_proj, o_proj
Format: alpaca, ctx: 2048

Gemma uses GeLU activation (vs SiLU in Llama). Gemma 4 adds RoPE scaling differences. GGUF metadata prefix: gemma.

Phi-3/Phi-4

LoRA rank: 8, alpha: 16, LR: 5e-4, scheduler: constant
Modules: q_proj, v_proj
Format: alpaca, ctx: 2048

Lowest rank recommended — these are small, capable models and over-parameterization quickly leads to catastrophic forgetting. Higher dropout (0.1) and constant LR work well.

ChatGLM / GLM-4

LoRA rank: 16, alpha: 32, LR: 2e-4, scheduler: cosine
Modules: q_proj, v_proj, k_proj, o_proj
Format: alpaca, ctx: 2048

Prefix-encoder architecture: different attention masking pattern than decoder-only models. Uses a different tokenizer (sentencepiece based). GGUF metadata prefix: chatglm.

Command R / R+

LoRA rank: 32, alpha: 64, LR: 1e-4, scheduler: cosine
Modules: q_proj, v_proj, k_proj, o_proj, gate_proj, up_proj, down_proj
Format: sharegpt, ctx: 4096

Very large FFN layers — full module set recommended for adapters. Smaller batch size (2) with grad accumulation due to memory footprint.

Quantization Handling

Quantization is architecture-agnostic at the GGUF level. The quantizer (quantizer.py) now reads architecture metadata to determine the correct GGUF key prefix for extracting model configuration (context length, embedding dim, layers, etc.).

Key architecture-specific quantization notes:

ArchitectureRecommended Minimum QuantNotes
Llama 3/3.1/3.2Q4_K_MGood quality/speed tradeoff
Mistral/MixtralQ5_K_MSliding window benefits from higher precision
Qwen2/Qwen3Q4_K_MMoE models compress well (Qwen3-30B: Q4_K_M=15.3GB)
Gemma 2/4Q4_0Gemma is more quantization-tolerant
Phi-3/Phi-4Q4_0Small models, less quantization impact
DeepSeekQ4_K_MMLA attention benefits from K-quant
ChatGLMQ4_0Standard quants work well
Command RQ4_K_MLarge FFN → K-quant reduces memory
FalconQ4_0Standard
StarCoderQ4_0Standard

Performance Benchmarks

Per-architecture benchmark data (from llama-bench on Threadripper 3970X, 32c/64t, AVX2+FMA, DDR4):

ModelArchQuantSizePP tok/sTG tok/s
Llama-3.2-1BllamaQ4_00.7 GB~2500~71
Llama-3.2-1BllamaQ4_K_M0.7 GB~2400~72
Qwen3-30B-A3Bqwen3moeQ4_K_M15.3 GB~120~28.5
Gemma-4-E2B-2.6Bgemma4Q4_K_M1.6 GB~1800~60

Expected: All llama.cpp-native architectures show similar tok/s per parameter count. MoE models (Qwen3-30B-A3B, Mixtral) have higher prompt processing due to sparse activation but lower TG due to routing overhead. Benchmarks for DeepSeek, ChatGLM, Phi-4, and Command R coming soon.

Verifying Architecture Support

To verify a model loads correctly:

# Via MojoLlama server
mojollama-server --model path/to/model.gguf
# Check /api/models for architecture detection
curl http://localhost:8080/api/models | jq '.models[] | {name, architecture, n_params_hr}'

# Direct GGUF metadata read
python3 -c "
from mojollama.quantizer import _read_gguf_metadata
import json
meta = _read_gguf_metadata('path/to/model.gguf')
print(json.dumps({k: v for k, v in meta.items() if not k.startswith('_')}, indent=2))
"

Future Architecture Targets

ArchitectureStatusNotes
DeepSeek V3/R1 (full)⏳Large MoE with MLA, needs >1TB memory at high precisions
DBRX (MosaicML)📋Dense-MoE hybrid, massive FFN
Jamba (AI21)📋Mamba + Transformer hybrid (SSM + attention)
Dbrx (Databricks)📋MoE architecture
Nemotron (NVIDIA)📋Llama-derived, needs verification
Olmo (AI2)📋Llama-derived