Running Large Language Models on a 64GB Unified Memory Machine: A Practical Model Selection and Scheduling Guide
This article explains how to select and schedule large language models on a single 64GB unified-memory machine running as a local inference node. It separates two limits that are often confused—the capacity wall (weights and KV cache must fully fit in memory) and the bandwidth wall (decoding speed depends on how many weights are read per token)—and shows how to estimate each. It walks through weight-size and quantization math, KV cache growth with context length, a sample 64GB budget, and why low-activation MoE models suit interactive use. It then maps three workloads (interactive, coding, offline batch) to concrete model choices, describes how to isolate the node's resources, and provides a LAN setup with checkpoint-resume batch scripts. Use it as a methodology reference; actual numbers vary by hardware, inference framework, and model implementation.
1. Background and the Core Problem: How Large a Model Can 64GB Run?
Running large language models locally has become a routine choice for many developers and teams handling coding assistance, document writing, and data processing. For reasons such as keeping data on the device, working offline, and controlling long-term costs, some users prefer to run models directly on a personal computer or workstation.
These devices typically use a unified memory architecture: compute units such as the CPU and GPU share a single pool of physical memory rather than separating dedicated VRAM from system RAM. A direct consequence is that memory used by the model competes with memory used by the operating system and applications. So the intuition that “as much memory as the device has, that is how large a model you can load” needs a discount.
This involves two independent but often-confused performance boundaries:
- The capacity wall: Model weights and the KV cache must reside fully in memory; if they don’t fit, the model cannot run.
- The bandwidth wall: During autoregressive decoding, every generated token requires re-reading the relevant weights, and the read speed is limited by memory bandwidth. If bandwidth is insufficient, generation speed cannot go up.
Capacity is determined by memory size. Speed is determined jointly by bandwidth and by how many weights must be read per token. Much of the confusion practitioners run into—such as “the model loads but every character takes several seconds” or “more parameters is actually slower”—traces back to conflating these two boundaries.
This article centers on a typical scenario: a 64GB unified-memory local device acts as an inference node, called over a LAN by another device. The device itself runs no graphical applications and keeps only the inference service, dedicating as much memory as possible to the model. The methodology and scheduling approach below are built for this scenario. All specification figures come from quantitative estimation and observation in this scenario; they will differ across devices, inference frameworks, and model implementations, so treat them as a methodological reference rather than absolute performance benchmarks.
2. Capacity Budget: First Confirm It Fits, Then Talk About Speed
2.1 Weight Size and Quantization Bit Width
Setting aside the KV cache, the memory footprint of model weights can be approximated as:
weight memory (GB) ≈ parameters (billions) × bytes per parameter
Common precisions use the following bytes per parameter:
| Weight precision | Bytes per parameter |
|---|---|
| FP16 / BF16 | 2 |
| 8-bit quantization | 1 |
| 6-bit quantization (with a small high-precision portion) | ~0.75–0.8 |
| 4-bit quantization | 0.5 |
Take a model of roughly 35 billion parameters as an example:
- FP16 needs about 70GB, which 64GB alone cannot hold;
- 8-bit quantization needs about 35GB;
- 6-bit quantization needs about 26GB;
- 4-bit quantization needs about 17–18GB.
Quantization, then, is the key technique for fitting a large model into 64GB.
2.2 The KV Cache: An Easily Overlooked “Hidden Heavyweight”
Transformer-style models must cache the Key/Value tensors of historical tokens during decoding—the KV cache. For an attention structure without special sharing, the cache size can be estimated as:
KV cache (GB) ≈ 2 × layers × KV heads × head dimension × bytes per element × sequence length ÷ 1024³
The “×2” accounts for one copy each of Key and Value. Assume a model with 40 layers, 4 KV heads per layer, and 128 dimensions per head:
- At FP16, each token needs about 80KB;
- 100K tokens need about 7.6GB;
- 200K tokens need about 15.3GB.
Attention structures differ significantly across vendors. Some models use grouped-query attention, where multiple query heads share a small number of KV heads, making the KV cache much smaller. So the formula above should be applied together with the specific model structure. The point is not to compute an exact figure but to build a quantitative awareness that “the longer the context, the more memory the cache consumes.”
2.3 A Sample 64GB Budget Allocation
| Use | Budget (GB) | Notes |
|---|---|---|
| Operating system and base services | 3–6 | Rigid overhead that cannot be compressed |
| Inference framework runtime | 2–5 | Tensor buffers, scheduling, temporary computation, etc. |
| Model weights | 18–27 | Depends on model size and quantization bit width |
| KV cache | 1–16 | Roughly proportional to context length |
| Safety margin | 5+ | To avoid triggering memory swapping |
At a fully loaded context (200K tokens), the KV cache may consume more than 10GB, which noticeably narrows the model options. After loading the model, first watch the memory-pressure indicators. Once sustained memory compression or swapping appears, generation speed drops off a cliff; at that point, prioritize shortening the context or lowering the weight bit width.
3. The Key Insight: Total Parameters Set the Capacity Wall, Active Parameters Set the Bandwidth Wall
3.1 How the Two Model Types Differ Mechanically
Today’s mainstream models fall into roughly two categories:
- Dense models: Every token passes through all parameters during computation.
- MoE (mixture-of-experts) models: Composed of multiple “expert” subnetworks and a routing mechanism. Each token is routed to only a few experts, so the parameters that actually participate in computation are a subset of the total—the active parameters.
An analogy: a dense model is like a doctor reading every medical record; an MoE model is like a triage desk that refers each patient to the relevant specialist, calling in only the departments needed. The overall scale is not small, yet the burden of any single request is far lighter.
3.2 A Theoretical Bandwidth Estimate
Devices with unified memory typically offer bandwidth on the order of hundreds of GB/s. The decoding bottleneck is mainly the per-token weight reading, so the theoretical upper bound on generation speed can be roughly estimated as:
theoretical speed (tokens/s) ≈ memory bandwidth (GB/s) ÷ weights read per token (GB)
Assume 400GB/s bandwidth. The estimates for various model forms are as follows (not measured benchmarks—only for understanding the order of magnitude):
| Model form | Weight size | Read per token | Theoretical speed ceiling |
|---|---|---|---|
| Dense (~27B params, 6-bit) | ~20GB | ~20GB | ~20 tokens/s |
| Low-activation MoE (~35B total / ~3B active, 6-bit) | ~26GB | ~2.3GB | ~170 tokens/s (theoretical) |
| Higher-precision MoE (~26B total / ~4B active, 8-bit) | ~26GB | ~4GB | ~100 tokens/s (theoretical) |
An MoE model reads only part of the expert weights per token, so at a comparable memory footprint its generation speed can be an order of magnitude higher than a dense model. This is why “loading a larger model can actually respond faster.”
This estimate ignores the overhead of attention computation as context grows, as well as routing overhead, so it is an optimistic upper bound. Actual speed is also affected by operator implementation efficiency, batching strategy, and context length, and is usually below this ceiling.
3.3 The Three-Way Trade-off of Quantization Bit Width
Each step down in bit width reduces memory usage but introduces quantization error, lowering numerical stability and adding format-conversion overhead. Two practical points are worth stressing:
- Don’t blindly chase the lowest bit width; 8-bit models often strike a better balance between quality and speed.
- 6-bit remains the “sweet spot” for most devices, balancing quality, memory, and speed.
4. Routing by Task: Selection Logic for Three Typical Use Cases
A single model can rarely balance response speed, generation quality, and context capacity all at once. A more practical approach is to route by task, letting different models each do their job.
| Usage | Model form (illustrative) | Quantization | Weight size | Characteristics | Typical scenarios |
|---|---|---|---|---|---|
| Interactive primary (resident) | ~35B total / ~3B active | 6-bit | ~26GB | Fast response, moderate memory | Daily Q&A, script snippets, code explanation, first drafts |
| Coding output | ~26B total / ~4B active | 8-bit | ~26GB | Stable format, clear logic | Structured documents, business coding, unit tests, interface definitions |
| Quality focus (offline batch) | ~27B dense | 6-bit | ~20GB | Thorough reasoning, slow generation | Complex design, long reports, difficult problems |
4.1 Interactive Primary: Prefer Low-Activation MoE Models
Everyday use is most sensitive to “time to first token” and “sustained output speed.” If a user has to wait a dozen-plus seconds after asking before the first character appears, the experience degrades sharply. A 6-bit MoE model with only a few billion active parameters delivers several-fold, even nearly order-of-magnitude, higher decoding throughput at a comparable memory footprint—well suited to being loaded persistently and responding on demand.
When selecting, also watch the context budget: about 26GB of weights, once combined with everyday conversation cache, noticeably narrows the room for long contexts. Keeping daily conversations within a few tens of thousands of tokens helps maintain smooth performance over the long run.
4.2 Coding Output: Trade 8-bit Precision for Format Stability
Many coding tasks impose strict requirements on output structure—for example, interface definitions, unit tests, data-conversion scripts, and structured documents. These tasks are relatively lenient on response speed and can accept “think for a few seconds, then output,” but they demand usable output that can be pasted directly with minimal rework.
A 6-bit… rather, an 8-bit MoE model retains higher numerical precision at a comparable memory footprint, producing code and structured text with fewer syntax flaws and missing fields. From a total-efficiency standpoint, even if each generation is somewhat slower, the gains from reduced rework usually outweigh it.
4.3 Quality Focus: Dense Models Are Worth the Wait
Complex design reviews, long-report writing, and difficult-problem diagnosis require the model to stay consistent across multiple reasoning steps and rely more on “deep thinking” than on “fast output.” A dense model passes every token through all parameters, so its reasoning is more thorough and generally more robust on complex tasks.
The cost is speed. By the bandwidth estimate, a 27B-parameter, 6-bit dense model generates at about 20 tokens/s, so a multi-thousand-word long report may take hours. With a long context fully loaded as well, it might not finish even overnight.
The sensible approach is to position it as an offline batch engine:
- Submit tasks in the evening and review the next morning;
- Prepare input materials in advance to reduce repeated trial and error;
- Enable checkpoint-resume for “must-complete” tasks (see Section 6).
4.4 Desktop Integration: Human–AI Collaboration for Long Reports
For long reports that need back-and-forth human polishing, another approach is to connect a desktop AI client to the local inference service. The client handles conversation management, history organization, and long-document segmentation, while the local device handles only the inference computation.
The benefit is that a human can add requirements mid-process, adjust the outline, and confirm section by section, avoiding a “generate once, rewrite everything” cycle. Clients typically also support streaming output and automatic context trimming, allowing more flexible management of the memory pressure from long contexts.
One caution: set a reasonable timeout on the client side. A single request for a long report takes considerable time, and a default timeout that is too short will drop the connection and void all completed content.
5. Resource Isolation: Turning the Machine into a Pure “Compute Device”
When the local device serves as a called-on inference node, its role shifts from “personal computer” to “compute device.” Toward that goal, take the following measures:
- Close GUI-related programs: Browsers, instant messaging, and video conferencing consume both memory and GPU resources and compete with the inference process for bandwidth.
- Disable background indexing and sync services: File indexing, cloud sync, and system updates can seize disk I/O and CPU during inference peaks.
- Lower display resolution and disable visual effects: Reduce GPU usage of VRAM and memory bandwidth.
- Keep the device on external power and disable power-saving mode: On battery power and in low-power modes, unified-memory devices may throttle performance.
- Schedule serially rather than issuing concurrent requests: Inference is compute-intensive, and concurrent requests generally just split the available compute. A single request monopolizing the resources better guarantees stable latency.
- Establish a resource-monitoring baseline: Record memory pressure, CPU and GPU usage, temperature, and so on during inference, so anomalies can be located quickly.
Example configuration (YAML, illustrating the meaning of the parameters only):
# Inference node runtime policy (illustrative)node:role: inference-only # inference node only; no graphical interfacepower: ac-plugged # on external power; low-power mode disabledconcurrency: 1 # serial inference; avoid concurrent contentionmodel:max_context: 200000 # context limit; must match the actual KV cache budgetkv_cache_quant: 8bit # enable KV cache quantization for long-context scenariostemperature: 0.2 # lower randomness for coding tasksgateway:listen: "0.0.0.0:8080" # listen on a trusted LAN segment only; do not expose to the public internettimeout_seconds: 3600 # relax the timeout for long tasks to avoid mid-stream disconnects
6. Frontend–Backend Separation: LAN Calls and Checkpoint-Resume
The usual way to connect an inference node to a LAN is to run an HTTP-compatible inference service that frontend devices call over HTTP. Most mainstream inference frameworks support this interface form, and common routes match the OpenAI-style /v1/chat/completions. Below is a minimal client example (Python):
import jsonimport urllib.requestdef chat(base_url: str, model: str, messages: list,max_tokens: int = 2048, timeout: int = 3600) -> str:"""Send one chat request to the local inference service and return the generated text."""payload = json.dumps({"model": model, # model identifier; must match the name loaded on the server"messages": messages, # [{"role": "user", "content": "..."}]"max_tokens": max_tokens, # cap generation length to control latency and memory"temperature": 0.2,"stream": False,}).encode("utf-8")req = urllib.request.Request(base_url.rstrip("/") + "/v1/chat/completions",data=payload,headers={"Content-Type": "application/json"},)with urllib.request.urlopen(req, timeout=timeout) as resp:data = json.loads(resp.read().decode("utf-8"))return data["choices"][0]["message"]["content"]if __name__ == "__main__":answer = chat(base_url="http://<inference-node-ip>:8080",model="<model identifier loaded on the server>",messages=[{"role": "user", "content": "Explain what a KV cache is"}],)print(answer)
Paired with a batch task script that supports checkpoint-resume, long overnight jobs can recover automatically after an interruption:
import jsonimport timefrom pathlib import Path# Initialization reuses the chat() definition from the previous snippetOUT_DIR = Path("outputs")def run_batch(tasks: list, base_url: str, model: str,max_retries: int = 3) -> None:OUT_DIR.mkdir(exist_ok=True)for idx, task in enumerate(tasks):out_path = OUT_DIR / f"task_{idx:04d}.md"if out_path.exists() and out_path.stat().st_size > 0:continue # checkpoint resume: skip tasks already completedfor attempt in range(1, max_retries + 1):try:text = chat(base_url, model,[{"role": "user", "content": task}], max_tokens=4096)tmp = out_path.with_suffix(".tmp")tmp.write_text(text, encoding="utf-8")tmp.replace(out_path) # atomic write to disk; avoid partial filesbreakexcept Exception as exc:print(f"task {idx} attempt {attempt} failed: {exc}")if attempt == max_retries:breaktime.sleep(30 * attempt) # incremental backoff before retrytime.sleep(1) # request interval; avoid instantaneous load spikes
This script addresses three common pain points of long tasks:
- Recoverable from interruption: If a file already exists, it is skipped, and the job resumes from the checkpoint after a restart.
- Retries on failure: Automatic retries with incremental backoff, requiring no manual babysitting.
- Atomic writes: Write to a temporary file first, then replace, so a half-written file is never mistaken for a completed one.
Also pay attention to network-level stability:
- The inference node is best connected via wired networking;
- When routers and switches have power-saving features enabled, they can occasionally cause momentary connection drops;
- The upload time for large request bodies should also be counted into the timeout setting.
7. Summary: Put Limited Local Compute Where It Matters Most
| Conclusion | Explanation |
|---|---|
| Estimate first, then select | Weight memory ≈ parameters × bytes per parameter; the KV cache grows roughly linearly with context |
| MoE fits interactive use | Total parameters determine memory footprint; active parameters determine decoding throughput |
| Route by task | Low-activation MoE for interactive, 8-bit for coding, dense models run offline for complex tasks |
| Be disciplined about long contexts | Reserve a safety margin; enable KV cache quantization when necessary |
| Subtract on the node | Close unrelated apps, schedule serially, use external power |
| Make long tasks reliable | Frontend–backend separation, relaxed timeouts, checkpoint-resume |
A 64GB unified-memory device is not an all-purpose terminal that “runs anything”; it is a local inference node that remains highly valuable under specific constraints. As long as the budget is clear, selection is sound, and scheduling is appropriate, it can reliably support three workloads: everyday interaction, batch coding, and offline high-quality generation.
For scenarios with higher concurrency, longer contexts, or compliance requirements on data, you can combine this with the general capabilities of public cloud—GPU compute and object storage—for a hybrid deployment: keep sensitive data local and run elastic tasks in the cloud. For example, a provider such as Baidu AI Cloud can host burst traffic on GPU cloud servers and archive generated results in object storage, combining the strengths of local and cloud.
