Evaluating and Selecting Locally Quantized LLMs for Coding: A Practical Benchmark
This article presents a reproducible framework for evaluating locally quantized large language models on real coding tasks. Instead of relying on subjective impressions or model-as-a-judge scoring, it uses fully automated, verifiable signals such as acceptance checks, unit test pass rates, lint warnings, and tool-call success. Three quantization approaches are compared across tool use, bug fixing, and end-to-end application builds, revealing distinct trade-offs among speed, cost, and code quality. The article also identifies the key variables behind these results and offers practical selection guidance for different development scenarios.
1. Background: How to Evaluate a Coding Model Running Locally
With data compliance requirements, offline development needs, and the goal of controlling inference costs, more teams are moving coding-focused large language models onto local workstations or self-hosted inference clusters. The real challenge is not whether the model runs, but whether it is useful once it does. The same model family, processed with different quantization schemes, can drift in output style, reasoning depth, and tool-calling strategy. These differences show up as significant gaps in task duration, number of interaction turns, and code quality.
Evaluation should therefore shift from a single focus on generation speed to multi-dimensional observation of agent behavior: whether the model chooses to call tools, whether it plans before executing, whether prompt caching is reused effectively, and whether generated code includes tests. Using an independent benchmark on a dual-accelerator local environment as a reference point, this article abstracts a reusable evaluation framework and selection method.
2. Benchmark Design: Let the Machine Be the Judge
The first principle of a high-quality benchmark is to eliminate subjective bias. A practical approach is to make the entire process automatically judged by programs, without introducing any large language model as a judge, avoiding the preference contamination caused by “models evaluating models.”
The benchmark consists of three parts:
- Tool-calling capability: The model must act as an agent and call more than twenty native tools, covering common development actions such as file reading and writing, command execution, dependency queries, and log retrieval.
- Bug-fixing capability: Fix more than ten real defects in a project written in a somewhat functional programming language with a relatively unusual concurrency model, testing how quickly the model understands an unfamiliar ecosystem.
- End-to-end build capability: Complete a full web application with nearly twenty acceptance checks, covering API correctness, data persistence, error handling, and basic security practices.
Scoring relies entirely on verifiable signals: unit test pass rate, number of static-check warnings, acceptance script hits, and end-to-end request response codes. A sample scoring skeleton is shown below:
score = (0.45 * acceptance_pass_ratio # Ratio of acceptance checks passed+ 0.25 * unit_test_pass_ratio # Pass rate of bundled test cases+ 0.20 * (1 - lint_warning_rate) # Static-check cleanliness+ 0.10 * tool_call_success_ratio # Tool-call success rate)
The value of this design is that no answer that merely “looks good” can slip through; only artifacts that truly run and can be verified will score.
3. Measured Performance of Three Quantization Schemes
All three models passed every test, but their working modes were completely different, corresponding to three typical engineering orientations.
1. Low-bit quantization: trading “less code” for “faster output”
The scheme using extremely low-bit weight quantization stood out the most: the application build took less than twenty minutes, with a total output of about twenty thousand tokens. Its inference engine did not have an advantage in single-step throughput, but the model tended toward minimal expression, with almost no lengthy explanations, leaving the entire budget for executable code.
The takeaway is: end-to-end latency ≈ single-step latency × number of steps + output tokens ÷ generation throughput. When output length is compressed to the extreme, the total time can still lead even if the underlying engine is somewhat slower. It suits scenarios such as prototype validation, scaffolding generation, and batch boilerplate code, where the priority is “get it running first, optimize later.”
2. Mid-precision floating-point quantization: trading “planning” for “low cost”
The scheme using eight-bit floating-point quantization had the fewest interaction turns, only about seventy, with a very “engineering-like” behavior pattern: it first output an implementation plan, then implemented it step by step, with very little trial and error in between. More importantly, its prompt cache hit rate exceeded ninety percent, meaning repeated prefixes in long contexts did not need to be recomputed, pushing the compute cost per task to the lowest level.
This explains why it is best suited for unattended background autonomous runs: stable plan-driven behavior reduces the frequency of manual intervention, while high cache reuse makes long-running, multi-turn agent loops economically viable.
3. High-precision low-bit mixed quantization: trading “thinking” for “quality”
The scheme using four-bit non-uniform mixed quantization took the longest, close to twenty-eight minutes, because it performed extensive internal reasoning before each interaction turn. The cost was time; the benefit was engineering quality: the most standardized code style, the largest number of bundled test cases (eighteen), and the fewest static-check warnings.
For codebases that require long-term maintenance and multi-person collaboration, this “slow but steady” orientation can significantly reduce subsequent rework and review costs.
4. Four Key Variables Behind the Results
- Quantization precision: Low-bit-width compression changes the model’s output entropy, usually manifesting as shorter, more direct answers; higher-precision or mixed-precision schemes are more likely to retain lengthy chains of thought.
- Inference engine implementation: Differences in batching strategy, operator fusion, and memory layout across engines running the same model can produce several-fold throughput gaps.
- Prompt caching strategy: Prefix reuse rate directly determines the marginal cost of long-context agent tasks and is the primary economic metric for long-running background scenarios.
- Agent scaffolding: Whether tool descriptions are clear and whether failure feedback is structured often affects the final number of turns and success rate more than the model itself.
5. Actionable Selection Recommendations
- Daily development workhorse: prioritize the mid-precision floating-point quantization version, which offers the best balance of efficiency and cost; its plan-driven behavior makes it easy to integrate into CI pipelines.
- Pursuing standards and test coverage: choose the high-precision mixed quantization version, trading time for quality, suitable for core modules and the hardening stage before delivery.
- Rapid prototyping: choose the low-bit quantization version to get a runnable skeleton in minutes, then hand it to a stronger scheme for refactoring.
Engineering practice favors a “combination punch”: use the low-bit scheme for exploration and drafting, the mid-precision scheme for execution and self-testing, and the high-precision scheme for review and supplementary testing. If using cloud inference services, it is worth paying attention to general capabilities such as object storage, message queues, container platforms, log services, and monitoring and alerting, and solidifying the evaluation pipeline, artifact archiving, and metrics dashboards. On Baidu AI Cloud, a complete model evaluation and iteration loop can likewise be built on top of these general product categories.
6. Conclusion
The competitive focus of local coding models has shifted from “parameter scale” to the system efficiency of “quantization scheme + inference engine + agent orchestration.” Only by establishing a benchmark with automatic scoring and no model judge, and by quantitatively observing duration, turns, cache hits, and test coverage, can selection turn from subjective impressions into reproducible engineering conclusions.
