Home / Insights / Generative AI and LLMs
Generative AI and LLMs
Running Open-Weight Models (Llama, Mistral, Qwen) on Your Own Infrastructure: A Planning Guide
The summer 2024 releases of Llama 3.1, Mistral NeMo and Qwen2 made self-hosting a serious option for confidential AI workloads. Success depends less on the model download than on licence checks, sizing, serving, security and who runs it afterwards.
Key takeaways
- Open-weight does not mean open source: Llama, Mistral and Qwen models ship under different licences, and the terms can differ between sizes in the same family.
- Choose the smallest model that passes your own evaluation; memory for weights scales with parameter count and precision, so size drives hardware cost more than anything else.
- Use a purpose-built serving engine with batching and efficient KV cache management rather than a research script; it is the difference between serving a handful of users and hundreds.
- Treat the model endpoint like any production service: authentication, private networking, logging with redaction, patching and an owner on call.
- Plan the first twelve months, not just launch: evaluation, model upgrades, capacity growth and a fallback route if the endpoint fails.
On this page
- Should you run an open-weight model yourself?
- How do you choose a model family and check the licence?
- How do you size hardware for a self-hosted model?
- Which serving stack should you use?
- How do you secure and operate the deployment?
- What will it cost, and what are the main risks?
- A step-by-step plan for your first deployment
- Frequently asked questions
- Sources and methodology
In the space of a few weeks in mid-2024, the open-weight model landscape changed. Alibaba’s Qwen team released Qwen2 in June, Mistral AI released Mistral NeMo on 18 July, and Meta released Llama 3.1 on 23 July, including a 405 billion parameter model alongside upgraded 8B and 70B versions. For organisations that cannot send confidential documents to a third-party API, or that run high-volume workloads, running a capable model inside their own cloud account or data centre is now realistic.
This guide is for CTOs, infrastructure leads and product owners planning a first self-hosted deployment. It walks through the decisions in order: whether to self-host at all, how to pick a model and check its licence, how to size hardware, which serving stack to use, how to secure and operate it, and what to budget for. It assumes you already know which business workflow you want to support.
Should you run an open-weight model yourself?
Self-hosting gives you control over where data goes, which model version runs and how costs scale. It also makes you responsible for uptime, security and quality. Be clear about which benefit you are buying.
Good reasons to self-host
- Data cannot leave your environment because of client contracts, regulation or internal policy.
- Steady, high volume where fixed infrastructure becomes cheaper per request than a metered API.
- Version stability: you decide when the model changes, which matters for validated workflows.
- Customisation: you can fine-tune and serve your own variants.
- Air-gapped or on-premises sites with no reliable external connectivity.
Weak reasons
- Assuming it will be cheaper without modelling utilisation; idle GPUs are expensive.
- Expecting open models to match the best proprietary models on every task without testing.
- Avoiding vendor lock-in while having no team to run the platform.
| Option | Data control | Operational effort | Cost profile | Best fit |
|---|---|---|---|---|
| Proprietary model via public API | Lowest; governed by provider terms | Lowest | Per token | Non-sensitive data, variable volume |
| Open-weight model via managed cloud endpoint | Medium to high; stays in your cloud tenancy depending on service | Low to medium | Per token or per instance hour | Teams wanting open models without running GPUs |
| Open-weight model on your own cloud GPUs | High | Medium to high | Per instance hour | Confidential data, steady volume |
| Open-weight model on-premises | Highest | Highest | Capital expenditure plus operations | Strict residency, air-gapped sites |
How do you choose a model family and check the licence?
Start with a shortlist of two or three models in the size range your hardware budget allows, then test them on your own data. Licence checks happen in parallel, not after you have built everything.
The main families in mid-2024
- Llama 3.1 (Meta). Meta’s announcement describes 8B, 70B and 405B models with a 128K context length and support for eight languages, plus Llama Guard 3 for safety classification and Prompt Guard for prompt injection filtering. Meta also says it converted the 405B model to FP8 so it can run within a single server node.
- Mistral NeMo (Mistral AI with NVIDIA). According to Mistral AI, NeMo is a 12B model with a context window of up to 128k tokens, released under Apache 2.0, trained with quantisation awareness so FP8 inference does not lose quality, and using a new tokeniser that compresses many languages more efficiently.
- Qwen2 (Alibaba). The Qwen2 release covers 0.5B, 1.5B, 7B, a 57B mixture-of-experts model and 72B, with training data in 27 languages beyond English and Chinese. Context ranges from 32K on the smallest models to 128K on the 7B and 72B.
Licence terms that matter
Open-weight licences vary, sometimes within one family:
- Qwen2: the 0.5B, 1.5B, 7B and 57B-A14B models are Apache 2.0, while the 72B models use the Qianwen License.
- Llama 3.1: the Llama 3.1 Community License requires a separate licence from Meta for organisations whose products had more than 700 million monthly active users on the release date, requires displaying Built with Llama when you distribute the model or a product containing it, requires derived models that are distributed to have names beginning with Llama, and incorporates an acceptable use policy. It is governed by California law.
- Mistral: NeMo is Apache 2.0, but not every Mistral model is; check each checkpoint.
Record the licence for the exact checkpoint, who reviewed it and the date. If you plan to fine-tune and distribute a model to customers, have counsel review naming, attribution and acceptable use obligations before you start.
Practical selection criteria
- Quality on your evaluation set, including your languages.
- Context length you actually need, not the maximum advertised.
- Memory footprint at the precision you intend to serve.
- Support in your chosen serving engine and quantisation formats.
- Availability of safety classifiers you can run alongside.
How do you size hardware for a self-hosted model?
Detailed capacity planning deserves its own exercise, but the first-order logic is simple enough to sanity-check vendor quotes.
Memory for weights
Model weights need roughly parameter count multiplied by bytes per parameter. At 16-bit precision that is about 2 bytes per parameter, so an 8B model needs around 16 GB just for weights and a 70B model around 140 GB. At 8-bit precision those roughly halve, and at 4-bit roughly quarter. These are approximations; real deployments need headroom.
Memory for context
Each active request also needs memory for its key-value (KV) cache, which grows with context length and the number of concurrent requests. Long contexts and many simultaneous users can need as much memory as the weights themselves. This is why a model that fits on a GPU in a demo may run out of memory under production load.
Throughput and latency
What users feel is time to first token and tokens per second. Both depend on model size, precision, GPU type, batch size and prompt length. Measure them with your real prompts at your expected concurrency, using the serving engine you will deploy.
| Model size (illustrative) | Approximate weights at 16-bit | Typical starting hardware | Notes |
|---|---|---|---|
| 7B to 12B | 14 to 24 GB | One data-centre GPU with adequate memory | Good for classification, extraction, drafting |
| Around 70B | Around 140 GB | Multiple GPUs with tensor parallelism, or fewer with quantisation | Stronger reasoning; higher cost per request |
| 400B class | Hundreds of GB | A full multi-GPU server node, FP8 or lower | Rarely justified for a first deployment |
For example, a 150-person legal services firm piloting a private document assistant might start with a 7B to 12B model quantised to 8-bit on a single GPU instance in its own cloud account, measure quality on 200 real queries, and only move to a 70B model if the evaluation shows a clear gap. This is illustrative; your own measurements decide.
Which serving stack should you use?
Do not serve production traffic from a notebook or a simple generation script. Use an inference engine designed for concurrent requests.
Why the engine matters
The vLLM project’s research paper, Efficient Memory Management for Large Language Model Serving with PagedAttention, explains the core problem: the KV cache for each request is large and changes size during generation, and poor memory management wastes it through fragmentation, limiting batch size. PagedAttention manages that memory like operating system pages, and the authors report two to four times higher throughput than earlier systems at the same latency. In practice, engine choice can change how many GPUs you need.
A typical stack
- Inference server: vLLM or Hugging Face Text Generation Inference, exposing an OpenAI-compatible API so application code is portable between self-hosted and hosted models.
- Container and orchestration: Docker images with pinned versions, deployed on Kubernetes or a managed container service with GPU node pools.
- Gateway: authentication, per-team rate limits, request logging and routing between models.
- Safety layer: input and output classifiers, such as Llama Guard 3, plus your own policy checks.
- Application services: retrieval, prompt templates and business logic, kept separate from the model server so you can swap models.
- Observability: latency, throughput, GPU utilisation, error rates and quality samples.
If the assistant answers questions from internal documents, the retrieval layer must respect each user’s permissions; our guide to permission-aware enterprise search explains how. For deciding how much to place in the prompt versus retrieve, see long context windows versus retrieval.
How do you secure and operate the deployment?
Security controls
- Keep inference servers on private subnets; expose them only through an authenticated gateway.
- Integrate with your identity provider and apply role-based access per application.
- Encrypt data in transit and at rest, including model weights and logs.
- Log prompts and outputs only as far as needed, with redaction and a retention limit.
- Verify model files come from the official source and record their checksums.
- Patch serving engines, drivers and base images on a schedule.
Operations
- Ownership: name the team responsible for the endpoint, its on-call rota and its budget.
- Capacity: autoscale where your platform supports GPU scaling; otherwise set queue limits and alert before saturation.
- Model lifecycle: keep an evaluation set and rerun it before every model or engine upgrade.
- Fallback: decide what happens when the endpoint is down: queue, degrade gracefully or route to an approved alternative.
- Usage governance: track which applications and teams use the model and for what. Our article on rolling out AI coding assistants describes a governance pattern that transfers well.
What will it cost, and what are the main risks?
Cost components
- Compute: GPU instances or hardware, which dominate. Utilisation is the key variable.
- Engineering: platform set-up, gateway, security integration and evaluation harness.
- Operations: monitoring, patching, upgrades and on-call time.
- Data work: preparing documents for retrieval and building evaluation sets.
- Licence and legal review: modest but necessary, repeated for each new model.
Upfront set-up costs more than calling an API. Self-hosting can reduce cost per request at high, steady volume, so model both scenarios with your expected traffic before deciding.
Risks
- Underused GPUs: sized for peak and idle most of the day. Start small and scale with measured demand.
- Quality gap: the chosen open model underperforms on your task. Evaluate before buying hardware.
- Licence surprises: a model upgrade introduces new terms. Review licences as part of change control.
- Skills concentration: one engineer understands the stack. Document runbooks and share on-call.
- Fast-moving ecosystem: better models arrive every few months. Keep application code model-agnostic behind an OpenAI-compatible interface.
A step-by-step plan for your first deployment
- Define the workflow, users, data sensitivity and success criteria.
- Confirm which data cannot leave your environment and choose cloud account, private cloud or on-premises hosting.
- Build an evaluation set of 100 to 300 real, representative examples.
- Shortlist two or three models and review their licences.
- Benchmark on rented GPUs with your serving engine, measuring quality, latency and throughput.
- Size capacity from measured throughput and expected concurrency.
- Build the platform: gateway, identity integration, logging, safety layer and monitoring.
- Run a limited pilot with real users and review samples weekly.
- Write runbooks for incidents, upgrades and capacity changes.
- Schedule quarterly reviews of model choice, utilisation and cost.
PoliteTech’s Private AI Deployment team works through these steps with clients: benchmarking open models such as Llama, Mistral and Qwen on their own tasks, deploying them in their cloud account, private cloud or on-premises with network isolation and encryption, optimising inference with quantisation and batching, and setting up monitoring and an update plan.
Frequently asked questions
Is Llama 3.1 free for commercial use?
For most organisations it can be used commercially under the Llama 3.1 Community License, subject to its conditions: attribution when distributing, naming rules for distributed derivatives, the acceptable use policy and a separate licence requirement for very large platforms above 700 million monthly active users. Have counsel review it for your use.
Can we run a 70B model on a single GPU?
At 16-bit precision, the weights alone need roughly 140 GB, more than a single common data-centre GPU holds. Quantisation to 8-bit or 4-bit reduces this, and multi-GPU tensor parallelism is the usual route. Test quality after quantisation on your own data.
Will a self-hosted open model be as good as the best proprietary models?
On some tasks, close; on others, not yet. The gap depends heavily on the task and language. Benchmark your shortlist against a proprietary reference using your own examples before committing to hardware.
How long does a first deployment take?
It depends on security requirements, integrations and evaluation effort. Benchmarking can be done quickly on rented GPUs; production readiness with identity integration, monitoring and runbooks takes longer. Plan in phases, with a limited pilot before wide rollout.
Do we need Kubernetes?
Not necessarily. A single GPU instance with a container and a gateway is enough for a pilot. Kubernetes helps when you run several models, need autoscaling or already operate it for other services.
Sources and methodology
Guidance reflects PoliteTech delivery experience. The external references below informed specific points in this article.
- Meta AI: Introducing Llama 3.1 (23 July 2024) — accessed 9 November 2026. Llama 3.1 model sizes, 128K context, eight languages, Llama Guard 3 and Prompt Guard, FP8 conversion of the 405B model.
- Meta: Llama 3.1 Community License Agreement — accessed 9 November 2026. 700 million MAU clause, Built with Llama attribution, derivative naming, acceptable use policy and governing law.
- Mistral AI: Mistral NeMo (18 July 2024) — accessed 9 November 2026. 12B size, 128k context, Apache 2.0 licence, quantisation-aware training and tokeniser efficiency.
- Qwen team: Hello Qwen2 (7 June 2024) — accessed 9 November 2026. Qwen2 sizes, context lengths, language coverage and the split between Apache 2.0 and Qianwen License.
- Kwon et al.: Efficient Memory Management for LLM Serving with PagedAttention (SOSP 2023) — accessed 9 November 2026. KV cache memory problem and the reported 2 to 4 times throughput improvement from vLLM.
Related reading
Continue your research
Planning to run Llama, Mistral or Qwen inside your own environment?
We can benchmark candidate models on your tasks, size the infrastructure and deploy a secure, monitored endpoint in your cloud or data centre.
