Skip to content
←Back to Open Source

OPEN SOURCE DEEP DIVE

LLMLocal InferenceMoESpeculative Decoding

Magnitude: A Local LLM Inference Engine for Everyday Hardware

Magnitude is an open-source local LLM runtime that tiers sparse MoE experts across VRAM, RAM, and SSD, then combines device-tuned kernels, expert prefetching, speculative decoding, and elastic KV caches for everyday hardware.

magnitudedev/magnitude8.6kRustApache-2.014 min read

Magnitude is a Rust-based local inference engine for large language models. Its central problem is not how to wrap another agent framework. It is the lower-level question of whether an ordinary computer can keep a capable open-weight model responsive when weights, context caches, and concurrent requests compete for the same limited memory. The project ships a desktop app, a command-line interface, a container, and a local service, but its core asset is the inference runtime: weight tiering for sparse mixture-of-experts models, device-specific numerical program generation, speculative decoding, and shared state.

Treating Magnitude as an agent product would set the wrong expectation. It does not plan tasks, call tools, or own a workflow. It exposes local models to Pi, OpenCode, Hermes, Codex, Claude Code, Cline, and other clients. That boundary matters because agents generate the workload Magnitude is designed to survive: long prompts, repeated turns, multiple sessions, and calls that can arrive close together.

Start with the memory wall, then tier the model

The usual local-inference question is whether a model fits entirely in VRAM. That is the right framing for a dense model, whose complete weight set is needed on every step. Sparse mixture-of-experts models relax the premise. The total parameter count can be large while only a small fraction of experts activates for each token. Magnitude describes the common activation rate as roughly five percent. Shared layers, routing machinery, the working set, and frequently selected experts matter far more than the complete checkpoint on every step.

Magnitude therefore divides storage into three tiers. GPU memory or unified memory holds shared layers, active working space, and the hottest experts. System RAM holds the next tier of frequently used experts. The SSD holds the rest. Before the GPU asks for an expert, the runtime attempts to predict the upcoming demand and move weights from SSD to RAM and then toward the device. This is not operating-system swap, and it is not a blind page-in of the entire checkpoint.

Tier Primary contents Effect on latency
VRAM or unified memory Shared layers, active workspace, high-hit experts Fastest path; determines whether decode can start immediately
System RAM Next-tier experts, pending state, reusable caches Requires a host-to-device transfer, usually cheaper than storage
SSD Cold experts and temporarily unused weights Storage bandwidth and random-read latency dominate

The tiers are not fixed partitions. The runtime adjusts the expert bank as device room, host memory, request demand, and cache value change. A single memory ledger covers every committed byte, reclaimable cache, and external-process footprint, so the engine does not confuse nominal free memory with memory it can safely consume. Under pressure it releases cache, then considers preemption, and unloads a model only after cheaper options fail. The order is important because an unnecessary unload forces the next request to pay the entire model-start cost again.

The expert bank is a predictive streaming scheduler

Magnitude treats the expert set as a bank that can be replaced as demand changes. A packed batch can combine expert work from several requests, turning many small reads into more suitable transfer units. A hit uses the resident copy. A miss triggers a decision about where to fetch from, when to fetch, and whether the likely next step justifies a read-ahead. The scheduler compares locality, recent use, bytes released by eviction, and the cost of bringing the data back later.

The hard part is not the existence of a cache. It is the ordering between reading and computation. If the GPU has already issued a matrix operation before the runtime starts loading an expert from SSD, the streamed model still stalls and the extra storage tier merely acts as slower memory. Magnitude uses upcoming-expert prediction and prefetching to shorten that path. Speculative decoding adds another source of lead time: work for guessed future rows may begin before acceptance is known.

The engine documents that guessed work cannot contaminate accepted state. A normal decode step has one exact row that must commit, followed by optional acceptable rows from an external drafter. A front row may run farther ahead, but it is never accepted directly. It prepares reads and computation for a position that a later round might confirm. If the guess fails, only the opportunity cost of the read and calculation is lost. This distinction lets the runtime be optimistic about physical work while remaining conservative about logical history.

Seismic turns numerical structure into a program for the current chip

Magnitude calls its numerical execution layer Seismic. Seismic does not merely dispatch a fixed kernel to each backend. It treats authored computation, legal physical mappings, precision constraints, and device capabilities as a candidate space. The compiler may change tiling, thread cooperation, storage layout, communication, and launch order without changing the meaning of the operation. The runtime then binds and executes the selected implementation on CPU, Metal, CUDA, or Vulkan.

The design document describes an optimality target: for a fixed computation, allowed behavior, deployment, and objective, the candidate domain should contain every potentially legal realization, and selection should choose the best one. A practical engine cannot enumerate an infinite space, and Magnitude acknowledges that finite measurements do not prove global optimality. Its implementation establishes a default, measures representative workloads, explores structurally different candidates, retains complete programs, and checks the winner across the required numerical scope. The goal is a reliable improvement inside a bounded first-load budget, not a mathematical proof that no faster program exists.

