How to Choose and Deploy Open-Source Large Language Models: A Practical Guide for Developers

    Public benchmarks are useful for narrowing down open-source LLMs, but engineering teams need to answer three more practical questions: How well does a model perform on their own code, how much GPU memory does deployment require, and how can its output fit into the existing development workflow? This guide provides an actionable evaluation framework for those questions, including task-based testing, VRAM estimation, and the trade-offs between FP16/BF16, INT8, and INT4 quantization.

    Teams often start by reviewing public benchmarks when selecting an open-source large language model. Benchmark scores are useful for initial screening, but the questions that matter in production are more specific:

    1. How well does the model perform on our own code?
    2. How much GPU memory does deployment require?
    3. How can its output integrate with our existing development workflow?

    This article provides practical methods for answering those questions.

    The recommendations apply to human-reviewed use cases such as code completion, unit test drafting, pull request pre-review, and long-file analysis. They do not apply to fully automated merges without human review or to final decisions involving safety-critical code. These methods should also not be used to process unauthorized source code or personal data.

    1. Evaluate Models on Your Own Tasks First

    Build a test set of 30 to 50 real tasks from the past six months. Suitable sources include issue tickets and changes that have already been merged.

    Divide the tasks into four categories:

    • Function completion
    • Unit test generation for existing modules
    • Bug localization
    • Pull request review

    Include at least five tasks in each category. This helps prevent the test set from being dominated by trivial examples.

    Record every task using the same template:

    Field Requirement Example
    Task ID Unique and suitable for repeated testing T-017
    Task type Function completion, test generation, bug localization, or pull request review Test generation
    Input materials Relevant files and requirements, with secrets and customer data removed utils/date.py and its requirements
    Pass criteria Quantifiable conditions, such as all unit tests passing with no new static-analysis warnings pytest and ruff pass
    Manual editing time Minutes from receiving the output to producing code that can be merged 12 minutes
    Error type Use the classification below API misuse

    Use a consistent timing method. Ideally, have the same person record the time and conduct a blind evaluation, so the reviewer does not know which model produced a given output.

    Start the timer when the output is received and stop when the code is ready to merge. State clearly whether rework time is included.

    Classify errors as follows:

    Error type Definition Severity
    API misuse Calls a nonexistent function or parameter, or uses an API that is incompatible with the current version Medium
    Logic error Does not meet the business requirements or misses boundary conditions High
    Invalid test Passes without covering critical branches, or contains an assertion that is always true High
    Security omission Fails to validate input, hard-codes credentials, or permits unauthorized access Critical

    For scoring, first determine whether each task passes or fails. A security omission is an automatic failure. For other errors, calculate each model’s failure rate and average manual editing time by severity. Evaluate both metrics together rather than relying on a single score.

    2. Estimating VRAM and Choosing Between INT8 and INT4

    Estimate total GPU memory with the following formula:

    Total VRAM ≈ weight memory + KV cache memory + activation and framework overhead

    Weight memory can be estimated as:

    Weight memory = parameter count × bytes per parameter

    FP16 and BF16 use 2 bytes per parameter, INT8 uses 1 byte, and INT4 uses 0.5 bytes.

    KV cache memory can be estimated as:

    KV cache memory ≈ 2 × number of layers × number of KV heads × head dimension × context length × concurrency × bytes per element

    The factor of 2 represents the separate key and value caches. Reserve an additional 10% to 20% for framework overhead and activations.

    For a 7B model, the weights require approximately:

    • 14 GB in FP16
    • 7 GB in INT8
    • 3.5 GB in INT4

    However, if the deployment must support eight concurrent requests with an 8K context per request, KV cache usage may exceed the memory required for the weights. Always plug the layer count and number of KV heads from the model configuration into the formula instead of looking only at parameter-based weight estimates.

    The quantization trade-offs are summarized below. Actual results should be verified on your own test set.

    Configuration VRAM relative to FP16 Accuracy impact Throughput Best-use boundary
    FP16/BF16 Baseline Baseline Baseline Use when accuracy is the highest priority and resources are available
    INT8 Approximately half Usually small, but still requires testing Depends on the inference framework and hardware A practical default starting point for most code-related tasks