arXiv:2610.37432cs.DCOct 2026

Manuscript Offprint

arXiv:2610.37432

Request-Adaptive Execution for Efficient Hybrid LLM Inference

Fahao Chen, Xuzhe Yan, Qi Zhang, Peng Li, Dongxiao Yu, Song Guo

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Fahao Chen

chenfh@ieee.org

Shandong University

China

Peng Li

Xi'an Jiaotong University

China

pengli@xjtu.edu.cn

Xuzhe Yan

Xi'an Jiaotong University

China

Zedekiah5571@outlook.com

Dongxiao Yu

Shandong University

China

dxyu@sdu.edu.cn

Qi Zhang

Xi'an Jiaotong University

China

zq0204@stu.xjtu.edu.cn

Song Guo

Hong Kong University of Science and

Technology

Hong Kong SAR

songguo@cse.ust.hk

Abstract

Hybrid large language models (LLMs) have emerged as a promising way to combine the modeling capability of the Attention mechanism with the efficiency of state space models (SSMs). However, most existing hybrid LLMs still inherit a static design philosophy: once the Attention-to-SSM layout is chosen, every request must follow the same hybrid execution. This one-layout-fits-all design is inefficient for real-world serving workloads, where different requests rely on contextual information in different ways.

This paper presents FLEX, a serving system that co-designs the model architecture and runtime for request-adaptive hybrid LLM inference. Its model architecture pairs Attention and SSM layers within each block and uses prefill-oriented gating to select a request-specific layout that remains fixed throughout decoding. Its serving runtime preserves batching efficiency under divergent layer choices through selective batching and enables correct prefix reuse through hybrid-aware context caching. Experiments on six datasets show that FLEX achieves a better quality-efficiency trade-off than existing static hybrid baselines. System-level evaluation further shows that FLEX improves the serving throughput by up to 3.87×3.87\times over baselines while substantially reducing inference latency.

Keywords: Large language models, State space models, Efficient serving

1 Introduction

Large language models (LLMs) have become the foundation of modern AI services, powering applications such as search [31, 40], coding assistants [20], document analysis [18, 49], and autonomous agents [24, 34]. Most deployed LLMs are based on the Transformer architecture, where the attention mechanism provides strong global-context modeling but incurs quadratic computation and growing KV-cache memory during inference [43, 50, 56]. To reduce this cost, state space models (SSMs), such as Mamba [9, 16], have been introduced as efficient sequence modeling primitives. SSMs summarize

Figure

(a) Static hybrid layout

Figure

(b) Proposed dynamic hybrid layout

Figure 1. (a) Hybrid LLMs use the static Attention-to-SSM layout for all requests. (b) Request-adaptive hybrid layout allows different requests to activate different Attention and SSM execution. Colored lines indicate layer selections.

prior tokens into compact recurrent states and update them in linear time. However, this compact recurrent state may limit the ability to recall context-dependent information, making SSMs less effective on tasks that require precise long-range context modeling [46].

To combine the complementary strengths of attention mechanisms and SSMs, recent works have proposed hybrid LLMs 1^{1}, which interleave Attention layers and SSM layers within the same model to balance model quality and inference efficiency. Representative works such as Jamba [22], MambaLLaMA [38], and Nemotron-H [3] have demonstrated a better quality-efficiency trade-off than Attention-only or SSM-only architectures. A core design factor behind the performance of hybrid LLMs is the Attention-to-SSM layout, which specifies not only how many Attention and SSM layers are used, but also where these layers are placed in the model.

Existing hybrid LLMs typically rely on hand-crafted architecture designs, where the Attention-to-SSM layout is selected based on empirical studies. In addition, this layout remains static for all requests once the model is constructed. For example, Jamba adopts an a/m rotation strategy, inserting a Attention layers for every m SSM layers. As illustrated

1^{1}We use the term “hybrid LLMs” to broadly refer to LLMs that combine Attention layers with SSM layers within the same model.

in Figure 1(a), such static designs assume requests with different characteristics, e.g., summarization, QA, and reasoning, benefit from the same hybrid structure. However, our preliminary experiments in §2.2 show that this assumption does not always hold in real-world inference workloads. A layout that achieves the best accuracy on a reasoning task such as ARC-Challenge can lead to suboptimal quality on a summarization task such as PubMed. This inconsistency arises because different workloads rely on contextual information in different ways. For example, reasoning tasks may only require selected Attention layers for option comparison, while long-document summarization often depends more heavily on fine-grained global context modeling to identify and preserve salient information. As a result, a static Attention-to-SSM layout can either overuse Attention for simple requests, wasting computation, or underuse Attention for context-sensitive requests, sacrificing output quality.

