On-Device Full-Modality and Diffusion-Based Generation: The Engineering Evolution
This article examines the shift in LLM competition from raw capability toward generation paradigm, comparing autoregressive decoding with diffusion-based text generation in terms of latency, throughput, and controllability. It then outlines the architecture of on-device full-duplex, full-modal interaction, including state machine design, interrupt handling, and resource constraints, followed by a layered inference service architecture built around measurable speed metrics and a three-dimensional evaluation matrix. The article closes with common pitfalls and a three-step adoption path.
1. Where the Problem Starts: Once Capabilities Converge, Competition Moves to the Generation Paradigm
Over the past two years, large models have gradually converged on general question answering, code completion, and similar tasks, and the marginal return from simply stacking more parameters is declining. The industry discussion has therefore shifted from “who answers more accurately” to “who answers faster, more naturally, and more like real-time interaction.” Behind this shift lies a frequently overlooked fact: the cost of mainstream autoregressive decoding scales roughly linearly with output length, and token-by-token serial generation inherently suffers from time-to-first-token delay and a slow tail. Diffusion-based text generation instead models the process as iterative denoising over an entire sequence, which can in principle refresh multiple positions in parallel and offers structural advantages in throughput and controllability.
It is worth stressing that claims of diffusion models fully replacing large language models are too absolute. A more rigorous framing is that the two paradigms will coexist for the long term and divide work according to task characteristics. Autoregressive decoding remains robust for long-chain reasoning and tasks with strict causal dependencies; diffusion-based generation is more valuable for low-latency dialogue, structured output, and local rewriting. The key engineering decision is not to pick a side, but to establish measurable selection criteria.
2. How the Two Generation Paradigms Differ Mechanically
The core of autoregressive decoding is a chain decomposition of conditional probabilities, where each step depends only on the already generated prefix. This naturally supports streaming output, but generated content cannot be revised. Diffusion-based generation starts from a sequence that approximates noise and converges toward the target text through multiple denoising steps, and any single step can make a globally consistent adjustment.
The difference can be expressed with minimal pseudocode:
# Autoregressive: serial, cost determined by lengthtokens = []for _ in range(max_len):logits = model(prefix=tokens)tokens.append(sample(logits))# Diffusion: parallel iteration, cost determined by step countx = init_noise(batch, length)for t in reversed(timesteps):x = denoise(x, t) # each step can refresh all positionsx = project_to_vocab(x) # constrain to the valid vocabulary space
Three engineering conclusions follow. First, diffusion latency is strongly correlated with the number of denoising steps, so step reduction (for example distillation or step prediction) is the main optimization lever. Second, memory must hold the hidden states of the entire sequence, which puts more pressure on long-text scenarios. Third, masked diffusion naturally fits fill-in-the-blank and rewriting tasks, giving it an interaction advantage in code completion and document polishing.
3. On-Device Full-Duplex Full-Modality: From “One Question, One Answer” to “Continuous Perception”
The real difficulty of on-device deployment lies not in model accuracy but in the interaction form. The traditional request-response mode requires users to wait for a complete reply, whereas full duplex means the system must listen continuously, allow interruption at any time, and listen, think, and speak simultaneously. Engineering-wise this is usually split into four parallel subsystems: a streaming speech front end (including endpoint detection and noise reduction), a multimodal encoder (unified representation of vision, audio, and text), the generation kernel, and speech synthesis with playback scheduling.
State machine design is the core of full duplex, and the following transitions should be modeled explicitly:
IDLE -> LISTENING -> THINKING -> SPEAKING^ | ||---- INTERRUPT ----|------------|----|
Interruption must support preemptive cancellation: once the user is detected speaking, immediately abort the current synthesis queue, roll back the uncommitted generation context, and merge the new speech segment into the history. Without this piece, the interaction degrades into high-latency turn-taking.
Resource constraints are a hard limit on-device. Viable strategies include quantizing model weights and fusing operators, dynamically loading and unloading capability modules by scenario, sampling frames rather than running inference on every frame for the vision encoder, and handing long-tail capabilities such as complex reasoning to the cloud through a generic interface. When cloud-side capabilities are involved, generic category descriptions are sufficient: object storage for distributing models and assets, message queues for decoupling asynchronous tasks, container platforms for elastic inference, and logging plus monitoring and alerting for observability.
4. Inference Service Architecture: Turning “Fast” into an Operable Metric
Speed cannot remain a slogan; it must land in metrics and capacity planning. At least four observable quantities should be defined: time to first token, per-step denoising time, end-to-end completion time, and effective throughput per unit of energy. Around these metrics, the architecture can be layered:
- Access layer: protocol adaptation, authentication, and rate limiting, shielding differences between device and cloud;
- Scheduling layer: routing by task type to the autoregressive or diffusion kernel, with support for priority and preemption;
- Execution layer: batching and memory reuse, preferring static shapes and bucketing dynamic lengths;
- Feedback layer: collecting latency distributions and failure samples, feeding them back into the evaluation set.
Evaluation must go beyond a single accuracy number. A three-dimensional matrix is recommended: quality (task pass rate), latency (P50/P95), and cost (compute per request). Only when all three are included in regression testing can hidden degradation from “sacrificing usability for speed” be avoided.
5. Common Pitfalls and Adoption Recommendations
Pitfall one is treating diffusion as a universal accelerator. If a task requires strict step-by-step reasoning, forcing parallel denoising introduces inconsistency. Pitfall two is ignoring vocabulary projection and legality constraints, which breaks output structure. Pitfall three is only trimming on-device without scheduling, so the process is eventually killed by the system due to a memory peak.
A three-step adoption path is suggested: first, compare the quality-latency curves of the two paradigms on an offline evaluation set to establish a baseline; then, pick one high-frequency short-interaction scenario for end-to-end rework, focusing on interruption and streaming synthesis; finally, complete observability and canary mechanisms, and validate capacity assumptions with real traffic. Baidu AI Cloud’s standardized capabilities in general compute, storage, and monitoring can serve as the foundation for such a pipeline, but the actual selection should still be based on measured data.
