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/CODING-SOUL.md # 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 / CODING-SOUL.md` 282 lines · 10154 bytes Raw Blame History Rendered 1 # MojoLlama CODING-SOUL 2 3 ## Identity 4 5 MojoLlama is a hybrid LLM inference engine built with Mojo + MAX. 6 It runs on CPU (AVX2/AVX512/NEON), GPU (CUDA/SYCL/Vulkan), and hybrid 7 setups — competing with vLLM/SGLang while also running on machines without 8 a discrete GPU. 9 10 No Python in the hot path. No hand-rewriting kernels for every model. 11 The architecture IS the advantage. 12 13 ## Principles 14 15 ### 1. Mojo + MAX, not C + llama.cpp 16 17 We use Mojo and the MAX ecosystem. When Mojo's heap/pointer APIs 18 mature in nightly, we adopt them. When MAX becomes installable, we 19 integrate its graph compiler and GPU kernels. 20 21 Until then, the Python backend (bridge.py) is a placeholder — not a 22 compromise. Every line of Python is temporary, clearly marked, and 23 designed to be swapped for Mojo without changing the op graph. 24 25 ### 2. Ops, not models 26 27 An `AttentionOp` is an `AttentionOp`. It doesn't know or care whether 28 it's part of Llama, AttnRes, MLA, or something unreleased. 29 30 NEW ARCHITECTURE = new graph wiring in `graph/ops.mojo`. 31 No new kernels. No new backends. No new anything except the DAG. 32 33 This is why we beat the vLLM/llama.cpp approach: they write kernels 34 per architecture. We write ops once, compose them differently. 35 36 ### 3. The graph is the source of truth 37 38 The computation is defined in `graph/ops.mojo`: 39 ``` 40 MatmulOp, AttentionOp, RMSNormOp, RoPEOp, SiLUOp 41 AddOp, EmbedOp, TransformerBlock 42 ``` 43 44 These compile in Mojo 0.26.2 with zero errors. They are the invariant. 45 Backends are swappable: Python → Mojo SIMD → MAX GPU → whatever comes next. 46 47 No runtime type dispatch. No `if model_type == "llama"`. The graph 48 structure IS the model. 49 50 ### 4. Every line of SIMD is deliberate 51 52 The Q4_0 kernel (`kernels/q4_matmul.mojo`) is hand-written for AVX2. 53 Not because we couldn't use BLAS — because we want the ASM to be 54 exactly what we specify. 55 56 Every `SIMD[DType.float32, 8]` is an explicit 256-bit vector register. 57 Every `reduce_add()` is a horizontal sum. Every nibble extraction is 58 a sequence of `& 15`, `>> 4`, `- 8` that maps directly to AVX2 59 instructions. No surprises, no compiler guessing. 60 61 When VNNI/AVX512/CUDA are available, `comptime if` dispatches. 62 The code changes at compile time, not runtime. 63 64 ### 5. Future architectures are graph changes, not kernel changes 65 66 Attention Residuals: one new op (`DepthAttentionOp`), same backends. 67 MLA: one new op (`LatentAttentionOp`), same backends. 68 Whatever comes next: same pattern. 69 70 The backends (CPU SIMD, CUDA, Vulkan, SYCL) are stable. The graph evolves. 71 This is how we stay ahead of llama.cpp and vLLM. 72 73 ## Non-Negotiable 74 75 - Mojo stdlib imports only. No Python in the forward pass. 76 - The `ops.mojo` graph compiles in current Mojo stable. 77 - Every kernel has a test with deterministic expected values. 78 - No hand-writing CUDA kernels for new architectures — the graph compiler handles it. 79 80 ## What We Ship When 81 82 "Works on my machine" is not the standard. The standard is: 83 - AVX2 today (our dev box) 84 - AVX512 tomorrow (server-class) 85 - CUDA/SYCL/Vulkan when MAX is installable 86 - Any graph architecture (Llama, AttnRes, MLA, ...) = same binary, different input 87 88 ## The Bet 89 90 We're betting that Mojo's pointer APIs stabilize before MAX becomes 91 installable, and that MAX's graph compiler beats hand-written kernels. 92 History suggests this is right: specialized kernels don't scale to 93 50+ architectures. A graph compiler does. 94 95 If we're wrong, we rewrite the backends in C. The ops stay. 96 97 --- 98 99 # MojoLlama Brand Guidelines 100 101 ## Brand Identity 102 103 MojoLlama is positioned at the intersection of: 104 - **CPU-first** — runs efficiently without a GPU (unlike vLLM/SGLang) 105 - **All-in-one** — inference, fine-tuning, quantization, serving (unlike llama.cpp/Ollama) 106 - **Mojo+MAX native** — engineered in Mojo, not a C/Python wrapper 107 - **Open source** — Apache 2.0, no proprietary features 108 109 ### Tagline 110 **"Inference at the speed of Mojo"** 111 112 Alternative taglines for different contexts: 113 - "CPU-first LLM inference, engineered in Mojo+MAX" 114 - "The open-source LLM platform built in Mojo" 115 - "Fine-tune, quantize, and serve — all on CPU" 116 117 ### Brand Voice 118 - Technical but approachable — we speak to ML engineers and developers 119 - Confident, not arrogant — back claims with real benchmarks 120 - Generous — open source, no lock-in, free forever 121 - Mojo-first — we're proud of the technology stack, not hiding it 122 123 ## Color Palette 124 125 ### Primary (Mojo Purple) 126 | Token | Hex | Usage | 127 |-------|-----|-------| 128 | `--mojo` | `#6C3CE1` | Primary brand color, buttons, links | 129 | `--mojo-light` | `#8B5CF6` | Hover states, highlights | 130 | `--mojo-glow` | `rgba(108,60,225,0.3)` | Glow effects, shadows | 131 132 ### Accent (Cyan) 133 | Token | Hex | Usage | 134 |-------|-----|-------| 135 | `--cyan` | `#22D3EE` | Secondary accent, code syntax, highlights | 136 | `--cyan-glow` | `rgba(34,211,238,0.25)` | Glow effects | 137 138 ### Semantic 139 | Token | Hex | Usage | 140 |-------|-----|-------| 141 | `--green` | `#34D399` | Success, benchmarks highlight | 142 | `--pink` | `#E879F9` | Feature accent, creative sections | 143 | `--orange` | `#FB923C` | Warning, speed accent | 144 | `--red` | `#F87171` | Error, danger | 145 146 ### Backgrounds 147 | Token | Hex | Usage | 148 |-------|-----|-------| 149 | `--bg` | `#080B12` | Main background (darkest) | 150 | `--bg2` | `#0C101A` | Section backgrounds | 151 | `--surface` | `#111624` | Card/panel surfaces | 152 | `--surface2` | `#171D2E` | Hover states | 153 | `--surface3` | `#1E2540` | Active states, code blocks | 154 | `--border` | `#252D4A` | Borders, dividers | 155 | `--border2` | `#1A2238` | Subtle borders | 156 157 ### Text 158 | Token | Hex | Usage | 159 |-------|-----|-------| 160 | `--text` | `#E2E8F0` | Primary text | 161 | `--text2` | `#C8D0DC` | Secondary text | 162 | `--dim` | `#7F8EA3` | Muted text | 163 | `--dim2` | `#5A6A82` | Subtle/meta text | 164 165 ### Gradient Signature 166 `linear-gradient(135deg, #6C3CE1 0%, #8B5CF6 40%, #22D3EE 100%)` 167 168 This is the MojoLlama gradient — used for logo text, hero headings, primary buttons. 169 170 ### Gradient Accents 171 - **Success**: `linear-gradient(135deg, #22D3EE 0%, #34D399 100%)` 172 - **Warm**: `linear-gradient(135deg, #FB923C 0%, #F87171 100%)` 173 174 ## Typography 175 176 | Context | Font | Weights | 177 |---------|------|---------| 178 | Headings | Space Grotesk | 600, 700, 800, 900 | 179 | Body | Inter | 300, 400, 500, 600, 700 | 180 | Code | JetBrains Mono | 400, 500, 600 | 181 182 ### CSS Variables 183 ```css 184 --font-heading: 'Space Grotesk', system-ui, sans-serif; 185 --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; 186 --font-mono: 'JetBrains Mono', 'Fira Code', monospace; 187 ``` 188 189 ## Logo / Icon 190 191 The MojoLlama logo mark is the llama emoji 🦙 on a Mojo gradient background. 192 - The llama represents the "Llama" in MojoLlama 193 - The gradient background (mojo purple → cyan) represents the "Mojo" part 194 - Always use on dark backgrounds 195 196 ### Logo Usage 197 - **Navbar**: 🦙 + "MojoLlama" in gradient text 198 - **Footer**: 🦙 + "MojoLlama" in gradient text 199 - **Favicon**: 🦙 on a rounded mojo gradient square 200 201 ## UI Patterns 202 203 ### Buttons 204 - **Primary**: Solid mojo gradient, `border-radius: 10px`, font-weight 700, lift on hover 205 - **Secondary**: Dark surface with border, subtle hover with mojo-light border 206 - **Install/Code**: Terminal-themed, dark background, cyan text, monospace 207 - **Ghost**: Border-only, used in nav 208 209 ### Cards 210 - Dark surface (`--surface`) with subtle border (`--border`) 211 - Hover: lift 2px, slight glow, top gradient border reveal 212 - Icon in a colored circle matching accent type 213 214 ### Navigation 215 - Fixed top, backdrop blur, border-bottom 216 - Left: logo | Right: links + CTA button 217 - GitHub badge: inline star count 218 219 ### Install Block 220 - Terminal window mockup with traffic light dots 221 - Green prompt `$`, cyan commands, dim output 222 - "Copy All" button in the footer bar 223 224 ## Component Hierarchy (Landing Page) 225 226 1. **Navbar** — Logo, Studio, Chat, GitHub stars, Launch Studio CTA 227 2. **Hero** — Badge (open source), Headline, Subtitle, Feature checks, CTAs, Install block 228 3. **Features** — 2-column grid of feature cards with dual CTAs 229 4. **Benchmarks** — Dark section with real benchmark table + visual bars 230 5. **Getting Started** — 3-step numbered cards 231 6. **Open Source** — License badges, GitHub star CTA 232 7. **Footer** — 4-column grid: brand + Product + Community + Ecosystem 233 234 ## Key Differentiators (Messaging) 235 236 Always lead with these when describing MojoLlama: 237 1. **Mojo language** — built in Mojo+MAX (unique among all competitors) 238 2. **CPU-first** — runs efficiently on CPU, not just GPU 239 3. **GGUF native** — optimized GGUF quantization pipeline 240 4. **Concurrent serving** — built-in, not add-on 241 5. **All-in-one** — inference, fine-tuning, quantization, serving, benchmarking 242 6. **Fully open source** — Apache 2.0, no proprietary features 243 244 ## Competitor Positioning 245 246 | Competitor | MojoLlama Advantage | 247 |------------|---------------------| 248 | vLLM | CPU-first, Mojo engine, all-in-one (not just serving) | 249 | SGLang | CPU-first, Mojo engine, simpler architecture | 250 | Unsloth | Fully open source, Mojo-native, no GPU required | 251 | LLaMA-Factory | CPU-first benchmarks, concurrent serving built-in | 252 | Ollama | Open source, programmable, fine-tuning pipeline | 253 | llama.cpp | Mojo engine, concurrent serving, all-in-one platform | 254 255 ## Social Proof Patterns 256 257 - GitHub star count in navbar and hero 258 - "Built with Mojo+MAX" badge 259 - Benchmark comparison tables (Mojo vs competitors) 260 - Real hardware specs in benchmarks (AMD Threadripper 3970X) 261 - Apache 2.0 license badge 262 263 ## Website Structure (www/) 264 265 ``` 266 www/ 267 ├── index.html # Landing page (sellable, branded) 268 ├── studio.html # MojoLlama Studio UI (training/quantization dashboard) 269 ├── chat.html # Chat interface 270 └── ... # Additional pages as needed 271 ``` 272 273 ## Build Spec 274 275 The `.onedev-buildspec.yml` deploys `www/` content to OneDev's static site at: 276 `https://git.bamse.cloud/a730/MojoLlama/~site/` 277 278 The PublishSiteStep must come BEFORE any container steps (container 279 isolation loses the checked-out files). The buildspec is structured as: 280 1. Build Kernels (job) — compiles C AVX2 kernels in parallel 281 2. Deploy Site (job) — publishes www/ to ~site, depends on Build Kernels 282 3. Quick Test (job) — fast validation for dev branches