Back to Docs / Engineering

Running Large MoE Models Faster on Mac: TokenFlow’s End-to-End Inference Architecture.

Tokkey Engineering · Apple Silicon & Metal · M5 Pro (48 GB Unified Memory) · 8 min read
Tokkey plugged into the front USB-C port of an Apple Mac mini
Tokkey connected to Mac mini. The external device delivers Apple Silicon–adapted Metal kernels; compute executes locally on host silicon.
Abstract

Large language models are moving from the cloud to local devices, yet the vast majority of consumer hardware still cannot run them effectively. Built for Apple Silicon, TokenFlow unifies its kernel ecosystem, weight organization, budgeted residency, and lookahead prefetching into a single end-to-end execution pipeline—turning static memory ceilings into dynamic effective capacity so the same Mac can host larger models and keep its compute saturated.

Prefill · Full residency
2,828.12 tok/s
Decode · Full residency
114.03 tok/s
Prefill · RGE=0.5
96.1% retained
Decode · RGE=0.5
72.1% retained

1Why “Downloadable” Still Doesn’t Mean “Runnable”

The open-weight ecosystem has matured rapidly: weight formats are converging, low-bit quantization is widely available, and runtime interfaces are standardizing. Downloading a frontier model takes minutes. Yet an uncomfortable reality remains: on the vast majority of existing consumer laptops and desktops, large models still fail to run.

The bottleneck is rarely raw compute—it is effective memory capacity and data movement latency.

A single inference pass must simultaneously fit four competing allocations in memory: the full set of expert weights (governed by total parameter count, regardless of how many experts are active per token), a KV cache that grows linearly with context length, intermediate scratchpads for kernel execution, and everything already claimed by the OS and background apps. Subtract all of that from nominal RAM, and what remains is your true memory budget.

Figure 1 · Conceptual memory model

Four competing allocations inside nominal RAM

2×
Nominal unified memory ceiling Fits in RAM
KV cache scales strictly linearly with context length (1× → 2× → 4× → 6×). Beyond RAM capacity, naive mmap collapses into disk paging while TokenFlow dynamically budgets expert residency.

While Mixture-of-Experts (MoE) architectures reduce per-token FLOPs through sparse activation, they do not proportionally reduce memory residency requirements. Beyond capacity lies bandwidth and latency: whenever data must shuttle between unified memory and external storage, actual throughput depends entirely on whether that transfer can be hidden behind active computation.

Existing open-source approaches generally rely on three strategies, each with a hard ceiling:

Aggressive low-bit quantization

Shrinks model size by a constant factor, which cannot bridge order-of-magnitude parameter gaps and introduces dequantization overhead.

Memory-mapped (mmap) lazy loading

Collapses into page-by-page disk reads the moment the working set exceeds available RAM, exposing storage latency and causing a cliff-edge drop in speed.

Full-residency loading

Locks usability behind top-tier hardware specs, pricing out most existing machines.

As a result, “can load” and “can run smoothly” remain two completely different things.

TokenFlow’s thesis

To make large MoE models genuinely runnable on existing hardware, we must expand effective capacity itself rather than chasing marginal gains in compression ratios. When weights are organized at schedulable granularity, residency scales dynamically with the available budget, data is prefetched ahead of compute, and kernels have native implementations across bit-widths and inference phases, memory capacity stops being a hardware procurement problem and becomes a systems scheduling problem.

The headline numbers from an M5 Pro (48 GB unified memory): under full residency, TokenFlow achieves 2,828.12 tok/s in Prefill and 114.03 tok/s in Decode. Even when the memory budget is cut in half (RGE=0.5), Prefill retains 96.1% of its throughput and Decode retains 72.1%—with no cliff-edge degradation.

These results are not driven by an isolated trick, but by three interlocking mechanisms inside TokenFlow’s execution engine: Phase-Aware Kernels, Lookahead Prefetching, and Budgeted Residency—answering how to compute, when to move data, and what to keep in memory.

2Co-Design: An Execution System Built for Apple Silicon

TokenFlow is not a thin wrapper bolted onto a general-purpose framework. It is a co-designed execution stack built around Apple Silicon’s unified memory architecture, GPU parallelism, and Metal execution paths—aligning model loading, weight layout, task scheduling, and low-level kernels.

Within this architecture, every layer shares execution state rather than operating in isolation:

Figure 2 · Co-designed execution stack

Four coupled layers sharing execution state

Select a layer

Weight Layer

Organized at expert granularity into addressable, independently swappable units.

→ Shares expert addresses, bit-width, and exact working-set footprint with the Runtime.

Point optimizations yield only local gains. Sustained end-to-end throughput requires aligning data layout, scheduling, prefetching, and kernels so the GPU spends its time computing rather than waiting.

3Three Interlocking Mechanisms

3.1Phase-Aware Kernels: Solving How to Compute

