Local LLM Deployment on Unified Memory: Capacity Planning and Quantization

    Learn how to estimate memory requirements for local LLMs on unified-memory systems, choose a quantization level, and balance context length against concurrency. This guide covers weight and KV cache calculations, deployment monitoring, privacy checks, and scheduling multiple AI models within a shared memory budget.

    1. Why Run an LLM Locally?

    Cloud models typically charge by usage and impose concurrency and rate limits. For long-running workloads—such as batch document processing, continuous coding assistance, or an always-on personal assistant—API costs and queueing delays can become significant. Running a model locally shifts inference spending toward relatively fixed hardware and electricity costs. Data can also remain within the local environment, making privacy risks easier to control.

    The trade-off is limited resources. Consumer hardware has far less memory than data center accelerators, so deployment should start with capacity planning: which models will fit, what inference speed to expect, and how many tasks the system can serve simultaneously.

    Local deployment is a good fit when:

    • Tasks run continuously or generate enough requests to make cloud usage expensive.
    • Sensitive data should not be uploaded to a third-party service.
    • Offline availability is required.
    • Slower responses are acceptable, or additional hardware investment is justified.

    Local deployment is less suitable when:

    • Usage is occasional and a pay-as-you-go cloud service is simpler.
    • The workload requires model capabilities that local hardware cannot support.
    • No one is available to maintain the service, update models, troubleshoot failures, and apply security patches.

    2. Memory Planning on a Unified-Memory System

    A unified-memory architecture allows the processor and accelerator to share the same physical memory. Compared with a separate graphics-memory pool, this can provide more capacity for large model weights. However, the operating system, background services, and inference process all draw from that shared pool. Their usage must be accounted for before deciding how much memory is available for inference.

    This article uses inference memory usage to mean the total memory consumed while running a model, rather than treating it as dedicated VRAM.

    Inference memory has three main components:

    1. Model weights: Primarily determined by parameter count and quantization precision.
    2. KV cache: Grows linearly with context length and concurrent requests. For long-document workloads, it can consume as much memory as the weights.
    3. Runtime overhead: Includes intermediate results, framework buffers, and other working memory.

    Use the following formulas for an initial estimate:

    1. Weight memory = Parameter count × Bytes per parameter
    2. KV cache = 2 × Layers × KV heads × Head dimension
    3. × Context length × Bytes per element × Concurrent requests
    4. Total requirement ≈ Weight memory + KV cache + Runtime overhead
    5. (typically allow an additional 10%–20%)

    Example: A 30B Model with 4-Bit Weights

    The following figures are illustrative calculations, not measurements from a specific model.

    Assume a model with approximately 30 billion parameters, quantized to 4 bits. At a theoretical 0.5 bytes per parameter, its weights require approximately 15 GB.

    Now assume:

    • 60 layers
    • 8 KV heads
    • A head dimension of 128
    • A 16-bit KV cache, or 2 bytes per element

    The KV cache requires approximately 245,760 bytes per token, or about 0.25 MB. At a context length of 32,768 tokens, one request requires approximately 8.05 GB of KV cache.

    Weights and cache together require about 23 GB. Adding 10% runtime overhead brings the estimate to approximately 25.4 GB for one long-context request.

    The key point is that context length and concurrency matter just as much as model size. Parameter count alone is not enough to determine whether a model will fit.

    All GB figures in this article use decimal units: 1 GB = 10⁹ bytes. Expressed in GiB, the numerical values are about 7% lower. Actual 4-bit model files also include scaling factors and other metadata, so they are somewhat larger than the theoretical weight size. Use the actual model file size when planning a deployment.

    Define a Usable Memory Budget

    A simple budget check is:

    1. Budget = Total unified memory × Usable fraction
    2. − Memory used by the system and other services
    3. Required = Weight memory + KV cache + Runtime overhead
    4. if Required > Budget:
    5. Reduce the context limit, choose lower-bit quantization,
    6. or reduce concurrency

    For a host with 64 GB of unified memory, an 80% usable fraction, and 8 GB allocated to the system and other services:

    1. Budget = 64 GB × 0.8 − 8 GB = 43.2 GB

    The table below uses the same illustrative 30B model and adds 10% runtime overhead to the combined weight and KV cache estimate.

    Configuration Weights KV cache Total, including 10% overhead Within a 43.2 GB budget?
    4-bit, 1 request, 8K context 15 GB 2.01 GB 18.7 GB Yes
    4-bit, 1 request, 32K context 15 GB 8.05 GB 25.4 GB Yes
    4-bit, 2 concurrent requests, 32K context 15 GB 16.1 GB 34.2 GB Yes
    4-bit, 4 concurrent requests, 32K context 15 GB 32.2 GB 51.9 GB No
    4-bit, 1 request, 128K context 15 GB 32.2 GB 51.9 GB No
    8-bit, 1 request, 32K context 30 GB 8.05 GB 41.9 GB Yes, with little headroom
    16-bit, 1 request, 8K context 60 GB 2.01 GB 68.2 GB No

    These are estimates. With 20% runtime overhead, the 8-bit, single-request, 32K configuration would require approximately 45.7 GB and exceed the budget. Actual runtime memory measurements should determine the final configuration.

    Important Limits of the Estimate

    • Capacity does not guarantee speed. Memory bandwidth affects generation speed, and token generation is often primarily constrained by memory reads and writes.
    • Test context length and concurrency together. Passing a short, single-request test does not establish that four long-document requests will work.
    • Verify quantization compatibility. Inference frameworks support different quantization formats. Confirm that the selected file loads in the target runtime.
    • Leave sufficient overhead. The table assumes only 10%. Actual overhead may fall between 10% and 20%, so avoid planning right up to the limit.

    Use this checklist when balancing context length and concurrency:

    • Establish the maximum context length first, then set concurrency.
    • When concurrency exceeds two requests, check KV cache growth before proceeding.
    • If longer contexts are required, reduce concurrency first, then consider lower-bit weights.
    • Split long tasks into separate sessions where appropriate to reduce per-request context length.
    • Quantizing the KV cache can reduce memory usage, but any effect on output quality must be checked against an evaluation set.

    3. Choosing a Model and Quantization Level

    Quantization reduces the storage precision of model parameters to save memory. Lower precision produces smaller files, but increases the risk of quality degradation.

    The following weight sizes are theoretical values for a 30B-parameter model.

    Weight precision Bytes per parameter 30B weight size Quality risk Speed and compatibility considerations Suitable use
    16-bit 2 60 GB Minimal loss from reduced precision High memory usage; exceeds the example host’s inference budget Quality reference, not deployment on the example host
    8-bit 1 30 GB Usually low, but evaluation is still required Broad format support Prioritizing quality when memory is sufficient
    6-bit 0.75 22.5 GB Low to moderate Depends on the quantization format Balancing quality and capacity
    4-bit 0.5 15 GB Moderate and task-dependent Mature ecosystem with many options A common starting point
    3-bit 0.375 11.25 GB More noticeable; complex reasoning and coding can be more sensitive Depends on runtime implementation Tight memory budgets where quality loss is acceptable
    2-bit 0.25 7.5 GB High; output may degrade substantially More experimental Not recommended for production tasks

    Measure Speed Rather Than Assuming It

    Lower-bit weights reduce the amount of data that must be read during generation, which can improve speed. The actual benefit depends on the inference framework’s kernel implementation. Benchmark the selected format on the host that will run it.

    Evaluate Quality on Real Tasks

    Quantization-related quality loss must be tested against your own evaluation set. Do not select a model by parameter count alone or assume that published leaderboard results will transfer directly to your workload.

    Performance can vary substantially across languages and tasks. Use representative samples and record the types of errors the model makes.

    A practical selection process is:

    1. Calculate the maximum weight size that fits the memory budget.
    2. Choose the highest-precision version that fits within that limit.
    3. Compare output quality using real task samples.
    4. Stress-test the maximum context length at the target concurrency.
    5. If the configuration fails to meet requirements, reduce the context limit, reduce concurrency, or move to lower-bit weights.

    4. Deploying a Stable, Power-Conscious Local Service

    Sustained inference can push a host toward full-load power consumption. An always-on service needs attention to power, cooling, request limits, and recovery.

    • Power: Select an appropriate power mode. If the system supports a power cap, use it to limit peak consumption. Avoid running unrelated high-load applications in the background.
    • Temperature: Compact systems have limited cooling capacity. Sustained load may trigger thermal throttling and cause generation speed to fluctuate. Keep air intakes and exhausts clear, and monitor temperatures regularly.
    • Concurrency control: Set limits on concurrent requests and queue length. Return a busy status when limits are reached rather than allowing memory exhaustion.
    • Service management: Use the operating system’s service manager, such as systemd or launchd, to start the inference service at boot and restart it after failures.
    • Health checks: Periodically send a fixed, short prompt. Verify that the response is valid and arrives within the expected time.

    Deployment and Monitoring Procedure

    1. Record the idle baseline. Measure system memory usage before loading the model.
    2. Measure after loading. Compare actual usage with the estimate. Investigate large differences, including accidentally loaded additional models or caches.
    3. Run sustained load tests. Use the target concurrency and maximum context length. Record peak memory, generation speed, temperature, and power consumption.
    4. Configure alerts. Notify operators when memory usage approaches the budget limit.
    5. Check long-term memory behavior. Look for gradual growth during extended operation. Accumulating caches, logs, or session records are common causes.

    Predeployment Checklist

    Check Pass criteria
    Idle memory baseline Recorded and available for later comparison
    Peak memory Below budget, with headroom remaining
    Sustained operation No continuous increase in memory usage
    Temperature under full load No significant speed reduction caused by thermal throttling
    Service recovery Starts automatically after reboot and passes health checks
    Logs and privacy Full user inputs are not logged, or a retention period is enforced
    Outbound network activity Unnecessary telemetry and automatic updates are disabled, and data is confirmed not to leave the environment

    Privacy and compliance require a separate review. Local deployment does not automatically mean that every component stays offline: logs, caches, plugins, and telemetry can transmit data outside the machine. Check each configuration individually.

    Model licenses also differ in their restrictions on commercial use and redistribution. Read and confirm the applicable terms before deployment.

    5. Scheduling Multiple Models

    Speech recognition, speech synthesis, and image generation are often deployed alongside a language model. Planning such a system requires separating two kinds of memory usage:

    • Resident weights: Memory occupied while models remain loaded.
    • Temporary working memory: Memory needed only while tasks are running.

    Estimate total host peak usage as:

    1. Peak memory ≈ Weights of all simultaneously resident models
    2. + Temporary memory for simultaneously active tasks
    3. + System memory usage

    Three Scheduling Approaches

    • Serial execution: Run one heavy model at a time. This reduces memory pressure but increases waiting time. It suits workflows where speech and text processing alternate.
    • Parallel execution: Keep multiple models resident and allow overlapping work. This can improve responsiveness, but peak memory requires careful budgeting.
    • On-demand loading: Unload unused models and reload them when needed. This saves memory, but loading delays can make frequent switching disruptive.
    Module Typical purpose Memory characteristics Scheduling recommendation
    Speech recognition Convert speech to text Relatively small models; high real-time responsiveness requirements Keep resident and assign the highest priority
    Speech synthesis Convert text to speech Relatively small models; execution must follow language-model output Keep resident or load on demand
    Image generation Generate images from text Model weights and temporary memory can be large; generation may take longer Load on demand, queue jobs, and avoid overlap with long-context tasks

    Measure each model’s memory usage on the actual host. Do not substitute measurements from someone else’s system.

    Degrade Gracefully Under Memory Pressure

    When memory becomes constrained, apply the following steps in order:

    1. Pause the image-generation queue as usage approaches the budget.
    2. If pressure remains high, reduce the language model’s context limit.
    3. If that is insufficient, switch to lower-bit weights or a smaller language model.
    4. Keep speech recognition available as a priority so voice interaction remains usable.

    To plan a multi-model deployment, list measured memory usage for every model, decide which models may remain resident together, calculate peak usage, and reserve headroom. Then run end-to-end stress tests for representative combinations of active tasks.