Key Idea. Our key idea is to make the hybrid LLM request-adaptive: rather than fixing the Attention-to-SSM layout, the model selects an appropriate hybrid layout for each incoming request. As illustrated in Figure 1(b), different requests can activate different Attention and SSM layers according to their context-modeling demands. We realize this idea through algorithm-system co-design in FLEX, an inference system that integrates a request-adaptive hybrid model with runtime optimizations for efficient serving. The hybrid model consists of multiple adaptive hybrid blocks, each containing a lightweight gate, paired Attention and SSM branches, and shared components such as the FFN. For each request, the gates select one branch per block, forming a request-specific execution layout that balances modeling capability and inference cost.

A key design choice is the gating granularity. A natural token-level gating design would allow each token to independently choose whether to execute the Attention or SSM layer in each hybrid block. However, this design is ill-suited for autoregressive decoding, where newly generated tokens rely on the cached results of previous tokens, i.e., Attention KVs and SSM states, to avoid recomputation. If tokens from the same request choose different layers within the same block, later tokens may not be able to directly reuse the Attention KVs or SSM states produced by earlier tokens, forcing the runtime to recompute previous tokens under the new layer choice. FLEX therefore adopts prefill-oriented gating mechanism (§4): during prefill, the gate uses all input tokens to make one request-level Attention and SSM choice for each hybrid block, and these choices are fixed throughout decoding. This allows the Attention KVs or SSM states built by previously generated tokens to be reused consistently.

At the system level, request-adaptive layouts introduce two challenges: requests within the same batch may select different branches, and requests sharing a textual prefix may require incompatible layer-wise caches. The serving runtime in FLEX addresses these challenges through the following two designs to preserve batching efficiency and ensure correct context reuse.

Selective Batching Engine. To maintain high inference throughput, FLEX must efficiently batch multiple requests for parallel execution. However, requests in the same batch may select different branches at each hybrid block, which breaks the traditional batching assumption of conventional serving engines, where all requests in a batch follow the same operator sequence [12, 21, 32]. A naive solution would either serialize or execute block computations separately. The former loses parallelism, while the latter fragments the original batch and prevents request-independent operations, such as normalization and FFN computation, from being executed as a single compact batch [55].

FLEX addresses this with selective batching engine (§5). The key idea is to keep branch-independent operations on the original packed batch, and split requests only for the branch-dependent Attention and SSM computation. At each block, it partitions requests into compact Attention and SSM sub-batches, executes them with their corresponding kernels, and then merges outputs back into the original batch layout. Since two branches may have different execution costs, FLEX further applies load-aware branch coordination by assigning more resources to heavier branch, reducing synchronization stalls before merging.

Hybrid-Aware Context Caching. Real-world LLM serving workloads often contain repeated long prefixes, such as system prompts, document contexts, and multi-turn conversation histories. Recomputing these prefixes for every request wastes substantial prefill computation, especially in long-context scenarios. Context caching [19, 41, 45] addresses this issue by identifying matched textual prefixes and reusing their previously generated caches. Existing techniques typically assume that a matched textual prefix uniquely determines all reusable caches. However, this assumption no longer holds for FLEX: even when two requests share the same prefix, they may select different Attention and SSM layers across hybrid blocks, producing different layer-wise caches. Moreover, conventional cache eviction operates at the context level, where evicting a prefix removes all layer-wise caches associated with it. This coarse-grained eviction is inefficient for request-adaptive hybrid execution, because only a subset of layer caches under a matched context may be frequently reused. Evicting the whole context can reduce future cache hit ratios, while retaining it may keep many rarely used layer caches in memory.

To address these limitations, FLEX introduces the hybrid-aware context caching (§6). Its core mechanism, a two-level radix tree structure, decouples textual-prefix matching from layer-wise cache matching. After identifying a shared textual prefix, it further determines which layer-wise caches are compatible with the current hybrid layout. Built on this structure, FLEX further performs priority-based eviction at

Figure

(b) SSM-based LLM

(c) Conventional Hybrid LLM

(d) Pareto frontier of model performance.

Figure 2. Overview and quality-efficiency trade-off of conventional hybrid LLMs. (a)-(c) Illustrations of Attention-based, SSM-based, and conventional hybrid architectures. (d) PIQA accuracy versus model efficiency under different Attention-to-SSM layouts. All models have 3B parameters.

the layer-wise cache level, accounting for context sharing potential, layer-wise reuse likelihood, and recomputation cost. As a result, FLEX preserves useful shared prefixes while evicting low-value layer caches, enabling correct and efficient context reuse for dynamic hybrid LLM serving.

Results: We evaluate FLEX on the NVIDIA H100 GPU using six datasets spanning reasoning, QA, and summarization tasks. Experiments show that the proposed hybrid model achieves a better quality-efficiency trade-off than homogeneous and static hybrid baselines, obtaining the best results on 13 out of 18 quality metrics while reducing estimated TFLOPs/token by up to 67.2% relative to LLaMA. At the system level, FLEX improves up to 3.87×3.87\times the serving throughput of vLLM while substantially reducing time-to-first-token (TTFT) and time-per-output-token (TPOT).

References (22)