Local Inference Benchmarking and Tuning for Very Large Models
This article presents a reproducible evaluation framework for local deployment of very large full-parameter models, combining service performance testing with task quality assessment. It examines prefill and decode throughput, concurrency degradation, TTFT, KV Cache memory pressure, and structured SQL generation contract issues, then outlines a tuning and deployment roadmap for moving from “the model runs” to “the model is deliverable and regressable.”
Introduction
The core value of local deployment for very large full-parameter models lies in data controllability, customization flexibility, and predictable long-term cost. However, local deployment does not mean simply “getting the model to run.” What determines real usability is two classes of questions: first, whether the inference service remains stable under different input lengths and concurrency pressure; second, whether the model reliably delivers results under real task contracts. Looking only at single-concurrency peak throughput can easily overestimate system capability, while looking only at a loose pass rate can hide delivery issues such as formatting, column names, and metric definitions.
Evaluation should therefore cover both service performance and task quality, using a reproducible load matrix and a two-track judging approach. This article uses a general evaluation framework as an example to discuss prefill and decode throughput, concurrency degradation, TTFT, KV Cache memory pressure, and structured SQL generation issues including tool-call loops, strict judging, precision formatting, and column-name contracts. It concludes with a tuning roadmap.
1. Evaluation Framework Design Principles
1.1 Fixed Environment and Versions
Local inference evaluation must first fix key variables such as hardware, drivers, inference framework versions, model precision, memory utilization, KV Cache configuration, maximum number of concurrent sequences, maximum batch tokens, and related settings. Any parameter change should be recorded; otherwise, data from different batches is not comparable. In particular, record cold-start versus warm-start differences, whether chunked prefill is enabled, whether continuous batching is enabled, and request timeout and retry policies.
1.2 Load Matrix and Metric Definitions
The load should cover both length and concurrency gradients: input lengths can be 2k, 4k, 8k, 16k, and 32k; concurrency can be 1, 2, 4, and 6; output length should be fixed; sampling temperature should be 0 or low; and each case should be repeated multiple times with the median recorded. Core metrics include:
- Prefill throughput: input tokens processed per unit time;
- Decode throughput: output tokens generated per unit time;
- TTFT: time to first token, separating queue wait from actual computation;
- End-to-end latency, error rate, and timeout rate;
- Peak memory, KV Cache usage, and queue wait length;
- Task-side token consumption, tool-call steps, and retry count.
Example pseudocode:
for length in [2048, 4096, 8192, 16384, 32768]:for concurrency in [1, 2, 4, 6]:warmup()results = run_batch(prompts_by_length[length],concurrency=concurrency,repeats=5,temperature=0)record(median(results))
1.3 Quality Question Set and Two-Track Judging
The task quality question set should be graded as trivial, easy, medium, and hard. Each question should specify a clear prompt, database schema, execution environment, expected result, and judging rules. Judging should use two tracks in parallel: strict judging requires exact matches for row count, column count, column names, and the first-row string; tolerant judging allows numeric tolerance, for example 1e-6. Strict judging is used as a delivery gate, while tolerant judging is used for capability diagnosis. Both should be reported together to avoid conflating “logic correct, format poor” with genuine failure.
2. Inference Service Performance: Throughput, Concurrency, and Latency
In a set of local measurements, single-concurrency prefill peaked at about 757.7 tok/s with 4k input. Across the 2k to 32k range, throughput was about 629 to 758 tok/s, with no obvious length degradation. This indicates that under single-concurrency, short-queue conditions, prefill computation efficiency is relatively stable. But as concurrency increased, degradation became obvious: at 2 concurrency, throughput dropped by about 30% to 45%; at 4 concurrency, by about 50%; and at 6 concurrency with 2k input, it fell from about 688 tok/s to about 228 tok/s, a drop of about 63%.
On the decode side, single-concurrency throughput was about 23.8 to 28.7 tok/s and remained stable. Under high concurrency, it dropped to 8 to 18 tok/s. Long prompts (16k/32k) combined with 4 to 6 concurrency produced low points of 8 to 11 tok/s. The 32k scenario rebounded to 20 to 28 tok/s, which may be data-point noise and requires more repetitions to confirm. TTFT increased approximately linearly with input length. At 32k, it rose from about 51.5s at 1 concurrency to about 186.4s at 6 concurrency, with queuing as the main cause.
Bottleneck analysis: when the maximum number of concurrent sequences is limited to 2, requests beyond 2 enter the queue. Long prefill requests block one another, worsening TTFT and spreading prefill throughput across requests. Memory utilization was about 0.91, and KV Cache was nearly full, so simply increasing concurrency was not feasible. Improvement directions include: within the memory limit, increasing the maximum number of concurrent sequences and maximum batch tokens; enabling chunked prefill to reduce blocking of short requests by long requests; scheduling by input-length buckets; isolating prefill and decode resources; setting concurrency limits and priority queues; and continuously monitoring queue wait, KV occupancy, and TTFT P95.
3. Structured SQL Task Quality: Separate Capability from Contract
In 25 structured SQL questions, the model was able to autonomously complete the tool-call loop in every case: generate SQL, execute it, validate it, and confirm the result. Complex multi-table JOINs and window functions were mostly written correctly; only a few complex questions showed structural errors. Under strict judging, 9/25 passed, about 36%: trivial 8/8, easy 1/2, medium 0/2, and hard 0/13. The main scoring loss was not a complete inability to compute, but ROUND precision: the model often omitted the ROUND(…,2) required by the prompt, and strict judging required the first-row string to match exactly. As a result, about 15 of the 25 questions fell into the “logic correct, format off by one decimal place” category.
Structural failures included: in a multi-table discount CTE scenario, the final returned column names did not match; in a period-over-period window-function scenario, the query returned 0 rows and the column names did not match; and in a channel-definition scenario, the expected share for one channel was about 73.3%, but the model calculated another channel. In terms of token consumption, trivial/easy questions averaged about 2 steps and about 2.2k plus 0.2k tokens; hard questions averaged about 6.1 steps, with a maximum of 17 steps and 55.5k tokens, and another case at 14 steps and 55k tokens. If numeric tolerance was relaxed to 1e-6, the pass rate was about 22/25, or about 88%.
This shows that strict judging is highly sensitive to interface contracts. SQL generation is not only a computation problem; it also includes delivery contracts such as column names, sorting, ROUND, NULL handling, percentage denominators, and channel definitions. Optimization suggestions: strengthen the system prompt to require “strictly follow the ROUND and format requirements in the prompt”; add schema validation, column mapping, first-row format validation, and automatic repair retries to the tool-call loop; provide example SQL for window functions; and maintain a definitions dictionary clarifying channels, percentages, and denominators. Strict and tolerant judging should be reported together: strict for gates, tolerant for diagnosis.
def strict_match(actual, expected):if len(actual.rows) != len(expected.rows):return Falseif actual.columns != expected.columns:return Falseif actual.rows[0] != expected.rows[0]:return Falsereturn Truedef tolerant_match(actual, expected, eps=1e-6):if actual.columns != expected.columns:return Falseif len(actual.rows) != len(expected.rows):return Falsefor a, e in zip(actual.rows[0], expected.rows[0]):if abs(float(a) - float(e)) > eps:return Falsereturn True
4. Tuning Roadmap and Deployment Recommendations
On the service side, establish a parameter sweep matrix: scan the maximum number of concurrent sequences, maximum batch tokens, KV Cache memory ratio, chunked prefill switch, and request timeout and retry policies item by item, recording throughput, TTFT P95, error rate, and peak memory. On the quality side, use prompt templates, few-shot examples, tool-call state machines, SQL formatting, schema constraints, and result post-processing, and classify errors into four categories: calculation errors, definition errors, format errors, and column-name errors. On the evaluation side, fix the question set, repeat runs multiple times, record confidence intervals and cost, and set regression gates for strict pass rate, tolerant pass rate, TTFT P95, and decode throughput.
During deployment, start with small-traffic canary releases, rate-limit by input length and concurrency quota, and define clear SLOs. For long-context requests, prioritize bucketing and rate limiting; for high-concurrency short requests, prioritize batching efficiency; for structured tasks, strict contract validation must be front-loaded rather than relying on manual user repair. Only by closing the loop between service performance evaluation and task quality evaluation can local deployment of very large models move from “runs” to “deliverable, regressable, and operable.”
