NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Firewall Routing: Blocking Leads to Better Hybrid Inference for LLMs

Runyu Peng, Yunhua Zhou, Kai Lv, Yang Gao, Qiyun Guo, Xipeng Qiu2025

Abstract

The rapid advancement of Large Language Models (LLMs) has significantly enhanced performance across various natural language processing (NLP) tasks, yet the high computational costs and latency associated with deploying such models continue to pose critical bottlenecks. To mitigate these challenges, we propose a dynamic hybrid inference framework, Firewall Routing, which efficiently selects between a strong and a weak LLM based on the complexity of the query. A lightweight routing model is trained to optimize resource allocation by learning from response quality and preventing long-tail queries, which are often too hard to solve by LLMs, from being routed to the stronger model. Moreover, our method incorporates multiple sampling to enhance query evaluation reliability while leveraging Hard Blocking and Soft Blocking to handle long-tail queries along with refining labels for model selection. Extensive experiments show our method outperforms existing routing strategies by up to 5.29% in APGR, demonstrating state-of-the-art performance across multiple benchmarks.

Introduction

Deploying massive Large Language Models (LLMs) often forces a compromise between performance, latency, and cost—an "impossible triangle." Hybrid inference, which routes queries between a small, cost-effective "weak" model and a large, high-performance "strong" model, offers a potential solution. However, existing routing strategies are hampered by two primary issues: unreliable training signals derived from binary "hard labels" and the inefficient allocation of resources to "long-tail" queries that are either unsolvable by both models or better handled by the weaker one.

Methodology: The Firewall Routing Framework

Firewall Routing addresses these limitations through a three-stage pipeline designed to stabilize training and optimize query allocation.

The three-stage pipeline of Firewall Routing: data collection, label generation with blocking, and hybrid inference.

Soft Label Training

Instead of using binary labels (success/failure on a single attempt), we employ multiple sampling (e.g., 32 responses per query) to calculate a "Win Rate." This soft label represents the probability that the weak model's performance meets or exceeds that of the strong model, providing a more nuanced and stable signal for training the router.

Blocking Strategies

A core innovation of this work is the concept of "blocking" difficult queries to prevent wasteful routing to the strong model:

  • Hard Blocking: Identifies queries where the weak model is statistically likely to perform as well as the strong model, ensuring they are handled locally by the weak model.
  • Soft Blocking: Uses the Pass Rate (pass@1) to estimate the joint probability that either the weak model succeeds or both models fail. If the strong model is likely to fail, the query is "firewalled" and sent to the weak model to save costs.

Implementation

The system utilizes a DeBERTa-v3-large model as a lightweight router. This adds minimal latency (~0.024s), which is negligible compared to the generation time of the underlying LLMs.

Experimental Results

We evaluated Firewall Routing on three major benchmarks: TriviaQA (fact retrieval), GSM8K (mathematical reasoning), and HumanEval (code generation).

Performance comparison of Firewall Routing against baselines across TriviaQA, GSM8K, and HumanEval benchmarks.

Key Findings

  • State-of-the-Art Performance: Our method consistently outperformed existing strategies like RouteLLM and Hybrid LLM. Notably, we achieved a 5.29% improvement in Average Performance Gap Recovered (APGR) on the GSM8K benchmark.
  • Efficiency Gains: In a 50/50 routing scenario, Firewall Routing achieves nearly a 2x speedup compared to using the strong model exclusively, with minimal impact on accuracy.
  • Robust Generalization: Routers trained on specific model pairs (e.g., Llama-1B and Llama-70B) maintained effectiveness when the weak model was swapped for a different variant (e.g., Llama-3B), indicating that the router learns intrinsic query difficulty.

Conclusion

Firewall Routing demonstrates that "blocking" the hardest queries from the most capable models is an effective strategy for optimizing hybrid inference. By transforming noisy binary signals into stable soft labels and implementing intelligent firewalls, we achieve a superior balance of cost and performance. Future work will explore the application of this framework to more diverse model architectures and real-world production traffic.

Summary updated

BibTeX
@misc{peng2025firewall,
  author = {Runyu Peng and Yunhua Zhou and Kai Lv and Yang Gao and Qiyun Guo and Xipeng Qiu},
  title = {{Firewall Routing: Blocking Leads to Better Hybrid Inference for LLMs}},
  year = {2025},
  doi = {10.18653/v1/2025.emnlp-main.331},
}
Figure