Local LLM Inference Performance and SQL Generation Benchmarking

    This article presents a local benchmarking analysis of large language models across two dimensions: inference performance under concurrency and accuracy on structured query generation. It details the metrics, test setup, and results for prefill and decode throughput, TTFT, and latency, then attributes the observed bottlenecks to server scheduling and batching configuration rather than model limits. On the capability side, it reports a 36% strict pass rate on a tiered SQL task set, explains why formatting precision caused most failures, and offers practical tuning and prompting recommendations.

    1. Benchmark Background and Objectives

    As large language models move from “usable” to “deliverable,” showcasing capability along a single dimension is no longer enough to guide technology selection. Engineering teams care about two independent yet mutually constraining sets of metrics: the performance curve of the inference service under real concurrency, and the accuracy and stability of the model on structured tasks—especially query generation. This benchmark is designed around these two tracks, and all tests were run in a fully local deployment to avoid interference from network jitter and remote quota limits.

    It is worth stressing that the conclusions are strongly environment-dependent. The same model can differ by several times across different GPU memory capacities, batching configurations, and quantization precisions. So the goal here is not just to present numbers, but to explain why the numbers look the way they do.

    2. Inference Performance: Metrics and Methodology

    The performance tests cover the following metrics: prefill throughput, decode throughput, TTFT (time to first token), end-to-end latency, and the decay curve of each metric as concurrency increases. Tests span input lengths from 2k to 32k, with concurrency increasing from 1 to 6. Only steady-state data was recorded, and cold-start samples were excluded.

    The test logic is illustrated below:

    1. for length in [2048, 4096, 8192, 16384, 32768]:
    2. for concurrency in [1, 2, 4, 6]:
    3. prompts = build_prompts(length, concurrency)
    4. stats = run_benchmark(prompts, concurrency)
    5. record(length, concurrency, stats)

    3. Interpreting the Performance Results

    At single concurrency, peak prefill throughput appears near 4k at roughly 757 tok/s; across the 2k–32k range it stays between 629–758 tok/s with no clear length decay. This indicates that compute throughput in the prefill stage is not sensitive to sequence length, and the bottleneck lies in compute rather than memory access.

    The real problem shows up along the concurrency dimension. At 2 concurrent requests, prefill throughput drops by about 30%–45%; at 4 concurrent, it roughly halves; at 6 concurrent, the drop reaches 63% (in the 2k scenario, from 688 down to 228 tok/s). Decode throughput is stable at 23.8–28.7 tok/s under single concurrency, but falls into the 8–18 tok/s range above 8 concurrent requests. When long prompts are combined with 4–6 concurrency, throughput dips to 8–11 tok/s, then rebounds to 20–28 tok/s at 32k—a rebound more likely caused by sampling noise than by a genuine optimization.

    TTFT rises roughly linearly with input length: at 32k input, single concurrency reaches 51.5 seconds, worsening to 186.4 seconds at 6 concurrency. The key takeaway is that queuing, not computation, is the main driver of latency degradation.

    4. Bottleneck Attribution and Tuning Directions

    Looking at the server-side configuration, the maximum number of concurrent sequences is capped at 2. Once concurrency exceeds 2, requests enter a waiting queue, long prefill tasks block one another, throughput gets averaged out, and time to first token is amplified. This is a classic “configuration bottleneck,” not a ceiling on model capability.

    Practical improvements include: moderately raising the maximum concurrent sequences and the maximum tokens per batch so the scheduler can merge more requests; separating queues for long and short prompts to prevent long tasks from blocking short ones; and, when GPU memory is tight (current memory utilization is about 0.91 and the KV cache is near saturation), trading cache footprint, enabling chunked prefill, or adjusting the quantization strategy to free up concurrency headroom. Any change requires balancing throughput, latency, and memory—there is no lossless option.

    5. Structured Query Generation Capability

    The capability test uses 25 tiered questions (8 trivial, 2 easy, 2 medium, 13 hard), requiring the model to complete a tool-calling loop autonomously: generate the query, execute it in an embedded analytical database, validate the result, and judge whether it meets the requirement.

    Under strict judgment, 9 questions passed, a 36% pass rate: all trivial questions passed, 1 easy question passed, and all medium and hard questions failed. Notably, the tool-calling loop was completed autonomously for all 25 questions, and complex multi-table joins and window functions (such as lag-based lookups, row numbering, and cumulative ratios) were largely syntactically correct. Failures clustered in two areas: first, structural errors (mismatched return column names, empty results, wrong metric selection—3 questions in total); second, precision and formatting issues, where the model tended to omit the two-decimal rounding explicitly required by the prompt, while the official judgment requires strict string matching on the first row. This led to 15 of the 20-plus questions being “logically correct but losing points on format.” If the numeric tolerance is relaxed to 1e-6, the pass rate rises to about 88%.

    Token consumption is also worth noting: simple questions average 2 steps and about 2.4k tokens; hard questions average 6.1 steps, with individual questions reaching 17 steps and 55.5k tokens. The growth in steps comes mainly from repeated self-checking and rewriting.

    6. Engineering Takeaways

    First, a benchmark must define its judgment criteria up front. Strict string matching and numeric-tolerance judgment lead to very different conclusions, so selection should align with the business’s real tolerance. Second, prompts should state format constraints as hard requirements—for example, explicitly declaring “all ratios must be rounded to two decimal places and output the specified column names.” Third, for error-prone cases like window functions and multi-table metric definitions, providing a few examples in the prompt can stabilize output. Fourth, performance tuning should start by inspecting scheduling and batching configuration before considering hardware upgrades.