Streaming data analytics helps businesses identify opportunities and spot risks in a timely fashion. As large language model (LLM) usage grows, people are exploring incorporating agents or LLMs in streaming data pipelines to help find patterns in datasets without supervision or interpret natural languages for content moderation. However, most streaming systems are currently optimized for data movement and perform poorly on GPU intensive workloads such as performing inference with LLMs. We introduce a system on Google Cloud Dataflow designed to tackle hybrid streaming machine learning workloads with co-designed autoscaling on heterogeneous worker pools and prefix-aware batching. This increases throughput 1.5x to 2x for streaming pipelines using LLMs while maintaining similar latency with up to 75% peak resource savings and 84% lower peak tail latency compared with existing streaming data processing systems.
Figures & tables
Figure 2: Comparison of KV Cache Optimization. The proposed prefix-aware batching approach groups context-similar prompts into dedicated keys, significantly maximizing individual worker prefix cache hit rates compared to simple, uncoordinated random hashing.
Parameter
Specification
Instance
a2-highgpu-1g
GPU
1 × NVIDIA A100
vCPUs
12
Memory
84 GB
Workers
8
Table 1: Server Configuration
Figure 3: Throughput and latency comparison on different request rates.
Figure 4: Prefix cache hit rate comparison overtime.
Parameter
Specification
Instance
n1-standard-4
GPU
1 × NVIDIA T4
vCPUs
4
Memory
30 GB
Max Workers
100
Table 2: Server Configuration
Figure 5: Evaluation under sinusoidal load with 2 hour period and load 10x at peak: (a) total allocated vCPUs, (b) total allocated GPUs, (c) cumulative GPU-hour consumption, and (d) watermark latency on a log scale. The experiment achieves a 51.1% reduction in total GPU-hours (37.0 vs. 75.7 GPU-hours).
Figure 6: Autoscaling performance on a GPU-bound pipeline: (a) allocated workers/GPUs and (b) watermark latency. The proposed policy saves 42.4% GPU-hours (27.7 vs. 48.1 h) and cuts peak latency by 71.0% compared to the baseline.
Figure 7: Dataflow and Apache Flink on a pure GPU LLM inference pipeline under sinusoidal traffic with 2 hour period and peak load 10x. Dataflow caps peak allocation at 25 GPUs and downscales elastically to 9 GPUs, while keeping peak queueing latency bounded (582 s vs. 3804 s).
Figure 8: TimesFM 2.0-500M inference under a 2-hour sinusoidal workload with 2 hour period and peak load 30x. Dataflow rapidly scales without pipelines churning causing tail latency spikes and promptly reclaims idle capacity.
Conventional transformer inference engines are request-driven, paying an O(n) prefill cost on every query. In streaming workloads, where data arrives continuously and queries probe an ever-growing context, this cost is prohibitive. We introduce a data-driven computational model centred on stateful sessions: a persistent KV cache advanced incrementally as new data arrives, so prefill is moved off the critical path and query latency becomes O(|q|), independent of accumulated context size. Building on this, Flash Queries reclaim idle GPU cycles between data arrivals to pre-evaluate registered questions and return cached answers before the user asks, a pattern that is structurally impossible in stateless engines because they discard intermediate state between requests. A multi-tenant continuous-batching scheduler with cell-budget admission and prefix-aware grouped prefill lets dozens of stateful sessions coexist on a single GPU while preserving full quadratic self-attention. On streaming market-data benchmarks the reference implementation achieves up to 5.9x speedup over conventional inference engines (vLLM, SGLang, TensorRT-LLM, llama.cpp), holding query latency constant as accumulated context grows.
On-device LLM inference is attractive for privacy and responsiveness, but remains challenging on mobile and embedded devices because model weights far exceed available DRAM. Prior systems exploit activation sparsity and offload weights to SSD or flash storage, but face a fundamental systems trade-off: accurate sparse execution decisions require the latest context, whereas efficient computation-I/O overlap requires early prediction. As a result, existing designs either serialize execution or incur redundant weight fetches, extra computation, and large cache overheads. We present LeanStream, a streaming speculate-and-refine framework for efficient on-device LLM inference. LeanStream progressively refines computation, loading, and cache-retention priorities using partial GPU results, enabling fine-grained overlap between GPU execution and storage I/O. We implement LeanStream on both mobile and embedded platforms. Compared with prior on-device LLM inference systems, LeanStream reduces memory usage by 4.8× to 7.5× at the best throughput achieved by prior work, while further improving token generation throughput by 1.6× to 2.1×. Source code is available at https://github.com/RenyuanLIU/LeanStream.
Renyuan Liu, Yuyang Leng, Kaiyan Liu +7
Richard · Global Technology Applied Research, JPMorganChase · University of Kansas +1
Context retrieval systems for LLM inference face a critical challenge: high retrieval latency creates a fundamental tension between waiting for complete context (poor time-to-first-token) and proceeding without it (reduced quality). Streaming context incrementally--overlapping retrieval with inference--can mitigate this latency, but doing so with concurrent requests introduces new challenges: requests contend for GPU compute and memory, and scheduling must adapt to dynamic context arrivals. We present Stream2LLM, a streaming-aware LLM serving system for concurrent prefill-decode disaggregated deployments. Stream2LLM introduces adaptive scheduling and preemption for two distinct retrieval patterns: append-mode (progressive context accumulation) and update-mode (iterative refinement with cache invalidation). It decouples scheduling decisions from resource acquisition, enabling flexible preemption strategies guided by hardware-specific cost models, and uses longest common prefix matching to minimize redundant computation when input changes dynamically. To evaluate Stream2LLM, we collect two large-scale, real-world streaming workloads based on web crawling and approximate nearest neighbor search. Our evaluation demonstrates that streaming architecture delivers up to 11x TTFT improvements, with cost-aware scheduling providing critical benefits under memory pressure, all while maintaining throughput parity with non-streaming baselines. Code: https://github.com/rajveerb/stream2llm/tree/mlsys_artifact