Local LLM Inference Performance and SQL Generation Evaluation Analysis
This article presents a cross-evaluation of an open-source large language model in a local deployment, covering both inference performance under concurrency and structured SQL generation accuracy. It details prefill and decode throughput, latency degradation, and queueing caused by conservative batching limits, along with memory trade-offs and request routing strategies. It also analyzes why logically correct queries fail strict output contracts, and offers practical tuning advice for deployment and application layers.
1. Evaluation Background and Goals
As large language models move from “usable” to “reliable,” isolated capability demos are no longer enough to support engineering decisions. Two independent but mutually constraining metrics drive real-world adoption: throughput and latency of the inference service under realistic concurrency, and the accuracy and stability of the model on structured tasks such as generating executable queries. This evaluation focuses on both tracks. Within a single local deployment environment, a performance load-testing tool and an answer-quality evaluation tool were used to cross-validate a release version of an open-source large language model.
The findings are strongly environment-dependent. Hardware model, inference framework version, quantization precision, context length distribution, and concurrency strategy can all change results significantly. This article therefore emphasizes trends and root causes rather than absolute numbers.
2. Inference Performance: Throughput, Latency, and Concurrency Decay
2.1 Prefill: Solid Single-Concurrency Results, Length Is Not the Main Enemy
Under single concurrency, the Prefill stage reached a peak throughput of 757.7 tok/s with a 4k context. Between 2k and 32k, throughput stayed within 629 to 758 tok/s with no clear length-related decay. This indicates that prefill computation for this model remains compute-intensive on modern accelerator cards, and the extra attention overhead from long contexts has not yet become a bottleneck.
2.2 The Cliff After Concurrency Rises: Queueing, Not a Compute Shortage
The problem appears along the concurrency dimension. At 2 concurrent requests, Prefill throughput dropped by roughly 30% to 45%; at 4, by about 50%; at 6, the drop reached 63% (from 688 to 228 tok/s with a 2k context). Meanwhile, the Decode stage stayed stable at 23.8 to 28.7 tok/s under single concurrency but fell to a low of 8 to 11 tok/s between 8 and 18 concurrent requests. The 32k long context rebounded to 20 to 28 tok/s at some data points, which is more likely sampling noise than a genuine optimization.
Time to first token (TTFT) rose roughly linearly with context length: at a 32k context, single concurrency measured 51.5 seconds, worsening to 186.4 seconds at 6 concurrent requests. The core cause is not a slower model but a overly conservative batching limit in the inference framework (for example, the maximum number of concurrent sequences was capped at 2). Once concurrency exceeded that threshold, requests entered a queue, long prefills blocked one another, and throughput was diluted.
2.3 Tuning Direction and Memory Trade-offs
Practical improvements include raising the maximum number of concurrent sequences and the maximum tokens per batch so the scheduler can merge more requests. However, memory utilization is already at 0.91 and the KV cache is near its limit; blindly increasing these values will trigger preemption and recomputation, which raises tail latency instead. A safer approach is layered handling: route short requests through a high-concurrency path and throttle long-context requests separately, or introduce prefix cache reuse to reduce repeated prefills.
Request entry├─ Short prompt (<4k) → High-concurrency batching path└─ Long prompt (≥16k) → Throttled queue + prefix cache reuseTrigger admission control when memory watermark > 0.9 to avoid KV preemption
3. Structured Query Generation: Correct Logic, Format Failures
3.1 Overall Results and Capability Profile
In a strict evaluation of 25 questions, 9 passed (36.0%): all 8 easy questions passed, 1 of 2 introductory questions, 0 of 2 medium questions, and 0 of 13 hard questions. Notably, all 25 questions completed the tool-calling loop autonomously: generating the statement, executing it in an embedded analytics database, and validating the result. This shows the model’s agent-style workflow orchestration is already quite mature. Complex multi-table joins and window functions (such as lag, ranking, and cumulative share) were all written correctly.
3.2 Main Failure Points: Precision and Output Contract
The largest source of lost points was numeric precision. The prompt required keeping two decimal places, and the model often omitted the rounding function, while the official judgment required the first row to match as a strict string. As a result, among the 20 logically correct answers, 15 were “logically right but one point short on format.” Another 3 were structural failures: a common table expression adding a discount table across multiple tables returned mismatched column names; a window-function-based grouped query returned 0 rows with mismatched column names; and a channel-definition misunderstanding computed distribution channel share as network channel share.
3.3 Evaluation Strictness Shapes the Conclusion
If floating-point comparison is relaxed to a 1e-6 tolerance, the pass rate rises to about 22/25 (88%). This suggests the evaluation criteria are themselves part of the conclusion. In engineering, the output contract (column names, column order, precision, row count) should be written explicitly into the prompt and the validation layer rather than expecting the model to guess.
# Validation layer: contract first, then numeric valuesdef check(df, expect_cols, tol=1e-6):if list(df.columns) != expect_cols: return False, "column name/order mismatch"if len(df) != expect_rows: return False, "row count mismatch"return allclose(df.iloc[0, 0], expect_first, tol), "ok"
4. Token Cost and Engineering Takeaways
Easy questions converged in an average of 2 steps and about 2.4k tokens; hard questions averaged 6.1 steps, with individual questions reaching 17 steps and 55.5k tokens. Cost grows super-linearly with the number of inference steps, so a maximum step count and budget circuit breaker should be set, and reusable intermediate results should be cached.
Overall, this version performs solidly in single-concurrency performance and workflow orchestration, with weaknesses concentrated in high-concurrency scheduling and strict format adherence. The deployment recommendation is to tune batching and the memory watermark and to split short and long requests. On the application side, strengthen output contract constraints and provide examples for window-function tasks. Using general capabilities such as the container platform, log service, and monitoring and alerting from Baidu AI Cloud to build a load-testing and observability pipeline can help locate queueing and memory bottlenecks faster, turning evaluation from a one-off script into a sustainable performance baseline.
