How to Choose Open-Source Code LLMs: Architecture, Lightweight Models, and Licensing

    This article provides a comprehensive guide for selecting open-source code large language models (LLMs). It covers key factors such as task types, deployment environments, and commercial requirements. Readers will learn how to calculate compute and VRAM requirements for Mixture of Experts (MoE) architectures, allocate tasks between flagship and lightweight models, establish internal evaluation benchmarks, navigate complex licensing agreements, and build model-agnostic infrastructure.

    How to Choose Open-Source Code LLMs? Start with Tasks, Then Environment

    Before selection, clarify three things: task type, deployment environment, and commercial requirements. Open-source code models can now handle real-world work in code completion, refactoring, and scripting, but different model scales vary significantly in cost and latency. Deciding based solely on leaderboard rankings may lead teams to pay for unused capabilities or discover insufficient hardware during deployment.

    This article avoids citing unverifiable specific scores or improvement margins. Before selection, rely on official model cards, release notes, and independent evaluations, and conduct tests using your team’s actual code tasks.

    Calculating Compute and VRAM for MoE Architectures

    Mixture of Experts (MoE) models divide total parameters into multiple expert networks, activating only a portion during each forward pass. This design decouples model capacity from the computation required for a single inference. As total parameters increase, the knowledge and expressive power the model can hold increase accordingly, while the actual computed parameters per pass remain limited by the activation size.

    When deploying, distinguish between two numbers. Compute depends primarily on activated parameters, but VRAM must accommodate the weights of all experts, because which experts are routed during inference depends on the input. Therefore, VRAM planning should be based on total parameters, not activated ones. If a team estimates VRAM based only on activated parameters, the purchased hardware will likely be insufficient.

    Use the following methods for a preliminary estimate:

    • Weight VRAM is approximately the total parameters multiplied by the bytes per parameter. BF16 is about 2 bytes, INT8 is about 1 byte, and INT4 is about 0.5 bytes.
    • Beyond weights, reserve space for the KV cache, activations, and the inference framework’s own overhead. In long-context scenarios, the KV cache can consume a significant proportion.
    • Throughput depends on batch size, context length, and concurrency; looking at model size alone cannot determine service capacity.

    Example: Assuming an MoE model with 300B total parameters, the weights after INT4 quantization require about 150GB. This already exceeds the VRAM of a single common consumer-grade GPU, typically requiring multiple cards or server-grade equipment. This is only a lower-bound estimate; measure peak VRAM and throughput on target hardware before actual deployment.

    Division of Labor: Flagship vs. Lightweight Versions

    Flagship versions suit complex tasks, while lightweight versions fit high-frequency, low-difficulty tasks. The lightweight versions described in the original text are independently trained new models, not pruned from the flagship versions. The text also notes that this series adopts a hybrid mechanism of sparse and linear attention for the first time, aiming to reduce the overhead of long-context inference. This design directly benefits scenarios requiring reading an entire code repository, but actual gains need validation on your own codebase.

    Task classification can refer to the table below:

    Task Type Recommended Model Main Considerations
    Line-level completion, small single-file changes Lightweight version Low latency, low per-call cost
    Single-file refactoring, unit test generation Lightweight version; upgrade if results fail Sufficient quality; automatic retry on failure
    Cross-repository refactoring, architecture design Flagship version Context understanding and reasoning capabilities take priority
    Tasks involving sensitive code Locally deployed lightweight version Code stays within the intranet

    This division balances cost and quality. Routing rules can initially use manually annotated task types, switching to automatic judgment after accumulating data.

    How to Evaluate Coding Capabilities?

    Terminal operation benchmarks evaluate a model’s ability to understand tasks, plan steps, execute commands, read feedback, and correct errors in a command-line environment. It is closer to real-world DevOps scenarios than “generating a snippet of correct-looking code.” However, benchmark scores only reflect the model’s performance on specific test sets and do not directly equate to effectiveness in team projects.

    A more reliable approach is to establish an internal evaluation set:

    1. Extract 100 to 300 tasks from the past six months of real tickets, bug fixes, and code review records.
    2. Write automatically verifiable pass conditions for each task, such as tests passing, successful builds, or expected API behavior.
    3. Standardize prompts and execution environments for candidate models, recording pass rates, modified lines, retry counts, and time consumed.
    4. Sample and manually review passed results to check for “tests pass but logic is wrong” situations.

    Evaluations should be repeated regularly. Open-source models iterate quickly; conclusions from six months ago may no longer be valid.

    How to Check Licenses? Separate Code and Weights

    A common misconception with open-source code models is treating the code repository’s license as the entire model’s license. The code repository and model weights may be subject to different licenses, and the terms for the flagship and lightweight versions within the same series may also differ. Before commercial use, verify the following items one by one:

    1. Confirm the respective license names and version numbers for the code and weights.
    2. Check if commercial use is allowed and whether there are restrictions on user scale, revenue scale, or industry.
    3. Check redistribution conditions and whether fine-tuned models can be released publicly or used as closed-source.
    4. Check attribution requirements and usage policies to confirm if there are prohibited application scenarios.
    5. Compare the terms of the flagship and lightweight versions to confirm consistency.
    6. Save a snapshot of the original license text and access date to avoid inability to trace back if terms change later.

    Common mistakes include: reading only the model card summary without reading the full terms; applying the lenient license of the code repository to the weights; ignoring that products fine-tuned from the model are still bound by the original license. For production environments or external services, it is recommended to have the compliance team review before integrating the model, rather than reworking after launch.

    How to Build Infrastructure for Deployment?

    Teams can unify model inference and evaluation into a single pipeline. Specific practices include: using object storage to save model files, evaluation data, and results; using a container platform to deploy inference services for easy model version switching; using logging services and monitoring alerts to track latency, error rates, and resource utilization.

    Architecturally, maintain model agnosticism. Set up a unified interface layer between business code and the model, so callers do not directly depend on a specific model’s parameter format or prompt habits. This way, replacing a model only requires modifying configurations and evaluation results, without rewriting business logic.

    In summary, selection can follow three steps: first, determine the model scale based on task classification; second, verify effectiveness using internal evaluations; finally, complete license reviews and select the deployment method. Do not treat a specific generation of models as a long-term answer; teams should retain the capability to “evaluate and replace models” internally.