Low-Cost Local LLM Inference: Shared Memory and Integrated GPU Practices

    This article examines what actually limits low-cost local large language model inference on small computing devices, covering shared-memory deployment boundaries, capacity budgeting for weights and KV cache, the difference between total and active parameters in mixture-of-experts models, backend compatibility and offloading, performance measurement, agent workflow considerations, and a practical deployment sequence. It explains why shared memory can expand model capacity without eliminating bandwidth and stability constraints, and how to evaluate whether a configuration can load, run continuously, complete real tasks with acceptable latency, and enforce reliable security and data protection.

    Low-Cost Local LLM Inference: Shared Memory and Integrated GPU Practices

    1. Rethinking the Core Problem of Low-Cost Local Inference

    Running a large language model with tens of billions of parameters on a small computing device is not primarily a question of whether the processor has enough raw compute. Three interrelated questions must be addressed first: whether the model can fit completely into available memory, whether the inference backend can effectively use compute resources, and whether sustained generation speed can meet business requirements.

    Traditional discussions often map parameter count directly to dedicated VRAM capacity and conclude that a model cannot run if VRAM is insufficient. For integrated graphics that can share system memory, however, the resource boundary is not exactly the same. With appropriate software and driver support, model weights can use system memory, giving the device an opportunity to host models beyond the fixed reserved graphics memory capacity.

    Still, “can load” and “can run efficiently” are different matters. Shared memory expands accessible capacity but does not create additional memory bandwidth out of nowhere. Quantization reduces weight size but may introduce precision changes and extra compute overhead. A larger context improves task capacity but also continuously increases runtime memory requirements.

    Low-cost local inference should therefore be treated as a resource-balancing engineering problem, not a contest over a single hardware metric.

    2. Why Shared Memory Changes Model Deployment Boundaries

    2.1 Fixed Reserved Capacity Is Not Total Usable Capacity

    Integrated graphics usually do not have a large dedicated VRAM pool and instead share physical memory with the CPU. The system may reserve part of memory for graphics tasks while allowing graphics compute to request more shared memory under certain conditions.

    As a result, a fixed graphics memory value shown in the device interface does not necessarily represent all the memory an inference program can use. The real limits also depend on:

    • Total physical memory capacity and current free memory;
    • The graphics memory allocation budget allowed by the system and driver;
    • How the inference backend creates and manages buffers;
    • Whether model operators can execute on the integrated GPU;
    • Whether there are limits on single allocation size, address space, or resource count.

    The mere phrase “shared memory” does not mean that any large model can be loaded directly.

    2.2 Shared Physical Memory Does Not Mean Automatic Zero-Copy

    Shared memory describes a hardware resource relationship, but actual programs may still involve different memory layouts, mapping methods, temporary buffers, and synchronization operations.

    If inference frequently requires data format conversion or repeated synchronization between the CPU and GPU, the extra overhead can offset the benefits of parallel compute.

    A more accurate statement is this: shared memory creates conditions for expanding model capacity and reducing some data movement, but whether efficient access is actually achieved depends on the backend implementation and measured results.

    2.3 Memory Must Also Remain Available for Other System Components

    System memory serves more than the model. It is also needed by the operating system, desktop environment, file cache, and other applications. If the model occupies too much memory, the system may begin frequent paging.

    Storage devices can expand virtual address space, but they cannot replace high-bandwidth memory. Once inference frequently accesses pages that have been swapped out, generation can suffer noticeable pauses. Stable deployment should therefore not aim to “just barely fit” the model, but should retain sufficient headroom.

    3. Estimate Capacity Before Choosing Model Size

    3.1 Basic Weight Capacity Calculation

    The theoretical size of model weights can be approximated as:

    Weight capacity ≈ parameter count × storage bits per parameter ÷ 8

    For a hypothetical 30-billion-parameter model, if each parameter uses an average of 4 bits of storage, the raw weight data is about 15 billion bytes, or roughly 15 GB.

    This number is only a preliminary lower bound and cannot be treated directly as the final memory requirement. An actual deployment may also include:

    • Scaling factors and auxiliary information for quantization groups;
    • Some tensors kept at higher precision;
    • Model structure and tokenizer-related data;
    • Computation graphs and operator temporary buffers;
    • Context cache;
    • Backend alignment, mapping, and additional copy overhead.

    Two model files both labeled as low-bit quantized may still differ in actual size and runtime memory use.

    3.2 Context Cache Grows with the Workload

    Autoregressive generation usually needs to store key-value states corresponding to historical tokens so that all prior content does not have to be reprocessed for every generated token. This state is commonly called the KV cache.

    Its capacity depends on the number of model layers, the data dimensions of the cache, storage precision, sequence length, and concurrency. With a fixed model structure and precision, longer contexts and more concurrent requests usually require a larger cache.

    This means that a model running well in short conversations does not necessarily handle long documents or multi-turn agent tasks reliably.

    3.3 Plan with a Full Budget, Not a Single File Size

    Capacity planning can use the following relationship:

    Available memory budget ≥ resident weight memory + context cache + runtime buffers + system and application headroom

    Each item should be verified under actual workloads. For resource-constrained devices, reducing concurrency and context length is often more reliable than pushing the system to the edge of memory exhaustion.

    4. Why Mixture-of-Experts Models May Reduce Compute

    A mixture-of-experts model contains multiple expert subnetworks. When processing a given token, the routing mechanism usually selects only a subset of experts to participate in computation. Two concepts must therefore be distinguished:

    • Total parameter count: the full parameter scale contained in the model;
    • Active parameter count: the parameter scale that actually participates in computation when processing a token.

    A lower active parameter count may reduce per-step compute requirements, giving a model with a larger total parameter count some potential for low-cost inference.

    There is an important boundary here: using only some experts during computation does not mean that the weights of the other experts can be directly subtracted from memory requirements.

    Different tokens may be routed to different experts. To avoid repeatedly reading weights from storage, common deployments still need to keep a large portion or even all expert weights accessible. The advantage of mixture-of-experts models therefore usually appears first as compute sparsity, not as a proportional reduction in weight memory based on the active ratio.

    In addition, expert scheduling, memory access patterns, and the degree of backend optimization all affect final efficiency. Generation speed cannot be inferred from active parameter count alone.

    5. What Capabilities a Backend Must Validate

    5.1 Model Format, Quantization, and Hardware Execution Must Match

    A complete local inference chain includes at least the model file, quantization format, inference engine, compute backend, and driver.

    If any link does not match, the result may be a load failure, some operators falling back to the CPU, or abnormal performance. Before deployment, confirm:

    • Whether the model architecture is supported;
    • Whether an execution path exists for the current quantization format;
    • Whether attention, matrix computation, and expert routing can execute correctly;
    • How the context cache is allocated;
    • Which layers or operators are actually offloaded to the integrated GPU.

    “Hardware acceleration enabled” is only a configuration state. It is not sufficient proof that the main computation has completed on the GPU.

    5.2 Partial Offload Is Not Necessarily Faster

    When a model cannot fit entirely into memory available for graphics compute, some computation can be kept on the CPU. However, this approach may increase synchronization, scheduling, and data movement overhead.

    For small-batch interactive generation, if execution switches too frequently between different compute units, overall speed may actually decrease. Test CPU execution, partial offload, and higher offload ratios separately instead of assuming that more offload is always better.

    5.3 Establish a Correctness Baseline First

    Before formal tuning, validate with a smaller model and a shorter context:

    • Whether output is normal;
    • Whether multi-turn conversations are stable;
    • Whether memory grows abnormally over time;
    • Whether logs show operator fallback or allocation failures;
    • Whether long-running operation causes driver resets or process exits.

    Only after correctness and stability are confirmed does performance optimization become meaningful.

    6. Performance Evaluation Must Go Beyond Generation Speed

    6.1 Separate Input Processing from Token-by-Token Generation

    Local inference includes at least two different stages.

    The input processing stage reads prompt content and builds context state; the generation stage outputs new tokens step by step. Their compute characteristics differ. The same device may have acceptable generation speed but require a long wait when processing long documents.

    At minimum, record:

    Metric Main purpose
    Model load time Judge cold-start cost
    Time to first token Measure wait before response begins
    Input processing throughput Measure long-prompt handling capability
    Output generation throughput Measure sustained generation speed
    Peak memory Judge capacity and stability boundaries
    Sustained power and temperature Judge long-running operating conditions

    6.2 Token Speed Is Not Directly Equivalent to Text Speed

    Different models may tokenize the same text differently. The same tokens-per-second value does not necessarily correspond to the same Chinese character output speed, nor does it necessarily represent the same useful information output.

    For real applications, also observe complete task completion time, answer correctness, format compliance rate, and repeated generation. A model that outputs faster but often requires retries may not have higher practical efficiency.

    6.3 Test Conditions Must Be Fixed

    Meaningful performance results should state model size, quantization method, input and output length, concurrency, context limit, offload method, and software and hardware environment.

    Record cold-start and post-warmup results separately, run multiple test rounds, and pay attention to the median and slower requests. Small devices should also undergo sustained load testing to avoid mistaking short bursts of high performance for long-term capability.

    Speed numbers without these conditions are not suitable as a basis for procurement or architecture decisions.

    7. Extending from Local Chat to Agent Workflows

    Running a model is only one part of an agent system. A complete workflow also requires task orchestration, tool calls, state persistence, exception recovery, and permission control.

    7.1 Multi-Turn Calls Amplify Latency

    A single task may involve planning, retrieval, execution, checking, and retry. Even if single-turn generation speed is acceptable, the total time after multiple serial calls may still increase significantly.

    For resource-limited devices, prioritize shortening unnecessary prompt content, limiting invalid loops, and reasonably orchestrating steps that can run independently, rather than simply increasing model size.

    7.2 Tool Execution Must Set Boundaries

    Running locally is not inherently safe. If a model can access files, execute commands, or send network requests, its permissions need to be explicitly restricted.

    Adopt the principle of least privilege, add human confirmation for high-risk operations, validate tool inputs, and set limits on loop count, execution time, and resource consumption. Model-generated content cannot be treated directly as trusted instructions.

    7.3 Sensitive Data Protection Must Cover the Entire Chain

    Not calling an external inference API can reduce opportunities for data to leave the local machine, but prompt records, tool outputs, logs, and temporary files may still retain sensitive information.

    Local deployment still requires access control, log redaction, data cleanup, and necessary storage protection. Privacy advantages come from complete data governance, not merely from changing the inference location.

    8. A Reasonable Practice Order for Low-Cost Deployment

    Proceed step by step according to the following process:

    1. Define the task. Clarify whether it is personal interaction, offline batch processing, or multi-step tool calling, and determine acceptable waiting time.
    2. Establish a memory budget. Consider weights, context, runtime overhead, and system headroom together.
    3. Validate with a small configuration. First confirm backend compatibility and output correctness, then gradually increase model size.
    4. Test with business samples. Use real lengths, real languages, and real tasks, rather than testing only short question-answer exchanges.
    5. Adjust one item at a time. Change only one variable at a time: quantization precision, context length, or offload ratio.
    6. Run sustained operation validation. Observe temperature, memory, failure rate, and long-duration response fluctuations.
    7. Implement security and operations. Configure permission boundaries, logging policy, failure recovery, and version rollback plans.

    It is important to emphasize that local inference can reduce external API call costs, but it does not mean there is no cost. Hardware purchase, power, cooling, storage, and maintenance time should all be included in total cost of ownership.

    9. Conclusion: Capacity Breakthrough Is Only the Starting Point

    Shared memory, low-bit quantization, and a suitable compute backend do expand the possibility of running large models on low-cost devices. However, these technologies do not eliminate constraints such as memory bandwidth, cache growth, backend compatibility, and sustained power consumption.

    To judge whether a solution is usable, answer these questions in order: Can it load stably? Can it run continuously under the target context? Can it complete real tasks with acceptable latency? Does it have reliable permission and data protection mechanisms?

    The value of low-cost local inference is not in demonstrating how large a model a device can open, but in providing sufficiently good capability for specific tasks in an explainable, reproducible, and maintainable way.