Local Deployment and Evaluation of Large Language Models: A Practical Guide
This guide explains how to move from simply loading a trillion-parameter, full-weight model locally to running it reliably under real workloads. It covers GPU memory budgeting, inference parameters that shape concurrency, root causes of high time-to-first-token (TTFT), evaluation criteria for structured query generation and tool-calling pipelines, and a concrete improvement checklist spanning prompts, few-shot examples, validation, serving, and regression testing.
1. Background: Running Is Not the Same as Performing Well
When a model with extremely large parameter counts (the subject here is the full-weight version at the trillion-parameter scale, with weights of roughly 1.6T) is deployed in an on-premise data center or a self-built GPU cluster, teams typically go through two stages. The first is “can it load and produce output.” The second is “can it produce output that is stable, accurate, and judgeable under business concurrency.” Many practice reports do poorly at the second stage, and the cause is usually not a loss of model capability, but a misalignment among three things: deployment parameters, batching strategy, and evaluation criteria.
A typical symptom is that the same model performs well in lightweight chat scenarios, but its pass rate drops sharply on tasks such as structured query generation, multi-table joins, and window functions. At the same time, time-to-first-token (TTFT) rises steeply under high concurrency. These two classes of problems need to be addressed separately; discussing them together leads to the wrong optimization direction.
2. Resource Planning Before Deployment: Treat GPU Memory as a Hard Constraint
The first principle of full-weight local deployment is to budget GPU memory first. The recommended order of accounting is:
- Weight footprint: full weights are a fixed cost, so first confirm they can be loaded in one pass.
- KV cache: grows roughly linearly with context length and concurrency, and is the main variable in long-prompt scenarios.
- Activations and temporary buffers: tied to batch size, and easy to overlook during load testing.
- Safety margin: reserve space for fragmentation, communication buffers, and burst traffic.
Illustrative accounting logic (pseudocode, conveying the idea only):
required = weight_bytes+ kv_per_token * avg_seq_len * max_num_seqs+ activation_bytes(max_num_batched_tokens)+ reserveassert required <= gpu_memory * target_util
When GPU memory utilization is pushed above 0.9, KV space is close to saturation. Raising the concurrency limit further only pushes requests into a queue instead of increasing effective throughput. This is one of the root causes of the TTFT degradation discussed later.
3. Key Inference Service Parameters and Concurrency Behavior
In mainstream high-throughput inference serving frameworks, two parameters determine concurrency behavior: the maximum number of concurrent sequences and the maximum number of tokens per batch. The two must be tuned as a pair:
- Raising only the maximum concurrent sequences, without raising the per-batch token limit, causes long prompts to block one another.
- Raising only the per-batch token limit, without enough GPU memory, directly triggers preallocation failures or frequent swapping.
A typical load-test matrix should cover input lengths of 2k/4k/16k/32k and concurrency of 1/2/4/6/8, recording prefill throughput, decode throughput, TTFT, and error rate for each combination. Only matrix-style data can separate “length decay” from “concurrency decay.”
As a general pattern, single-concurrency prefill throughput is on the order of a few thousand tokens/s and is relatively insensitive to length; as concurrency rises, it shows a roughly linear amortized decline. Single-concurrency decode throughput is typically on the order of tens of tokens/s and declines as concurrency and context length increase. If decode throughput falls to single digits when long prompts are combined with medium-to-high concurrency, it usually means requests within the batch are crowding each other out, not that the model has “become slower.”
4. Managing Time-to-First-Token: Queuing Is the Main Cause
TTFT rising linearly with input length is expected behavior. But when a 32k input already reaches tens of seconds at concurrency 1 and climbs to over a hundred seconds at concurrency 6, the main contribution comes from queuing rather than computation itself. Actionable measures include:
- Request tiering: route long-document tasks and short Q&A to separate service instances.
- Length bucketing: group requests into batches by input length so short requests are not held back by long ones.
- Limit constraints: set a maximum generation length and timeout per request to prevent individual jobs from occupying batch slots for a long time.
- Prefix reuse: enable prefix-caching capabilities for shared system prompts and fixed context.
- Elastic scaling: scale on queue length rather than CPU utilization on the container platform.
5. Designing Capability Evaluation: Criteria Determine the Conclusion
The most common misjudgment in structured query generation evaluation is counting “logically correct but wrongly formatted” output as a failure. If the criteria require strict matching of row count, column count, column names, and the first-row string, then a missing rounding function required by the question or an inconsistent column alias will fail the entire item. A common distribution in practice is: easy items nearly all pass, medium items partially pass, hard items have a very low pass rate, and the pass rate rises markedly once numeric tolerance is relaxed.
Therefore an evaluation report must explicitly state its judging criteria and report results under both a strict criterion and a tolerance criterion. Illustrative judging logic:
def judge(pred, gold, tol=None):if pred.columns != gold.columns: return Falseif len(pred) != len(gold): return Falseif tol is None:return str(pred.iloc[0, 0]) == str(gold.iloc[0, 0])return abs(float(pred.iloc[0, 0]) - float(gold.iloc[0, 0])) <= tol
Evaluating the tool-calling path matters just as much. Record the average number of steps, total token consumption, and where failures terminate, to determine whether the problem lies in SQL generation, execution validation, or result write-back. If the vast majority of items complete the full “generate–execute–validate–write back” loop autonomously, the agent skeleton is usable and the problem is concentrated in instruction following and output formatting.
6. An Actionable Improvement Checklist
- Prompt layer: fix the output contract in the system prompt, specifying decimal places for rounding, column names, sorting, and how empty results are handled.
- Few-shot layer: provide one canonical example each for error-prone patterns such as window functions, year-over-year and period-over-period comparisons, and cumulative share.
- Validation layer: run static checks before execution (column names, types, expected row count) and self-checks with automatic retries after execution.
- Serving layer: deploy with length bucketing, configure reasonable concurrency and per-batch token limits, and monitor queue depth and GPU memory levels with alerting.
- Evaluation layer: maintain a fixed test set and regression baseline, and automatically run the full matrix after every parameter change instead of tuning by feel.
7. Conclusion
For localizing a trillion-parameter full-weight model, performance and quality must be addressed on two fronts. On the performance side, the core tension is queuing and intra-batch interference under GPU memory constraints. On the quality side, the core tension is instruction following and judging criteria. Making load testing matrix-based, making judging criteria explicit, and baking the output contract into the prompt and validation chain will locate and converge most “underwhelming performance” issues. If an organization lacks the operations and tuning investment for a self-built cluster, it can also evaluate building inference services on top of general-purpose capabilities such as the container platform, object storage, and monitoring and alerting offered by Baidu AI Cloud, reducing the burden of low-level operations.
