Local LLM Inference Performance and SQL Generation Evaluation: Benchmarking Throughput, Concurrency, and Output Compliance

    This article breaks down a two-track evaluation of a local large language model deployment: inference performance under load and structured query (SQL) generation accuracy. On the performance side, it examines prefill throughput, concurrency degradation, decode throughput, and time-to-first-token, showing that the main bottleneck is scheduling and GPU memory rather than raw compute. On the capability side, a strict 25-question benchmark reveals a high semantic pass rate but a low strict-format pass rate, with failures driven by rounding, column naming, and business-logic mismatches. It closes with practical tuning and prompt-engineering recommendations for turning "mostly correct" output into reliably consumable results.

    1. Evaluation Background and Goals: Why “It Runs” Is Not the Same as “It Works”

    When a large language model moves from a demo to production, the biggest gap is usually not whether it can answer, but whether it stays stable under high concurrency and whether its output can be strictly consumed by machines. A complete version evaluation should cover two tracks: a performance profile of the localized inference pipeline, and the model’s capability boundary on a real business task (structured query generation in this article). Neither track is optional: performance determines user experience and unit cost, while capability determines whether the business workflow can close the loop.

    One point needs emphasis: evaluation conclusions must be tied to the environment. The same model can produce completely opposite results under different GPU memory capacities, batching strategies, and quantization precisions. Therefore, all data in this article serves only as a methodology example, and readers should reproduce it in their own environments.

    2. Performance Evaluation: Four Metrics That Determine Real-World Experience

    2.1 Prefill Throughput: Longer Inputs Do Not Necessarily Degrade Linearly

    With a single concurrent request, peak prefill throughput reaches 757.7 tok/s (4k input) and stays within 629–758 tok/s across the 2k to 32k range, with no clear length-related decay. This indicates that parallelism is well utilized during the compute-intensive stage, and long context does not inherently slow down per-unit processing.

    2.2 Concurrency Degradation: The Real Inflection Point Appears When Concurrency Exceeds Batch Slots

    At 2 concurrent requests, prefill throughput drops by about 30%–45%; at 4 concurrent, about 50%; at 6 concurrent, about 63% (2k input falls from 688 to 228 tok/s). This is not the model itself “slowing down,” but queuing at the scheduling layer: when the inference framework’s maximum number of concurrent sequences is capped at 2, the excess can only wait, and long prefill tasks block each other, spreading throughput thin.

    2.3 Decode Throughput and Time-to-First-Token

    Decode throughput is stable at 23.8–28.7 tok/s with a single concurrent request; it drops to 8–18 tok/s as concurrency rises, hitting a low of 8–11 tok/s when long inputs combine with 4–6 concurrent requests. Time-to-first-token rises roughly linearly with input length, worsening from 51.5 seconds at single concurrency to 186.4 seconds at 6 concurrency for 32k input. Queuing is the main cause, not a lack of compute.

    2.4 Tuning Approach (General Practice)

    1. # Example: directions for concurrency and batching configuration
    2. max_num_seqs: 2 -> 8 # increase the number of sequences that can run simultaneously
    3. max_num_batched_tokens: increase # allow larger batches to improve high-concurrency throughput
    4. gpu_memory_utilization: 0.91 # already high; KV cache is near its limit, requiring a tradeoff

    The key tradeoff is GPU memory: KV cache usage grows linearly with concurrency and context length, and blindly increasing concurrency triggers out-of-memory errors or frequent swapping. The recommended approach is to first run stress tests at a medium input length to find the inflection point, then gradually raise the concurrency limit, while using monitoring alerts and logging services to observe GPU memory and queue duration.

    3. Capability Evaluation: The “Format Failure” Trap in Structured Query Generation

    In a strict evaluation of 25 questions, 9 passed (36.0%): 8/8 easy, 1/2 introductory, 0/2 medium, 0/13 hard. If numeric tolerance is relaxed to 1e-6, the pass rate can rise to about 22/25 (88%). This stark contrast reveals an engineering reality: most failures are not because the model “cannot do it,” but because it “does not output according to the contract.”

    The model performs completely in the tool-calling loop: generating the query, executing it in an embedded analytics database, validating results, and judging whether requirements are met. Complex multi-table joins and window functions (such as lag-based retrieval, ranking, and cumulative share) are basically written correctly. Failures concentrate in three areas: omitting the required two-decimal rounding; result column names not matching requirements or returning an empty result set; and misunderstanding business definitions, such as calculating channel share on the wrong dimension.

    Token consumption is also worth attention: easy questions average two steps and about 2.4k tokens; hard questions average 6.1 steps, with individual questions reaching 17 steps and 55.5k tokens. Step inflation directly amplifies latency and cost, making it a place to set limits in production.

    4. Improvement Recommendations: Turning “Mostly Right” into “Reliably Right”

    1. Contract first: solidify output specifications in the system prompt, specifying decimal places, column names, sorting, and row-count requirements, with a positive example.
    2. Self-validation step: after execution, compare column names and row counts, and automatically retry once on mismatch instead of returning directly.
    3. Few-shot examples: provide templates for error-prone patterns such as window functions and year-over-year cumulative share.
    4. Step and budget caps: set a maximum number of steps and a token budget for the tool-calling loop to avoid long-tail tasks dragging down overall latency.
    5. Layered evaluation: distinguish “semantic accuracy” from “strict format pass rate”; the former measures capability, the latter measures usability.

    5. Conclusion

    The production version’s local inference shows a pattern of “strong at single concurrency, fragile under concurrency,” with the bottleneck in scheduling and GPU memory rather than the model; on the capability side, it shows “solid logic, loose contracts.” The focus of engineering deployment is therefore clear: use reasonable batching and concurrency configuration to unlock throughput, and use strict output contracts and self-validation to convert high semantic accuracy into high business pass rates. In environments with capabilities like container platforms, monitoring alerts, and logging services, such as Baidu AI Cloud, this closed loop of “stress test—tune parameters—contract constraints—layered evaluation” can be reused reliably.