Open-Weight LLMs: License Compliance Checklist and QLoRA Fine-Tuning Guide

    This article explains how "open-weight" models differ from traditional open-source software, provides a step-by-step checklist for verifying commercial-use licenses, shows how to estimate GPU memory requirements for different model sizes, and walks through a complete QLoRA fine-tuning workflow—from loading a 4-bit quantized base model to training and saving LoRA adapters. It is intended for developers who plan to deploy or fine-tune open-weight LLMs in production.

    1. How Open Weights Differ from Open-Source Software

    Traditional open-source software means publishing the source code. Users can read, modify, and compile the code, and fully understand how the program works.

    For large language models, “open source” usually means open weights. What the publisher releases is the trained parameter files—the weights themselves. Training data, data-cleaning pipelines, complete training code, and training logs are typically not fully disclosed. As a result, you can load the model locally and reproduce its inference capabilities, but you cannot reconstruct the full training process from the weights.

    The key differences:

    Dimension Traditional Open Source Open-Weight Models
    What is published Source code Parameter files; some projects also include inference code
    Reproducibility The same program can usually be built from source The full training process cannot be reconstructed from weights
    Licensing Commonly MIT, Apache 2.0, GPL, etc. Often custom licenses that may restrict commercial use or user scale
    Liability boundary Responsibility for code defects is relatively clear Responsibility for model outputs depends on the license and use case

    2. Verifying Commercial-Use Licenses

    The license determines whether a model can be used in your product. License review should happen in parallel with downloading the weights, and it should be based on the full license text—not summaries or community interpretations. The following items should be confirmed one by one:

    Checklist Item Question to Confirm
    Commercial use allowed Can it be used in for-profit products or internal business processes
    User scale limits Are there caps on monthly active users or total users? Is separate authorization needed beyond the cap
    Attribution Must copyright notices be retained or the model name be credited
    Prohibited domains Are uses such as medical diagnosis, weapons, or surveillance forbidden
    Redistribution Can the weights be bundled into your product or container images
    Derivative models Can fine-tuned models be published, and under what terms
    Legal review Ambiguous clauses should be confirmed in writing by legal counsel

    File integrity also needs verification. A loadable model directory typically contains config.json, tokenizer-related files (such as tokenizer.json and tokenizer_config.json), generation_config.json, and one or more *.safetensors weight files. The .safetensors format does not execute arbitrary code during loading, making it generally safer than pickle-based .bin files. After downloading, run the following commands in the model directory to compute checksums and compare them with the values published by the provider:

    1. ls -lh
    2. sha256sum *.safetensors

    In addition, read the model card’s sections on training data, known limitations, and evaluation results. This information determines which tasks the model suits and where you need additional testing.

    3. Estimating GPU Memory

    The memory required to load weights can be roughly estimated as:

    Weight memory ≈ parameter count × bytes per parameter

    FP16 or BF16 uses 2 bytes per parameter, INT8 uses 1 byte, and 4-bit quantization uses roughly 0.5 bytes. For a 7B model, FP16 weights take about 14 GB; after 4-bit quantization, about 3.5–4 GB (the extra covers quantization constants and similar overhead). For a 70B model, FP16 weights take about 140 GB; after 4-bit quantization, about 35–40 GB.

    Activations, the KV cache, optimizer states, and framework overhead consume additional memory. As a rule of thumb, reserve an extra 20%–50% on top of the weight memory; use the upper bound for long sequences or large batches. This ratio is only a preliminary estimate—the actual requirement should be based on peak memory measured on your target hardware.

    Model Size Typical Approach Reference Hardware
    ~7B 4-bit quantization + LoRA A single GPU with 16 GB or more
    ~13B–34B 4-bit quantization + LoRA A single GPU with 24 GB or more, or two mid-range GPUs
    ~70B 4-bit quantization + LoRA, or BF16 multi-GPU Multiple GPUs with 40 GB or more each, or a single 80 GB GPU
    ~100B and above Multi-GPU parallelism or cloud high-memory instances Choose based on measured peak memory, with headroom

    Consumer-grade GPUs are generally suitable only for small models or experimental tasks. Fine-tuning models at the hundred-billion-parameter scale typically requires multiple GPUs or cloud high-memory instances—do not assume a single consumer GPU will suffice.

    4. Complete QLoRA Fine-Tuning Workflow

    LoRA freezes the original weights and trains only a small set of low-rank matrices. QLoRA builds on this by loading the base model in 4-bit quantization, further reducing memory usage. The script below covers the full workflow from loading the model to saving the adapter.

    Step 1: Prepare dependencies. Recommended versions are as follows (always defer to the official documentation of the model you are using): torch ≥ 2.1, transformers ≥ 4.40, peft ≥ 0.10, bitsandbytes ≥ 0.43, accelerate, datasets.

    Step 2: Prepare the training data. The data should be a UTF-8 encoded jsonl file with one sample per line, using the field name text containing the fully concatenated training text. Training data must not contain unauthorized personal information or corporate secrets.

    1. {"text": "User: How do I reset my router password?\nAssistant: First unplug it for 30 seconds, then hold the reset button on the back for about 10 seconds, and log in with the default account."}

    Step 3: Run the training script. The script assumes the model directory is a local path, so it uses local_files_only=True to avoid network access during training.

    ```python
    import torch
    from datasets import load_dataset
    from transformers import (
    AutoModelForCausalLM,
    AutoTokenizer,
    BitsAndBytesConfig,
    DataCollatorForLanguageModeling,
    Trainer,
    TrainingArguments,
    )
    from peft import LoraConfig, get_peft_model, prepare_model_for_kbit_training

    MODEL_DIR = “path/to/local-open-weights-model” # Local directory containing config.json, tokenizer files, and *.safetensors
    DATA_FILE = “train.jsonl” # One {“text”: “…”} per line
    OUTPUT_DIR = “qlora-output”

    1. Detect bf16 support; fall back to fp16 if unavailable

    use_bf16 = torch.cuda.is_available() and torch.cuda.is_bf16_supported()
    compute_dtype = torch.bfloat16 if use_bf16 else torch.float16

    2. Load the tokenizer; use eos_token as pad_token if none exists

    tokenizer = AutoTokenizer.from_pretrained(MODEL_DIR, local_files_only=True)
    if tokenizer.pad_token is None:
    tokenizer.pad_token = tokenizer.eos_token

    3. Load the base model in 4-bit quantization

    bnb_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_quant_type=”nf4”,
    bnb_4bit_compute_dtype=compute_dtype,
    bnb_4bit_use_double_quant=True,
    )
    model = AutoModelForCausalLM.from_pretrained(
    MODEL_DIR,
    quantization_config=bnb_config,
    device_map=”auto”,
    local_files_only=True,
    )
    model = prepare_model_for_kbit_training(model) # Freeze quantized layers and enable gradient checkpointing
    model.config.use_cache = False # Disable KV cache during training

    4. Configure LoRA; base weights remain frozen

    targetmodules must match the model architecture. Use [n for n, in model.named_modules()] to inspect module names.

    lora_config = LoraConfig(
    r=16,
    lora_alpha=32,
    lora_dropout=0.05,
    target_modules=[“q_proj”, “k_proj”, “v_pro