Running LLMs on 64GB of Unified Memory: 6-bit or 8-bit?
This guide explains how to choose between 6-bit and 8-bit quantization when running large language models locally on a machine with roughly 64GB of unified memory. It covers how to budget memory for the OS, runtime, model weights and KV cache; how to estimate weight size from parameter count and effective bits per parameter; how MoE and dense architectures differ in memory and speed terms; a task-by-task selection table; how KV cache grows with sequence length, including what a 200K context really costs; how to verify memory use and tokens/s with llama-bench; and the practical and security steps needed before turning the device into a dedicated inference node.
1. On a 64GB Unified Memory Device, Where the Real Boundary Is
People run large models locally for a few common reasons: keeping data inside the network, predictable long-term cost, and stable behavior in offline or low-latency scenarios. As on-device compute and unified memory capacity have grown, a machine with around 64GB of unified memory can now host models of considerable size. But “enough memory” does not automatically mean “runs smoothly.”
On a 64GB device, usable memory must first cover the operating system, the inference framework, runtime overhead, logs, caches, and temporary tensors. A conservative way to budget is to reserve about 8–12GB for the system and runtime, then fit model weights and KV cache into whatever remains. Model weights are a relatively fixed cost; KV cache grows with context length, batch size, and concurrency. Run long contexts or high concurrency at the same time, and KV cache can exhaust memory faster than the weights do.
So local model selection usually comes down to three things: parameter count and quantization scheme, context length and KV cache, and whether the model architecture matches the task. Hardware is only the foundation; the selection logic is what matters. The model sizes, bit widths, and memory figures in this article illustrate the method — they are not benchmark results for any specific product.
2. What Unified Memory Buys You, and Where It Stops
Traditional PCs and servers separate CPU memory from dedicated GPU memory, so weights and inference data have to be moved between the two. A unified memory architecture lets the processor and the compute units share one physical memory pool, which brings two direct advantages:
- Available memory is no longer capped by VRAM capacity alone — one large pool can hold more weights and more context cache;
- If the framework supports zero-copy natively, you can avoid the extra latency of copying across memory domains.
Unified memory still has hard limits:
- Total memory still sets the ceiling;
- Memory bandwidth directly affects generation speed;
- Some platforms cap how much memory can be allocated to the GPU or compute units;
- When resources get tight, the system may compress memory or swap — the model loads, but generation becomes very slow.
So the real question for a 64GB unified memory device is not “is the memory large enough?” but “how is it allocated?” — how much for weights, how much for KV cache, and how much must be reserved for the OS and runtime.
3. Estimating Memory for 6-bit and 8-bit Quantization
Quantization represents weights with fewer bits, shrinking the model and reducing bandwidth pressure. The common choices are 8-bit and 6-bit. To estimate weight size:
weights (GiB) = parameters × effective bits per parameter ÷ 8 ÷ 1024^3
If the parameter count is expressed in billions (B), this simplifies to:
weights (GiB) ≈ billions of parameters × effective bits per parameter × 0.1164
Where:
- Q8_0-style 8-bit quantization is usually estimated at about 8.5 bits per parameter;
- Q6_K-style 6-bit quantization is usually estimated at about 6.56 bits per parameter;
- Actual effective bits depend on the quantization scheme, the model card, and implementation details, so always check the specific model.
Examples:
- 26B parameters, 8-bit, at 8.5 bits per parameter: 26 × 8.5 × 0.1164 ≈ 25.7GiB;
- 35B parameters, 6-bit, at 6.56 bits per parameter: 35 × 6.56 × 0.1164 ≈ 26.7GiB.
Memory is expressed in GiB throughout this article. If your system or a product page reports decimal GB, the numbers will differ slightly — for example, 25.7GiB is roughly 27.6GB. These estimates cover weights only: they exclude any higher-precision embedding and output layers, runtime temporary tensors, OS overhead, and KV cache.
The selection principle in short:
- Quality first: prefer higher bit widths such as 8-bit;
- Capacity or context first: consider 6-bit;
- Not enough memory: drop to 6-bit, but run a quality regression comparison.
4. MoE vs Dense: Look at Total or Active Parameters
Many models advertise both total and active parameters — for example, 35B total with 3B active. That points to two different architectures.
A Mixture-of-Experts (MoE) model contains a large number of parameters, but each token activates only a small subset. Its characteristics:
- All parameters generally need to be resident in memory, which sets the capacity threshold;
- Actual compute scales mainly with the active parameters, which affects generation speed;
- On unified memory devices, speed also depends on memory bandwidth, expert routing, weight access patterns, and framework implementation — active parameter count alone is not enough.
That makes MoE attractive on large-memory machines: enough memory holds a big model, and few active parameters can keep generation reasonably fast. But it is also more prone to the “it fits in memory, yet bandwidth or routing overhead hurts the experience” case.
Dense models behave differently. Every token involves all parameters in the computation, so speed depends more on total parameters and behavior is easier to predict. For tasks that need stable output and higher reproducibility, dense models are usually less trouble.
A simple rule of thumb:
- Large memory, want both capability and speed: look at MoE;
- Stability and predictability matter more: pick a dense model;
- Look at neither total nor active parameters in isolation — combine the memory budget with the task type.
5. Picking a Model by Task
| Task | Suggested model type | Suggested bit width | Priority metrics | Main risk |
|---|---|---|---|---|
| Coding or structured extraction | MoE with small active params, or a strong coding model | 6-bit or 8-bit | Active params, throughput, instruction following | MoE has a capacity threshold; coding tasks can’t be judged by active params alone |
| High-quality long-form generation | Dense model or high-activation MoE | Prefer 8-bit; 6-bit only if memory is tight | Output quality, long-form structure, perplexity | May be slower |
| Very long context tasks | Mid-size MoE or moderate dense model | Budget by memory | KV cache size, memory bandwidth | KV cache can fill memory fast |
For high-volume, well-defined, parallelizable work such as data extraction, bulk rewriting, or format conversion, favor models with small active parameter counts and direct responses. If the focus is programming, choose a model with strong coding ability — don’t judge it by active parameters.
For high-quality tasks where long runtimes are acceptable, use higher bit widths such as 8-bit when quality comes first; drop to 6-bit only if memory runs short, and run a quality regression comparison. Under the same memory budget, compare “larger model at 6-bit” against “smaller model at 8-bit,” and decide based on output quality, speed, and stability.
For reports and long-form writing, local and cloud tools can work together: generate an outline or first draft with the local model, polish with a general-purpose AI client, and keep sensitive data local for validation rather than sending it out.
6. How Much Memory a 200K Context Needs
Weight usage is relatively fixed, but KV cache grows roughly linearly with sequence length. It is the real memory killer for long-context inference.
KV cache can be estimated approximately as:
KVCache = 2 × layers × KV heads × head dim × sequence length × batch size × bytes per element
The 2 accounts for the K and V caches. With fp16 for both, each element takes 2 bytes.
Two hypothetical tables follow. Layer count, KV head count, head dimension, quantization precision, and batch size may differ in real models — always recompute for your own configuration.
Assumption A: 32 layers, 4 KV heads, dim 128, fp16, batch size 1 — about 64KiB per token.
| Sequence length | Estimated KV cache |
|---|---|
| 8K | ~0.5GiB |
| 32K | ~2.0GiB |
| 64K | ~4.0GiB |
| 128K | ~8.0GiB |
| 200K | ~12.5GiB |
Assumption B: 64 layers, 8 KV heads, dim 128, fp16, batch size 1 — about 256KiB per token.
| Sequence length | Estimated KV cache |
|---|---|
| 8K | ~2.0GiB |
| 32K | ~8.0GiB |
| 64K | ~16.0GiB |
| 128K | ~32.0GiB |
| 200K | ~50.0GiB |
Key takeaways:
- Double the sequence length and KV cache roughly doubles;
- Batch size, context length, and model bit width all share the same memory;
- When running very long contexts, memory usually needs to be prioritized for the inference workload.
For a 30B-class model, under the assumption of 64 layers, 8 KV heads, dim 128, fp16, the KV cache at a 200K context can reach about 50GiB. With more layers, heads, or concurrency, KV cache alone can exceed the total memory of a 64GB device — and adding roughly 27GiB of weights plus runtime overhead makes the whole machine even more likely to blow the memory budget.
If memory is short, options include:
- KV cache quantization;
- Prefix caching or KV reuse;
- Shorter contexts;
- Smaller batch size;
- Closing unrelated processes to avoid system swapping.
Note that both KV cache quantization and prefix reuse have side effects. The former may affect long-context output quality and can hit backend compatibility issues; the latter requires attention to cache isolation, privacy risk, and stale-context pollution. Run quality regression and security checks before enabling them.
7. Verifying Memory and Speed with Tools
Don’t rely on theory alone — measure with at least one tool. Using llama-bench from the llama.cpp ecosystem as an example, benchmark short context first, then long context, and watch how memory usage and tokens/s change.
The examples below are ready to run. Replace the model path, context length, and generation length with your own values:
# 1. Record available memory before inferencefree -h# 2. Short-context benchmark: 512 prompt, 128 generatedllama-bench -m ./model-Q6_K.gguf -p 512 -n 128# 3. Long-context benchmark: 16384 prompt, 128 generated, context set to 32768# Flag names may differ across versions; check llama-bench --help firstllama-bench -m ./model-Q8_0.gguf -p 16384 -n 128 -c 32768# 4. Record memory againfree -h
If your version of llama-bench does not support some of these flags, test manually with llama-cli, for example:
llama-cli -m ./model-Q6_K.gguf -p "Write a short piece of test text" -n 128 -c 16384 --temp 0.2
System tools can help you capture peak memory during testing. On Linux:
/usr/bin/time -v llama-bench -m ./model-Q6_K.gguf -p 512 -n 128
Local inference typically has two phases:
- Prompt processing: compute-bound, parallelizable, demands compute throughput;
- Token-by-token generation: memory-access-bound, with speed determined roughly by memory bandwidth and the number of parameters read per token.
In local chat scenarios, batch size is usually 1. As concurrency rises, add memory budget according to the KV cache formula. If a model loads in testing but speed drops sharply, suspect swapping, an oversized KV cache, or a platform memory allocation limit.
8. Turning the Device into a Compute Node: Manage Performance and Risk
If the local machine is dedicated to inference, treat it as a pure compute node. Closing unrelated programs — browsers, editors, sync drives — before inference reduces contention for memory and bandwidth. Save your work before you close anything.
Recommended risk-control checklist:
- Before terminating processes, confirm task state: save documents, stop training, verify backups or sync have finished;
- Do not kill unknown processes outright — identify their purpose first;
- For remote access, bind inference services to localhost or a trusted LAN address only, for example 127.0.0.1 reached over an SSH tunnel;
- If you must expose the service, enable token authentication — never put an unauthenticated inference port directly on the public internet;
- Use a firewall to restrict source addresses, following the principle of least privilege;
- Periodically check that authentication is still valid, so an expired token doesn’t retain high-privilege access;
- For KV cache reuse and prefix caching, watch for privacy isolation and cache pollution risks.
9. Practical Checklist
- Set the memory budget first: reserve OS and runtime overhead, then work backward to the weight and KV cache ceilings;
- Use bit width as a lever: 8-bit for quality first, 6-bit for capacity or context first;
- Compare at equal memory: a larger model at 6-bit versus a smaller model at 8-bit, then finalize after a quality regression;
- Look at active and total parameters together: MoE trades large memory for capacity and small activation for speed, but bandwidth and routing overhead matter too;
- Account for long context separately: treat KV cache as its own budget, and shorten context or lower batch size when needed;
- Route tasks appropriately: bulk, rule-based work goes to small-activation models, high-quality work to larger models, reports to a tool-assisted workflow;
- Node-ify the machine: close unrelated apps during inference, but save work and confirm task state first;
- Stay safe with remote access: prefer localhost binding, SSH tunnels, auth tokens, and firewall restrictions.
10. FAQ
Can 64GB of unified memory run a 35B model at 6-bit?
Usually worth trying, but check the actual weight estimate first. 35B parameters at 6-bit comes to roughly 26.7GiB of weights, leaving room needed for the OS, runtime, and KV cache. Short contexts may be fine; long contexts will be tight.
How much quality is lost going from 8-bit to 6-bit?
It depends on the model, the task, and the quantization scheme. Generally, complex reasoning, long-form writing, and code generation favor 8-bit first. If you must use 6-bit, run a quality regression comparison focused on instruction following, long-form stability, and factual consistency.
Are MoE models more memory-efficient than dense models?
Not necessarily. All MoE parameters still have to be resident in memory, so the capacity threshold can be higher. The advantage is fewer active parameters, which can translate into better speed — but on unified memory devices you also have to account for bandwidth, expert routing, and framework optimization.
What are the limits of running LLMs on unified memory devices?
Mainly total memory, memory bandwidth, platform allocation limits, and performance loss from system swapping. When selecting a model, look at weights, KV cache, runtime overhead, and task context length together.
What mistakes do people commonly make when running LLMs locally?
Common ones include looking only at total parameters and ignoring active parameters, forgetting KV cache, chasing very low bit widths blindly, closing processes without saving work first, skipping quality regression, and exposing inference services without authentication.