LLM inference consists of two fundamentally different workloads:

Figure 3 · Phase-aware routing
Same math operation, distinct Metal execution paths
Shared Op MatMul · MoE · Dequant Phase Router Phase · Bit-width · State Prefill Metal kernel Massively parallel · 2,828.12 tok/s Decode Metal kernel Streaming latency · 114.03 tok/s
Prefill · Compute-bound

Processes the input prompt in parallel, governing time-to-first-token (TTFT) on long prompts and complex documents—a compute-bound, massively parallel workload.

Decode · Latency-sensitive

Generates output tokens autoregressively one step at a time, governing interactive fluency—a latency-sensitive, fine-grained streaming workload.

Rather than forcing one static strategy across both regimes, TokenFlow implements Phase-Aware Kernels: the same mathematical operation is routed to distinct, phase-optimal Metal implementations depending on whether the engine is in Prefill or Decode, as well as the current bit-width and residency state.

Peak hardware FLOPS do not automatically translate into token throughput. Matrix multiplications, low-bit dequantization, expert routing, state updates, and attention all require hardware-faithful kernel translation. TokenFlow treats its Apple Silicon kernel ecosystem as core infrastructure across three dimensions:

Model-structure adaptation

MoE workloads are inherently uneven—each token activates only a subset of experts, and batch sizes per expert shift dynamically. Custom kernels eliminate the redundant intermediate steps required by general-purpose operators.

Hardware-native execution

Tuned for Apple Silicon’s unified memory and GPU threadgroup model to balance compute, memory access, and scratchpad reuse across low-bit weights and expert routing.

Runtime coordination

Kernels are aware of data arrival, inference phase, and downstream dependencies, enabling continuous pipelined execution rather than isolated kernel launches.

Tokkey (External device) Hosts Apple Silicon kernel library Host Mac · GPU & Unified Memory Dispatches Metal kernels and executes 100% of compute locally

Note on Deployment Architecture: The external device hosts the Apple Silicon–targeted kernel library. Once connected to a Mac, the runtime dispatches to the adapted Metal kernels, while all actual computation executes on the host Mac’s GPU and unified memory. The device serves purely as a delivery vehicle for software and kernel capabilities—it does not add external physical GPU compute.

3.2Lookahead Prefetching: Solving When to Move Data

In local inference, compute units are often idle not because math is slow, but because data hasn’t arrived yet—an activated expert isn’t resident, or the next buffer isn’t ready, stalling the GPU pipeline.

Figure 4 · Pipeline execution

Hiding data transfer behind active compute

Router Prefetch Metal GPU Time → Route N+1 Route N+2 Route N+3 Stage N+1 Stage N+2 Stage N+3 Layer N Layer N+1 Layer N+2 Layer N+3
Routing signals trigger asynchronous staging half a step ahead of compute, eliminating GPU idle bubbles.

TokenFlow elevates data movement from an ad-hoc, inside-the-kernel fallback to a global runtime Lookahead Prefetching policy that keeps data transfer half a step ahead of compute:

  • Compute–Transfer Overlap: Asynchronously stages data likely needed in upcoming layers while current kernels are actively executing.
  • Execution-Paced Staging: Uses expert routing signals and context state to guide prefetch targets instead of blindly flooding memory.
  • Thrashing Prevention: Under tight budgets, prioritizes high-reuse weights so local hit-rate gains do not trigger global memory pressure.

The goal of lookahead prefetching is to squeeze idle wait time out of the execution pipeline, improving responsiveness and sustained generation (while TTFT, long-context behavior, and sustained endurance remain subject to dedicated workload benchmarks).

3.3Budgeted Residency: Solving What to Keep

Effective memory budget is never a static number—it fluctuates continuously with context length, concurrent requests, and background OS activity. Reserving worst-case memory at startup wastes capacity that could host a larger model; allocating purely on demand leaves the runtime blind under pressure.

TokenFlow treats residency as an explicit budgeting problem:

  1. 1. Weights are structured at expert granularity as addressable, swappable units.
  2. 2. At each phase, the runtime computes an active working set and tracks its exact memory footprint against the current budget.
  3. 3. When the budget tightens, eviction is not uniform—experts are ranked by expected reuse, retaining high-frequency experts while evicting cold ones. When the budget relaxes, upcoming experts are pulled back proactively before compute stalls.

TokenFlow exposes this budget control directly to the user via the RGE knob.

Figure 5 · Budgeted residency

Reuse-ranked eviction under the RGE knob

Illustrative working set (ranked by reuse) 16 / 16 resident
Prefill (M5 Pro 48 GB) 100.0%
2,828.12 tok/s
Decode (M5 Pro 48 GB) 100.0%
114.03 tok/s

