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

    This article explores the feasibility and optimization strategies for running large language models (LLMs) on low-cost devices without large-capacity dedicated VRAM. It covers the mechanisms of shared system memory, how to accurately estimate memory budgets, the specific challenges of sparse expert models, and the joint validation of quantization and integrated graphics (iGPU) acceleration. Additionally, it provides a guide for establishing reliable performance benchmarks, outlines the essential components needed to evolve from local inference to functional AI agent workflows, and suggests a practical implementation sequence and cost assessment.

    1. Redefining the Problem: Can Low-Cost Devices Handle LLMs?

    In local LLM deployment, a common question among developers is whether it is impossible to run models with tens of billions of parameters without large-capacity dedicated VRAM.

    The answer is not a simple “yes” or “no.” The problem must be broken down into three layers:

    First, can the model weights fit into the available memory of the device? Second, can the inference engine effectively utilize the CPU and integrated graphics processor (iGPU)? Third, under the target context length and workload, can the response speed meet practical usage requirements?

    Using an iGPU in a mini PC does not mean inference is strictly limited to the small block of graphics memory reserved by firmware. With the right combination of hardware, drivers, and inference backends that support shared system memory, the iGPU can access more system memory, providing room to run larger quantized models.

    However, this does not mean shared memory can completely replace high-speed dedicated VRAM. Capacity determines whether the model “fits,” while bandwidth, compute capability, and execution efficiency determine “how fast it runs.” Therefore, a reasonable deployment goal is not to chase parameter size labels, but to find a usable balance among budget, latency, context length, and output quality.

    2. Why Shared Memory Expands the Model Running Space

    1. Dedicated VRAM and Shared Memory Are Not the Same Concept

    Dedicated graphics processors typically have their own VRAM, and model weights must be transferred into this memory via device transmission mechanisms. iGPUs, on the other hand, usually share physical system memory with the CPU, with the operating system and drivers managing access range and resource allocation.

    The “dedicated graphics memory” shown in the device interface may only be a reserved capacity and does not necessarily represent the total upper limit of memory the GPU can access. Whether an application can actually use more shared memory depends on:

    • Hardware addressing and memory access capabilities;
    • Operating system memory management policies;
    • Graphics compute interfaces and driver support;
    • Inference backend buffer allocation methods;
    • Single allocation limits and available memory budgets.

    Therefore, you cannot judge whether a model can run based solely on a capacity number on the system information page, nor should you assume that modifying the reserved graphics memory will necessarily improve inference speed.

    2. Shared Memory Does Not Automatically Mean High Bandwidth

    The same physical memory often serves the operating system, CPU, iGPU, and other applications simultaneously. During inference, these components may compete for memory bandwidth.

    For token-by-token generation tasks, the amount of model weight data read is typically large. If compute units wait too long for data, increasing compute capability may not significantly improve speed. The effective bandwidth of system memory, memory channel configuration, and background workloads can all affect final performance.

    When selecting hardware, you should pay attention to both capacity and bandwidth, rather than just looking at CPU specs or the number of graphics execution units. For devices that need to run continuously, you should also evaluate thermal and power limits to avoid situations where short-term tests perform well but long-term generation noticeably throttles.

    3. Memory Budgeting: Model File Size Is Just the Starting Point

    1. Rough Estimation of Weight Capacity

    The theoretical capacity of model weights can be estimated using the following formula:

    Weight Capacity ≈ Number of Parameters × Storage Bits per Parameter ÷ 8

    For example, a model with about 35 billion parameters, if all weights are saved in 4-bit precision, the theoretical size of pure weight data is about 17.5GB (calculated using decimal units).

    This is only an estimated lower bound, not the device configuration requirement. Actual quantized files may also contain group scales, auxiliary metadata, and tensors retained at higher precision. The inference runtime also requires additional memory, so you cannot assert that a specific device will definitely run smoothly based solely on this number.

    2. Total Budget Should Cover Runtime Overhead

    A more complete budget can be written as:

    Total Memory Requirement ≈ Model Weights + Attention Cache + Compute Workspace + Backend Overhead + OS/Application Usage + Safety Margin

    Among these, the attention key-value (KV) cache grows with context length and concurrent request count. The specific growth rate depends on the number of model layers, number of KV heads, cache precision, and attention structure, so you cannot apply the same ratio to all models.

    This means that a model loading successfully under a short context does not guarantee stability during long-document Q&A. If you plan to use long contexts, you should test directly at the target length rather than just verifying simple conversations.

    3. Avoid Relying on Heavy Swapping to Maintain Operation

    When physical memory is insufficient, the operating system may swap some data out to storage devices. While this can sometimes prevent the process from crashing immediately, continuous inference requires frequent reading of weights and caches, and swapping can easily cause severe latency jitter.

    A safer approach is to monitor actual physical memory usage, memory pressure, and swap activity. If generation speed drops accompanied by frequent swapping, you should prioritize shortening the context, reducing concurrency, or choosing a smaller model, rather than continuing to expand virtual memory and hoping for performance improvements.

    4. Sparse Expert Models: Less Compute Does Not Mean No Storage Needed

    Sparse expert models organize parts of the network into multiple expert modules, usually activating only a subset for each input. Thus, a model with a large total parameter count may have a significantly smaller number of active parameters involved in a single forward pass.

    This structure helps reduce some compute costs, but three boundaries must be noted.

    First, the total parameter count still affects weight storage requirements. In the common full-model-resident deployment method, the weights of inactive experts must still be kept in memory for subsequent routing calls.

    Second, expert selection is dynamic. Different inputs may access different experts, affecting memory access locality. Theoretically lower active parameters do not guarantee an equivalent proportional speedup on all devices.

    Finally, the degree of support the inference backend provides for expert routing, tensor layout, and related computations significantly impacts performance. The same model structure may exhibit different execution efficiencies under different implementations and driver environments.

    Therefore, you cannot equate “large total parameters, few active parameters” directly with “the memory requirements of a small model.” A more accurate understanding is: the sparse expert structure primarily changes the computation path, while quantization and resource management still determine whether it can be deployed on devices with limited memory.

    5. Quantization and iGPU Acceleration Require Joint Validation

    1. Quantization Is a Trade-off Between Quality and Resources

    Quantization reduces storage and data read overhead by lowering the representation precision of weights, but different models, tasks, and quantization methods have varying sensitivities to quality changes.

    When selecting quantization precision, you should at least validate the following capabilities:

    • Whether regular Q&A remains accurate;
    • Whether multi-step reasoning is more likely to miss conditions;
    • Whether structured output maintains format stability;
    • Whether tool call parameters are complete;
    • Whether fact extraction in long contexts is reliable.

    For agent scenarios, you cannot just test a single natural language response. Minor formatting errors or parameter deviations can cause subsequent tool executions to fail.

    2. iGPU Acceleration Depends on a Complete Software Stack

    For the GPU to participate in inference, three conditions must hold simultaneously: the driver must properly provide compute capability, the inference backend must be able to call the relevant interfaces, and the critical operations in the model must be supported.

    “Detecting a graphics device” does not mean “most computations are executing on the graphics device.” When certain operations are unsupported, they may fall back to the CPU, creating a mixed execution path. Frequent synchronization, data conversion, or inefficient buffer management can all undermine acceleration gains.

    During deployment, check initialization logs and runtime metrics to confirm the model load location, the actual offload ratio, and whether there are operation fallbacks. You should also retain a pure CPU baseline result to determine whether iGPU acceleration is genuinely effective.

    3. No Need to Pursue Full Offloading Immediately

    When the memory budget is tight or backend support is incomplete, partial offloading is sometimes more stable than forcing full offloading. Incremental adjustments can help identify the optimal configuration and make it easier to pinpoint failure causes.

    Sharing physical memory does not guarantee that the software layer will always achieve zero-copy. Different backends may still use independent buffers, perform layout conversions, or generate extra workspaces. Therefore, you need to rely on the actual memory usage of the process and device, rather than just inferring based on the model file size.

    6. How to Establish Reliable Performance Benchmarks

    A single “tokens generated per second” number cannot fully describe the local inference experience. You should at least distinguish the following metrics:

    Metric Description Primary Purpose
    Model Loading Time Time from startup to ready to receive requests Determine cold start cost
    Time to First Token (TTFT) Time from submitting a request to the first output Determine interactive responsiveness
    Prompt Processing Speed Efficiency of processing input content Determine suitability for long documents
    Continuous Generation Speed Generation efficiency during the output phase Determine answer wait time
    Peak Memory Usage Maximum resource demand during operation Determine stability boundaries
    Long-term Performance Variance Speed fluctuation under sustained load Determine thermal and power impacts

    A set of reproducible tests should fix the model version, quantization method, context length, input content, generation length, and concurrency level, while also recording the memory configuration, driver version, and inference backend version.

    It is recommended to test short Q&A, long document processing, and continuous multi-turn conversations separately, and run them repeatedly after warm-up. The report should include cold start results, typical values after warm-up, and the fluctuation range, rather than just showing the best single result.

    Different models may use different tokenization rules, so tokens per second is not suitable as an absolute cross-model performance ranking. For real-world tasks, a more important focus is how long it takes to complete the same task and whether the result meets the required quality standards.

    7. From Local Chat to AI Agents: What Else Is Missing?

    Being able to run a model only completes the inference part of an AI agent system. To form a reliable workflow, mechanisms for tool execution, task state, permission control, and failure recovery are also needed.

    A general workflow can be represented as:

    User Request → Input Validation → Model Planning → Tool Call Validation → Restricted Execution → Result Return → Final Output

    When deploying locally, you should focus on implementing the following measures:

    First, executing tools must be bound by permissions. File read/write, network access, and command execution should each have defined allowed ranges, and the model should not be allowed to freely operate the entire system.

    Second, the content returned by tools can only be treated as data to be processed, not automatically escalated to higher-priority instructions. External documents, web snippets, or logs may contain content inducing operations, requiring defenses against prompt injection.

    Third, set timeouts, retry limits, and maximum task step counts. Models may repeatedly call tools or generate invalid parameters; without exit conditions, small devices will be occupied for long periods.

    Fourth, monitor the entire task chain, not just the model generation speed. Agents often require multi-turn reasoning and may wait for tool results. Fast generation of a single response does not mean the total time for complex tasks is sufficiently low.

    Running locally helps reduce some data leakage, but it does not automatically guarantee privacy. If tools access external networks or logs save sensitive information, you still need to implement data masking, access control, and log retention policies.

    8. Implementation Sequence and Cost Assessment

    It is recommended to proceed with deployment in the following order:

    1. Clarify the target task, context length, concurrency, and acceptable latency.
    2. Estimate the total memory budget for weights, cache, and runtime.
    3. Verify correct model loading and basic output before enabling iGPU acceleration.
    4. Incrementally adjust offloading methods, context length, and batch processing configurations.
    5. Record TTFT, generation speed, peak memory, and swap activity.
    6. Validate the quality post-quantization using real tasks.
    7. Finally, integrate agent tools and conduct permission and stability testing.

    “No per-call pricing” does not equal “zero cost.” Local solutions still involve hardware procurement, power consumption, maintenance time, storage usage, and device depreciation. For high-frequency, data-sensitive, low-concurrency tasks for individuals or small teams, local deployment may be valuable; for bursty high-concurrency, strict availability requirements, or continuously growing workloads, you should evaluate other deployment methods.

    The core of low-cost local inference is not breaking through a nominal VRAM number, nor proving that a device can load the largest model. It is about matching the model structure, quantization precision, memory capacity, bandwidth, and execution backend together. Only when quality, response time, and long-term stability requirements are all met does “can run” truly transform into “usable.”