The default tuning allowance is about sixty seconds. During that period Magnitude runs legal configurations on the actual chip, including choices such as tile size, launch geometry, and data movement, and keeps a winner that preserves numerical behavior. Tuning records are tied to the device, driver, and program identity, so later loads can reuse evidence. This is the operational answer to hand-tuning kernels for every model and chip pair: model loading becomes slower once, but the runtime can select native programs for the machine in front of it.

Seismic also owns native-program persistence. An artifact is addressed by its rendered source, entry, toolchain, device, driver, and formation code. A load checks the artifact’s digest before using it, reducing the chance that damaged or replaced bytes are treated as executable code. Users share a program cache across processes, while tuning evidence remains a separate record. That separation lets the system avoid repeated compilation without pretending that an old driver measurement automatically describes a new driver.

Speculative decoding is more than an extra model

Magnitude supports two sources of speculation: a separate drafter model and a prediction head embedded in the main model. A drafter proposes several future tokens, and the target verifies them in one forward pass, accepting the longest correct prefix. An embedded head can produce guesses along the target model’s own decode chain. Either form can spread a large weight read across multiple potential output tokens. When the guesses are accurate, verification of several tokens can approach the weight-read cost of one ordinary decode. When they are poor, the return shrinks or disappears.

Decode, verification, and front work share one row shape. The first row is exact and always commits. Later rows are ordered guesses. Verification rows may extend the accepted prefix. Front rows may execute early but are never accepted directly. Stop tokens are not accepted as proposals, and grammar matchers advance only after token acceptance. This shape cleanly separates physical throughput from logical correctness: the device can do more work in parallel, while the request’s visible history advances only on evidence.

That distinction fits agent workloads. Coding, tool use, and long conversations can benefit when a device-side decode chain amortizes scheduling and weight movement across several accepted tokens. At the same time, concurrent sessions have different prefixes, stop conditions, and grammars. Magnitude keeps drafter state, grammar state, and the output cursor request-local. A failed guess or an invalid selection does not rewrite another request’s accepted state in the same packed batch.

KV state is designed for concurrent agents

Long-context inference also spends heavily on key-value state. A naive implementation treats it as a buffer that grows until VRAM is full. Magnitude places it under the same memory ledger as weights and caches, prices different holders, and permits shared physical history across retained prefixes. Checkpoints retain existing claims. A fork copies ownership descriptions instead of duplicating an entire history tensor. Appends use an exclusive tail or a new extent, so a later write cannot mutate history that a checkpoint still exposes.

When capacity is insufficient, the scheduler yields low-value cache first and eventually selects requests to preempt. An evicted request keeps its prompt, accepted tokens, grammar progress, queued output, cursor, and termination conditions while releasing numerical state. If the request runs again, replay reconstructs that state from retained history and input semantics. Replay costs computation, but it avoids silently losing already accepted output. Models can also unload after an hour without requests or when system memory pressure makes that the safer outcome.

Checkpoint and fork operations expose this state model to callers. A checkpoint requires reconciled numerical state and a matching logical position. A fork gets a distinct request identity, proposal state, grammar matcher, output queue, and recovery protection. These operations are useful for exploring several agent branches from a shared context or comparing tool outcomes without redoing the full prefix. Replay does not resample, emit output, or advance the matcher; it restores accepted history rather than generating it a second time.

The engine, service, and numerical runtime have separate jobs

Magnitude does not place every responsibility in one scheduler loop. Model loading owns artifacts, metadata, architecture descriptions, and weight roles. The family registry is the single list of supported model families. The model executor owns programs, packed inputs, sequence advances, and requested readout. Logical state owns positions, visibility, sharing, tentative advances, and accepted history. Generation owns proposals, acceptance, grammar, publication, and recovery. The service owns admission, phase selection, capacity negotiation, and fairness. Seismic owns physical allocation, binding, submission, and completion.

This separation has concrete effects. One packed execution can serve several independent requests, but completion and acceptance are reconciled per request. A row-local failure does not have to discard progress already accepted by its peers. When prefill and decode compete, decode runs first, while prefill accrues priority according to a configured service share. Cost spans preparation through observed completion; emitted token count is not treated as a clock. Resident experts, prefix hits, preemption debt, and waiting age all affect scheduling without bypassing resource safety.

The service layer observes generic work, completion, and capacity prices rather than tensor layouts or backend objects. Live execution objects remain with their owning thread. Host boundaries carry immutable inputs, options, constraint plans, and bounded results. On a desktop, this reduces coupling between the UI, transport, and background tuning. In a container service, it also gives cancellation, shutdown, completion reconciliation, and fatal-failure propagation an explicit owner.

A narrow API with several deployment paths

