LLM Inference Optimization for High Concurrency and Low Cost: A Flash Model Practice Guide

    This article explains how to optimize Flash-class model inference for high concurrency and low cost. It covers building an internal evaluation set based on real tasks, decoding optimizations such as operator fusion, low-bit quantization, speculative decoding, KV cache management, and scheduling, a cost model based on cost per task rather than per-token price, and a tiered routing strategy that balances output quality, latency, and cost. It also includes practical deployment recommendations with Baidu AI Cloud as a reference.

    1. Why Cost-Effectiveness Matters for Model Deployment

    In enterprise applications, the absolute capability of a model matters, but what really determines whether it can be deployed at scale is often the product of three engineering metrics: output quality, response speed, and cost per task. A model that performs slightly better but is ten times slower and twenty times more expensive is usually eliminated in a real business funnel. As a result, the industry is shifting its focus from public benchmark scores to the usability of outputs on everyday tasks and the end-to-end experience.

    This is exactly the value proposition of lightweight (Flash-class) models: with significantly fewer active parameters and more aggressive inference optimizations, they deliver a comprehensive experience close to that of much larger models, while reducing the cost per task to a fraction of the larger model’s cost.

    2. Evaluation First: Build an Internal Benchmark Close to Real Work

    Discussing model quality without business context is meaningless. A reusable approach is to build a “typical task set” that covers common forms of high-frequency work output, such as:

    • Creating and iteratively revising presentations
    • Human-AI co-writing of structured text such as Markdown
    • Long-document editing and format repair
    • Table structure repair and formula validation
    • Audio and video content processing and understanding
    • Visual understanding question answering

    Evaluation should not look at accuracy alone. It should include at least four dimensions: output usability rate (human review), output length per turn, end-to-end latency, and cost per task. Human review should be blind: reviewers score outputs without knowing the model’s identity to avoid brand bias.

    An example evaluation record structure:

    1. {
    2. "task_id": "ppt_edit_017",
    3. "category": "PPT editing",
    4. "human_score": 4.2,
    5. "output_tokens": 1850,
    6. "e2e_latency_ms": 8600,
    7. "cost_per_task": 0.0031
    8. }

    3. Inference-Side Optimization: Improve Decoding Speed

    The decoding stage is the bottleneck for interactive experience. Common optimizations can be combined:

    1. Operator fusion and mega-kernel approaches: merge multiple small operators into a single large kernel launch to reduce kernel launch and memory access overhead.
    2. Low-bit quantization (such as 4-bit weights): significantly reduce memory bandwidth pressure and clearly improve decoding throughput. A calibration set is needed to control accuracy loss.
    3. Speculative decoding and batch scheduling: use a small model for drafting plus a large model for verification, or use continuous batching to improve GPU utilization.
    4. KV cache management: paged caching and prefix reuse to reduce repeated prefill.
    5. Transfer and scheduling optimization: request routing, nearby access, and streaming responses to reduce time to first token.

    In engineering practice, it is recommended to break end-to-end latency into four segments and monitor them separately:

    1. T_e2e = T_queue + T_prefill + T_decode + T_network
    2. T_decode ≈ output_tokens / tps

    Here, tps (output tokens per second) is the core metric of decoding speed. Raising tps from tens to above 150 reduces the waiting time for long-output tasks proportionally.

    4. Cost Model: Decide by Cost per Task, Not Unit Price

    Unit price (price per million tokens) can be misleading. Real cost should be measured as follows:

    1. cost_per_task = (in_tokens * p_in + out_tokens * p_out) / 1e6 + infra_overhead

    The key point is that output length is often several times the input length, and decoding has higher compute density. Therefore, improving tps and reducing output redundancy (prompt constraints, structured output, concise templates) affects cost more than simply switching to a cheaper unit-price tier. Adding cache hit rate, batch utilization, and off-peak scheduling can reduce cost per task by another order of magnitude.

    5. Balancing Quality and Cost

    Tiered routing is recommended: simple tasks go to the lightweight model, while complex tasks are escalated to the large-parameter model, with confidence or rules used for upfront classification. At the same time, establish a regression gate: before any inference optimization goes live, it must run the internal evaluation set to ensure the human review score does not drop beyond a threshold.

    1. def route(task):
    2. if task.complexity < 0.4 and task.risk == "low":
    3. return "flash_model"
    4. return "large_model"

    6. Deployment Recommendations and Baidu AI Cloud Practice Reference

    In related practice at Baidu AI Cloud, teams typically use a container platform to host inference services, object storage to save evaluation outputs, and logging services with monitoring and alerting to build latency and cost dashboards, forming a closed loop of “evaluation, optimization, launch, and review.” Enterprises are advised to build a small-scale typical task set, quantify the baseline first, then gradually introduce quantization, operator fusion, and scheduling optimizations, use data to drive model selection, and ultimately obtain an inference solution that performs well in quality, speed, and cost.