Accordingly, we do not measure success by “how many gigabytes were saved,” but by “how much throughput is preserved under a given memory budget”—and whether performance degrades smoothly and predictably from full residency to constrained budgets, rather than collapsing into paging thrash.

4Benchmarks: Observed Performance on Apple Silicon

All measurements below were recorded on an M5 Pro with 48 GB of unified memory, focusing on Prefill and Decode throughput (measured in tok/s).

Figure 6 · Apple M5 Pro (48 GB)

4.1 Runtime Comparison (Full Residency)

Prefill throughput (tok/s)
Decode throughput (tok/s)

4.1 Runtime Comparison (Full Residency)

Model & Configuration Runtime Prefill (tok/s) Decode (tok/s)
Qwen3.6 affine, Full Residency TokenFlow 2,828.12 114.03
mlx-community/Qwen3.6-35B-A3B-4bit Lily 2,241.20 108.00
mlx-community/Qwen3.6-35B-A3B-4bit mlx-vlm 2,556.90 92.064

In this test run, TokenFlow’s Prefill throughput is ~26.2% higher than Lily and ~10.6% higher than mlx-vlm; Decode throughput is ~5.6% higher than Lily and ~23.9% higher than mlx-vlm.

Caveat: These figures reflect the specific configurations recorded in this run. Quantization equivalence between TokenFlow affine and the community 4-bit weights has not yet been formally verified; performance differences should not be attributed solely to the runtime, nor generalized across all hardware configurations and workloads.

4.2 GGUF Execution Path

Weights & Processing Runtime Prefill (tok/s) Decode (tok/s)
Qwen3.6-35B-A3B-UD-Q4_K_M.gguf TokenFlow 2,313.56 67.29
Same GGUF, converted via Kapitsa Kapitsa 1,031.00 73.80

On the GGUF path, TokenFlow delivers more than 2× the Prefill throughput (2,313.56 vs. 1,031.00 tok/s), while Kapitsa leads in Decode (73.80 vs. 67.29 tok/s). This contrast reinforces why Prefill and Decode must be evaluated as distinct execution regimes—a system’s behavior is a two-phase profile, not a single headline number.

4.3 Graceful Degradation Under Constrained Memory (RGE=0.5)

Comparing full residency against a 50% memory budget (RGE=0.5) on the same M5 Pro (48 GB) system:

Configuration Prefill (tok/s) Decode (tok/s)
Full Residency 2,828.12 114.03
Low Memory (RGE=0.5) 2,716.86 82.19
Throughput Retention vs. Full Residency 96.1% 72.1%

Cutting the residency budget in half still preserves 96.1% of Prefill throughput and 72.1% of Decode speed—demonstrating that budgeted residency and lookahead prefetching allow users to trade memory footprint for speed smoothly and predictably.

5Where TokenFlow Fits in the Industry Landscape

Edge inference optimization is advancing along several distinct architectural fronts:

Perplexity

Model-specific specialization (Lily)

Perplexity’s public overview of Lily highlights model-specific runtimes, staged execution, and custom Apple Silicon kernels.

Apple Silicon tuning

Hardware-profiled memory planning (Kapitsa)

Kapitsa’s public release notes focus on MoE support, memory planning, device profiling, and Apple Silicon–specific tuning.

Wulianghuo

Heterogeneous edge orchestration (Ember)

Ember (publicly disclosed by Wulianghuo) emphasizes heterogeneous scheduling across CPU, GPU, NPU, and storage-compute coordination.

TokenFlow

End-to-End Coherence

Rather than treating kernels, runtime scheduling, storage access, and hardware as separable layers, we optimize the entire path from “data is needed by compute” to “data is ready in place.”

Each of these directions pushes local AI forward. That reflects our core engineering conviction: true edge performance comes not just from faster compute units, but from eliminating pipeline stalls, aligning data layout with sparse workloads, and turning memory constraints into scheduling freedom.

6Conclusion: Making Local Models Feel Native

Running large MoE models locally is crossing the threshold from “technically possible” to “effortlessly usable.” Users shouldn’t have to care how many Metal threadgroups a kernel dispatches or how expert weights are paged behind the scenes. What matters is whether the model responds immediately, streams smoothly, and runs reliably on the machine already on their desk.

TokenFlow converges these systems layers into a single, cohesive execution pipeline—translating hardware potential through custom kernels, orchestrating phases in the runtime, and eliminating data stalls through lookahead prefetching and budgeted residency.

“When model architecture, scheduling algorithms, kernel ecosystems, and silicon truly resonate, local AI stops feeling like something crammed onto a device—and starts running as if it were native to it.”

Ready to run large local MoE models on your Mac?
Copied to clipboard

Your AI,
on your Mac.

EARLY ACCESS

Be first to try Tokkey

Reserve for $5
© 2026 OneToken Intelligent Technology Co., Ltd.*On supported Macs. Model compatibility varies. Hardware and resource blocks are illustrative.