Run 320B MoE Models on a Mac: On-Device LLM Limits, Quantization, and Memory Planning
An open-source 320B flagship model was ported to local inference hardware less than 24 hours after release, but a fast port does not mean a model is ready for on-device use. This article explains why a low active-parameter count does not solve the memory problem, how to calculate the resident weight footprint and KV cache budget, and where low-bit quantization breaks numerical accuracy. It also covers shared experts, module trimming, toolchain version pinning, and a practical checklist for deciding whether your hardware can run these models locally or needs a cloud fallback.
1. The Signal: A 320B Model Ported in Under a Day
An open-source flagship model with roughly 300 billion total parameters and native support for million-token context was ported to local inference hardware in less than 24 hours after release. This is becoming routine. Public weights, plugin-based inference frameworks, and mature quantization toolchains now compress adaptation work from weeks to hours.
The common mistake is reading a fast release cadence as “on-device is ready.” Community ports answer one question: can it load and generate text. Production deployment cares about three different things: numerical correctness, whether it fits in memory, and whether throughput is usable. Two “budget flagship” models released on the same day gave completely different answers to those three questions.
2. Why Fewer Active Parameters Does Not Save On-Device Inference
Mixture-of-experts (MoE) marketing usually says the same thing: total parameters are huge, but each token only activates a small fraction. That holds on the server side, where requests can be scheduled dynamically and inactive experts can stay in storage or on a remote node. On-device is different. Inference devices use unified memory shared by the CPU, GPU, and neural accelerator, and there is no low-latency path to swap experts in from disk on demand.
The result is a hard constraint: all expert weights must stay resident in unified memory. A model with 300 billion total parameters, just over 10 billion active per token, a mix of linear and sparse attention, and native million-token context exceeds 300 GB in weights alone at 8-bit, and still sits around 180 GB after 4-bit quantization. That makes it an experiment for a 256 GB or larger unified-memory workstation, not a candidate for a high-end laptop.
A second model offers a contrast: a backbone of just over 120 billion parameters plus an n-gram embedding table of more than 50 billion entries, with only 6 billion active per token. The key difference is that the n-gram table can stay resident in memory and be queried by lookup instead of participating in dense per-token computation, which spreads the memory and compute pressure much thinner. After quantization, a local package of about 113 GB runs on a device with hundreds of GB of unified memory, and vision input is preserved as well.
The engineering takeaway: when assessing on-device feasibility, the first metric to check is not active parameters but total resident weights divided by the target bit width, plus context cache overhead.
3. Context and Cache: The Underrated Second Memory Consumer
Native million-token context cuts both ways on-device. The attention cache grows linearly with sequence length. Hybrid linear attention compresses the cache for most layers into a fixed-size state, but sparse attention layers still need to retain keys and values within their window. A rough capacity model:
Total memory ≈ weights (GB) + Σ(per-layer cache) × concurrency + runtime and framework overhead (reserve 10%-20%)Context cache ≈ 2 × num_layers × num_kv_heads × head_dim × sequence_length × bytes_per_element
The practical order is to validate the pipeline with a short context of two or three thousand tokens first, then apply pressure in steps at 8k, 32k, and 128k, watching whether the memory curve stays linear and whether swapping kicks in. Skipping this and going straight to maximum context usually gets the process killed, not a verdict that “the model is bad.”
4. Low-Bit Quantization: The Numerical Traps Behind Smooth Output
The most typical problem with same-day community ports is not slowness. It is “fluent speech, wrong math.” Three root causes show up repeatedly.
First, numerical issues in routing and activation. Gate scoring, expert normalization, and activation functions use different default precisions across frameworks. After low-bit dequantization, the error is amplified, and a token that should go to expert A goes to expert B instead. The symptom is normal prose with factual errors.
Second, quantization granularity is too coarse. Per-channel quantization is sensitive to outliers, and mixed precision (keeping sensitive layers at higher bit widths and pushing the rest to 2-bit) is usually far more stable than a uniform global 2-bit scheme. Reported measurements show 2-bit mixed quantization shrinking the package to about 37 GB and 4-bit to about 74 GB, with both delivering throughput around thirty tokens per second. That indicates the bottleneck in this range is memory bandwidth rather than compute, so lowering bit width further buys no speed.
Third, extreme low bit widths break outright. A 1-bit scheme can shrink the package to around 75 GB, but there are reports of output collapsing completely, along with visible degradation at 2-bit. There is no free lunch between usability and size.
A minimal validation script to catch numerical problems before scaling up:
# 1) Short-context smoke test: confirm the pipeline and the memory curve# 2) Numerical alignment: fix the prompt and compare logits between the reference and on-device implementations# 3) Consistency: compare token by token under greedy decoding to locate the first divergencePROMPTS = ["1+1=", "List three prime numbers:", "Translate the following sentence into English: It is raining today"]for p in PROMPTS:out = run_local(p, max_new_tokens=32, temperature=0.0)assert is_finite(out.logits), "NaN/Inf detected, check dequantization and normalization"print(p, "->", out.text)
The recommendation: make token-by-token alignment under greedy decoding the admission gate for an on-device port, rather than judging by a few smooth sample conversations.
5. Shared Experts and Load Imbalance
Newer architectures add shared experts and finer-grained expert splits alongside routed experts, in order to stabilize training and improve parameter efficiency. On-device, this creates a new problem. Shared experts are computed for every token and cannot be skipped, so they form an incompressible compute floor. Meanwhile, once the number of routed experts grows, an implementation without capacity limits or load balancing will hit a few experts repeatedly while others sit idle, and actual throughput falls below the theoretical value. The way to investigate is to enable expert hit counters and check whether the distribution has a long tail.
6. Module Trimming: Cut Vision and Multi-Token Prediction First
The standard practice for on-device ports is to get pure text working first. The vision encoder and multi-token prediction (the extra prediction heads used for speculative decoding) are complex and depend on many operators, so most ports remove them before validating the backbone. Trimming needs an order and a rollback plan:
- Disable multi-token prediction and confirm backbone throughput and correctness;
- Remove the vision branch, keeping only the text tokenizer and template;
- Once the backbone passes, add modules back one at a time, rerunning the alignment tests each time.
Note the tradeoffs explicitly: removing vision means losing multimodal capability, and removing multi-token prediction means losing the speedup from speculative decoding. These are deliberate choices and should be written into the plan rather than left implicit.
7. Toolchain and Version Strategy
On release day, often only some paths in the on-device ecosystem are usable. A general-purpose local runner may still be cloud-oriented, desktop inference tools need time to catch up, and the relevant changes in standard inference engines and training or fine-tuning frameworks may not be merged to mainline yet. The workable strategy is to prefer paths that are already merged that day and have quantization artifacts available. For branches not yet merged, pin the commit hash and build your own environment, so the same weights do not produce different results on different machines.
One general rule: do not reuse an old runtime environment for a new architecture. Upgrade to a version that supports the architecture and pin dependency versions. The model template and chat format must correspond strictly to the weight version, since a template mismatch is a hidden source of output that “suddenly gets worse.”
8. Decision Checklist: Can a High-End Consumer Device Run It?
- Unified memory at least 1.3× the target quantized size, with large-memory swapping disabled;
- Prefer architectures where most parameters can be served by lookup and only a few participate in dense computation;
- Start quantization at 4-bit, treat 2-bit as experimental only, and do not consider 1-bit for production;
- Before going live, complete three checks: short-context smoke test, logits alignment, and expert hit distribution;
- Add vision and speculative decoding back as needed, and document the capability loss clearly;
- If the device is short on memory by an order of magnitude, a cloud API or managed inference service is more economical. The value of local deployment lies in keeping data in-house and working offline.
9. Cloud Fallback and Device-Cloud Collaboration
On-device is not all or nothing. If you need long context, multimodality, or high concurrency, a general cloud approach works: use a container platform to host the inference service, object storage for weights and datasets, a message queue to smooth request spikes, and logging plus monitoring and alerting to track time to first token, throughput, and failure rate. Baidu AI Cloud typically provides these general capability categories in such scenarios, making it easier to scale a model validated on-device to the server side and form a “test on-device, fall back to cloud” structure.
10. Conclusion
Two flagship models released on the same day had completely different on-device fates: one remains an experiment for large-memory workstations, while the other was usable for conversation on a high-end device that same day. The difference was not active parameters, but total resident weights, numerical stability under quantization, and whether the architecture allows some parameters to stay resident as lookup tables. Using these three points as an evaluation framework is more valuable than chasing release speed.