Magnitude listens on port 10100 while the desktop app or a serve process is running. OpenAI-compatible clients use http://127.0.0.1:10100/inference/v1; Anthropic-compatible clients use http://127.0.0.1:10100/inference/anthropic. Clients append their own chat or message paths. Local callers do not need a key by default. Other devices need the server’s configured network key.

The inference API is deliberately narrow: list models and generate text. Downloading, deleting, loading, stopping, choosing drafters, and managing model folders belong to the app or command-line interface. A client must use the exact model ID returned by the API; a display name is not a substitute. The first request may load a model and therefore takes longer than later requests. Local users can preload the model to avoid that cold start.

Command-line users can install the server with a script and run magnitude serve. For an isolated environment, the official container exposes the browser app, both inference protocols, and the command-line tool inside the container. NVIDIA containers reach GPUs through the NVIDIA Container Toolkit, while AMD and Intel GPUs use Vulkan. Containers on a Mac run in a Linux virtual machine and cannot reach the Apple GPU, so they use the CPU; the native macOS app is the path to Metal acceleration.

docker run -d --name magnitude --restart unless-stopped --gpus all \
  -p 10100:10100 -v magnitude:/data \
  magnitudedev/magnitude

That command assumes a Linux host with an NVIDIA driver and the container toolkit already installed. Other configurations need different device flags. The named data volume is not optional decoration: it preserves models, settings, and the network key across container replacement. Magnitude includes one-click or guided connection support for Pi, OpenCode, Hermes, OpenClaw, Codex, Claude Code, Oh My Pi, and Cline. Unlisted clients can use the compatible API.

Model and hardware limits matter

The current catalog names seven supported families: Qwen 3.5 through 3.8, Gemma 4, LFM 2.5 and 3, Nemotron 3 and 3.5, Muse Glimmer, DeepSeek V4.1, and GLM-5.3 Flash. Magnitude can run different quants and fine-tunes within those families, as well as compatible GGUF files already on the machine. It is not correct to summarize this as support for arbitrary models. A file can be structurally readable and still be unloadable because its architecture family has not been implemented.

The GPU backends also have explicit floors. Metal targets Apple silicon running a recent macOS. NVIDIA’s CUDA path starts at Ampere and requires a sufficiently recent driver. Vulkan serves some non-NVIDIA GPUs and older cards that meet the capability requirements. A CPU backend remains available when no supported GPU is present. The user-facing hardware page describes Vulkan 1.1 or later, while the internal compatibility document states a higher device floor for the complete backend. Those statements have different scopes; the runtime’s hardware discovery and compatibility checks should decide whether a particular device qualifies.

Memory sets the practical limit. Device memory must hold at least the shared layers and active experts. More room for experts in VRAM or system RAM produces steadier speed. A model that cannot keep its minimum working set in memory does not run. A model that only spills cold experts can run but will be slower than one that remains resident. SSD random-read performance directly affects the streamed portion. A multi-GPU machine currently uses one GPU; this is not a tensor-parallel implementation.

Context length is another deliberate constraint. If the requested full context does not fit, Magnitude selects the largest power-of-two context that does, never below 32K tokens. The floor exists because a coding agent’s system prompt, tool definitions, and conversation consume substantial space even before the task grows. This is a deployment compromise, not lossless context extension. Users who require longer contexts should choose a smaller model, a lower quant, or a machine with more memory rather than assuming expert streaming solves every cache problem.

Who should use it, and how to read the performance claim

Magnitude is aimed at developers with a Mac, a consumer GPU, or a CPU-only machine who want open models behind a coding agent or local chat without building a complete serving stack. Its distinctive work is the combination of family-specific implementations, on-device kernel tuning, sparse-expert tiering, and multi-session cache management. A user who only needs a tiny dense model, or a team that already operates a mature multi-GPU cluster, may not receive the same benefit from these mechanisms.

The project is licensed under Apache 2.0, while model weights retain their own licenses. Once a model is loaded, prompts, files, and generated results stay on the machine, with no per-token charge. Local execution is not automatically secure: exposing network access still requires careful key management, listening scope, host allowances, and container review.

The repository claims more than twice the speed of Ollama and links to the project’s own benchmarks. That should be read as an author claim under the project’s chosen models, hardware, and test conditions. This article did not independently reproduce it, so it is not a universal performance guarantee. The more useful technical conclusion is that Magnitude attacks several separate bottlenecks: first-load kernel selection, expert read-ahead, speculative verification, and state sharing. Whether those mechanisms pay off on a particular machine should be measured against the actual quant, context length, concurrency, and storage device.

This review examined repository commit 929ec8f24da84317810b81c6f9d7733753f6eb9a, focusing on the project overview, model catalog, hardware and container documentation, API documentation, engine architecture, scheduling, state, generation, tuning, and Seismic compatibility material. Magnitude is evolving quickly. Supported families, hardware floors, and tuning policy may change, so these conclusions describe the design visible at that commit rather than a permanent promise about later releases.

Related Projects

As an Amazon Associate, we earn from qualifying purchases.