LLM Inference Optimization and On-Device Interaction: A Technical Guide to Efficient AI Delivery

    This article examines three converging trends in AI engineering: improving large language model inference efficiency, coordinating touch interaction with display and system layers on endpoint devices, and closing the perception-to-action loop in embodied intelligence. It breaks inference performance into four metrics (TTFT, TPOT, throughput, and cost per request), outlines the trade-offs of common optimization techniques, and provides scheduling and layout pseudocode. Readers will find a reusable engineering checklist covering metric definition, layered decoupling, runtime tuning, canary rollback, observability, and cost attribution.

    1. Introduction: Why Three Technology Tracks Are Converging Now

    The industry is seeing three recurring types of news: a new generation of large language models may be entering a release cadence, touch-enabled laptop form factors are being revealed, and humanoid and wheeled robots for real-world scenarios keep getting updated. On the surface, these belong to three separate domains: models, endpoints, and hardware. In practice, they point to the same engineering question: how to reliably deliver intelligent capabilities to users under limited compute, limited power, and limited latency.

    This article makes no product recommendations or reviews. Instead, it abstracts these signals into three general technical problems: how to systematically improve inference efficiency, how on-device interaction should coordinate with the display and system layers, and how embodied intelligence closes the loop from perception to control. Each is discussed below, along with reusable engineering methods.

    2. LLM Inference Efficiency: From “Parameter Scale” to “Intelligence per Unit Cost”

    2.1 Efficiency Must Be Split Into Four Layers

    When discussing model iterations, comparing parameter counts alone no longer explains much. Engineering attention is better spent on four layers of metrics:

    • Time to first token (TTFT): determines whether interaction feels responsive;
    • Time per output token (TPOT): determines the long-text reading experience;
    • Throughput (tokens/s and concurrency): determines how many users a single machine can serve;
    • Cost per request: determines whether the business can scale.

    These four constrain each other. Raising concurrency often increases queuing latency on the endpoint; larger batches improve throughput but degrade TTFT. So the real value of a model update usually shows up as higher throughput at the same latency, or lower latency at the same throughput.

    2.2 Where Common Optimization Techniques Apply

    • Attention computation optimization: more efficient attention implementations and memory-access optimization reduce long-context overhead, with the clearest gains in long-document scenarios.
    • Sparsification and conditional computation: activating only part of the parameters per forward pass cuts compute, but introduces memory footprint and uneven routing load issues.
    • Quantization and low-precision inference: significantly reduces memory and bandwidth pressure, at the cost of accuracy loss, which must be calibrated against a business evaluation set.
    • Cache reuse: prefix caching and result caching hit at very high rates when the system prompt is fixed or for knowledge-base question answering.
    • Scheduling and batching: continuous batching and priority queues are key to raising cluster utilization.

    2.3 Illustrative Service-Layer Pseudocode

    1. # Illustrates scheduling logic only; not the interface of any specific product
    2. def schedule(requests, max_batch_tokens, max_wait_ms):
    3. queue = prioritize(requests) # interactive requests first
    4. batch, tokens = [], 0
    5. for req in queue:
    6. if tokens + req.estimate_tokens() > max_batch_tokens:
    7. break
    8. batch.append(req)
    9. tokens += req.estimate_tokens()
    10. wait = min(max_wait_ms, deadline_of(batch))
    11. return run_forward(batch), wait

    The engineering point is that max_batch_tokens and max_wait_ms must be runtime parameters that can be adjusted dynamically, not hard-coded in configuration, otherwise the system cannot handle traffic peaks and troughs.

    2.4 Evaluation Must Be Closed-Loop

    Any claim of “faster” should rest on reproducible load testing: a fixed input-length distribution, a fixed output-length cap, recorded P50/P95/P99 latency, and quality metrics reported alongside. Performance comparisons without a quality constraint are meaningless in engineering.

    3. On-Device Interaction: Coordinating Touch, Display, and the System Layer

    3.1 The Hard Part of Touch Laptops Is Not “Adding a Touch Layer”

    Bringing touch into traditional computing devices concentrates difficulty in three places:

    1. Posture and grip: tablet, stand, and laptop modes need different input semantics, and palm rejection policy must switch with posture.
    2. Screen and structure: the touch layer changes thickness, weight, and reflectivity, requiring joint tuning with display brightness and color-accuracy strategies.
    3. System event stream: touch, touchpad, keyboard, and external mouse input must be normalized uniformly, otherwise the application layer needs multiple sets of adaptations.

    3.2 Software Requirements Created by New Interaction Regions

    When a device introduces a dedicated interaction region at the screen edge (for example, a strip for shortcuts or status display), the software side must handle three problems:

    • Safe-area adaptation: the layout system needs a new insets concept so content is not obscured;
    • Focus management: guaranteeing focus visibility as it moves between the physical keyboard, the virtual keyboard, and the touch region;
    • State consistency: the state shown in that region must come from the same source as the main-screen application state; there cannot be two sources of truth.

    Illustrative layout adaptation logic:

    1. // Illustrative only: include the new interaction region in system insets
    2. val layoutInsets = window.decorView.rootWindowInsets
    3. val interactionBar = layoutInsets.getInsets(WindowInsets.Type.tappableElement())
    4. rootLayout.setOnApplyWindowInsetsListener { _, insets ->
    5. contentView.updatePadding(bottom = insets.getInsets(
    6. WindowInsets.Type.tappableElement()).bottom)
    7. insets
    8. }

    3.3 On-Device Compute Scheduling

    The endpoint must simultaneously handle system rendering, model inference, and sensor processing, which requires priority isolation: the interaction rendering thread must not be blocked by inference tasks; inference tasks should be degradable (smaller model, shorter context, lower frequency); and power and temperature must be part of scheduling decisions, forming a dual-objective “performance–power” control loop.

    4. Embodied Intelligence: Closed-Loop Engineering From Perception to Action

    4.1 A Layered Architecture Is the Consensus

    Deployable robot systems are usually split into three layers:

    • Perception layer: multi-source fusion and time synchronization of vision, depth, force/torque, and joint state;
    • Decision layer: task planning and skill orchestration, with the large model handling semantic understanding and task decomposition;
    • Control layer: the motion control loop with the strictest real-time requirements, typically decoupled from the upper layers to guarantee determinism.

    The key principle: the semantic layer can be non-deterministic; the control layer must be deterministic. The upper model outputs goals and constraints, not direct joint commands.

    4.2 Data and Simulation as Two Wheels

    The bottleneck in embodied intelligence is often data. A common approach is to generate trajectories in bulk in simulation for pre-training, then fine-tune and calibrate with real-scenario data, while maintaining a regression test set to prevent policy updates from degrading existing capabilities.

    4.3 Safety and Observability

    Torque and velocity limits, abnormal-posture protection, and an emergency-stop path are mandatory. On the logging side, decision inputs, outputs, and execution deviation need to be recorded to form a traceable chain for incident review.

    5. A Unified Engineering Checklist

    • Metrics first: define target ranges for latency, throughput, quality, and cost before anything else;
    • Layered decoupling: the semantic, scheduling, and execution layers must each be replaceable;
    • Runtime tunability: batching, quantization precision, and model size should all be dynamic parameters;
    • Canary and rollback: every model or policy update goes through small-traffic validation;
    • Observability closed loop: logs, metrics, and traces as one unit, covering the end-to-end path;
    • Cost attribution: account for cost per request by business line to avoid “performance improved but the bill got out of control”.

    6. Conclusion

    Accelerating model iterations, converging endpoint form factors, and expanding robot capabilities are three facets of the same thing: intelligence is moving from centralized to distributed, and from “usable” to “affordable and predictable”. For developers, real capability lies not in chasing any single release, but in building an engineering system that is measurable, rollback-capable, and portable. To carry the capabilities described above, general-purpose infrastructure can rely on Baidu AI Cloud’s elastic scaling and full-chain observability across container platforms, object storage, message queues, log services, and monitoring and alerting, so effort stays focused on model quality and interaction experience itself.