Lyceum Magazine cover: the label Run models without infra work and the title 'Deploy a Hugging Face model inference API: 2026 guide' beside one outlined block wired to three identical smaller blocks, the first purple-topped, suggesting one model copied onto reserved replicas.

Size the GPU for a Hugging Face model before you deploy

GPU memory decides whether a Hugging Face model serves one user or many, so size it first. You have a model ID, a product that needs an endpoint and no spare platform team. So how do you turn that model ID into a production API, and which GPU does it need?

The memory a model needs has two parts. The weights are the trained numbers of the model, and their size is fixed. The KV cache (key-value cache) is the record the model keeps of every token it has read in a request. It grows with every token and every request running at the same time.

At 16-bit precision (FP16 or BF16), every parameter takes 2 bytes. The weights therefore need about 2 GB per billion parameters. Quantization means storing each weight in fewer bits. It halves the weights at 8 bits and quarters them at 4 bits. Check output quality on your own prompts before you rely on a quantized model, as our quantization format comparison explains.

Weights forBF16 (2 bytes)INT8 (1 byte)INT4 (0.5 bytes)
8B parameters16 GB8 GB4 GB
27B parameters54 GB27 GB13.5 GB
70B parameters140 GB70 GB35 GB

A worked example: Qwen3.8 27B on one 80 GB GPU

We use one example through this guide: Qwen3.8 27B at BF16 on one 80 GB GPU, such as an H100. Its weights take 54 GB. The model's published config lists 64 layers. Only 16 of them use full attention, meaning they look back at every earlier token and so store something for each one. Each of those layers keeps 4 KV heads (parallel sets of keys and values) of 256 numbers each, the head dimension. The other 48 layers summarise past tokens in a fixed-size state, a record that does not grow with length. They add no per-token cache, but each request keeps its own copy of that state.

For every token, each full-attention layer stores a key and a value in each KV head. The cache per token is therefore a product of five numbers:

KV bytes per token = 2      (one key + one value)
                   x 16     (full-attention layers)
                   x 4      (KV heads per layer)
                   x 256    (numbers per head)
                   x 2      (bytes per number at BF16)
                   = 65,536 bytes = 64 KiB

One full-length request = 64 KiB x 262,144 tokens = 16 GiB

Fixed state per request = 48 layers x 48 heads x 128 x 128 x 2 bytes
                        = 75.5 MB = about 0.07 GiB

At the model's full context of 262,144 tokens, one request therefore holds 16 GiB of cache, as the last line shows. GiB counts in powers of two (1 GiB is about 1.07 GB), which is how memory tools report the cache. The cache sizes are our calculation from the config, not a measurement. Our KV cache memory calculation guide covers other architectures.

Serve the model with vLLM and fit the KV cache

vLLM is the engine to serve the model with, because it packs the KV cache of many requests into GPU memory without gaps. A plain pipeline in Transformers, Hugging Face's Python library for running models, reserves one block of memory per request. Requests finish at different times and leave holes too small for the next long request, so new requests wait while memory sits free.

vLLM splits the cache into fixed-size pages and hands freed pages back to a shared pool. Its authors call the method PagedAttention. Kwon et al. compared it with FasterTransformer and Orca, two earlier serving systems. At the same latency, they report 2 to 4 times the throughput (requests served per second). Anyscale measured up to 23 times the throughput of static batching in June 2023. Static batching waits until every request in a batch has finished before it starts the next batch.

Four vLLM settings decide how many requests fit

Four engine arguments decide how much cache vLLM can hold and how it is shared:

  • `--gpu-memory-utilization`: the share of GPU memory vLLM may use, 0.92 by default.
  • `--max-model-len`: the longest context, prompt plus output, that one request may use.
  • `--max-num-seqs`: how many requests run together in one step (one pass that adds a token to each of them).
  • `--kv-cache-dtype fp8`: stores the cache in FP8, an 8-bit number format, so 1 byte per value instead of 2.

In the example, vLLM may use 0.92 x 80 GB = 73.6 GB. After 54 GB of weights, about 19.6 GB is left for the cache, which is 18.25 GiB. That fits one request at the full 262,144-token context. Capped at 32,768 tokens, each request needs at most 2 GiB of KV cache. Each request also carries the fixed 0.07 GiB state from the 48 Gated DeltaNet layers, the fixed-state layers above. So a 32,768-token cap fits 8 requests in BF16 (18.25 GiB / 2.07 GiB, rounded down). An FP8 cache halves the KV part to 1 GiB, so 17 requests fit (18.25 GiB / 1.07 GiB).

Calculated example, horizontal bar chart of how many requests run at full length in the KV cache of Qwen3.8 27B on one 80 GB GPU, after 54 GB of BF16 weights and vLLM's 0.92 memory share. Each request also holds a fixed 0.07 GiB state. Full 262,144-token context with a BF16 cache: 1 request. Capped at 32,768 tokens with a BF16 cache: 8 requests, highlighted. Capped at 32,768 tokens with an FP8 cache: 17 requests. Activation memory is not included, so real counts are lower.
Our calculation for Qwen3.8 27B on one 80 GB GPU: capping each request at 32,768 tokens lets 8 run at full length instead of one, before activation memory.

The count of 8 errs in two directions. It assumes every request uses its full 32,768 tokens, and shorter real requests leave room for more. It also leaves out activation memory, the working space the GPU needs while it computes each step, which leaves room for fewer. Run a load test with your own prompts before you set `--max-num-seqs`. Still out of memory? Our guide to vLLM out-of-memory errors walks through the fixes.

Expose and secure an OpenAI-compatible inference API

vLLM serves the model through an OpenAI-compatible API, so your application changes only the base URL, the API key and the model name. The server starts on `http://localhost:8000` by default. Its Chat Completions endpoint serves models that ship a chat template, the prompt format the model was trained on.

Start it with an API key, and the server checks every request for one. You can pass several keys at once, which lets you rotate them without downtime. The example below starts the worked example with the 32,768-token cap. It sets `--max-num-seqs` to 7, one below the calculated 8, to leave room for activation memory:

vllm serve Qwen/Qwen3.8-27B \
  --max-model-len 32768 \
  --max-num-seqs 7 \
  --gpu-memory-utilization 0.92 \
  --api-key "$VLLM_API_KEY"

Give each service its own key, so you can revoke one without touching the others. Then restrict who can reach the port. Hugging Face's own Inference Endpoints offer three access levels: private (the default), authenticated with any Hugging Face token, and public with no authentication. On AWS, they can also sit behind AWS PrivateLink, a private connection from your own network.

Deploy a Hugging Face model on our dedicated endpoints

A replica is an identical copy of the model, serving requests on its own GPUs. Our dedicated endpoints run a Hugging Face model ID on reserved replicas behind one OpenAI-compatible endpoint. We then run the vLLM server setup above for you. We are Lyceum, a sovereign European AI inference provider for open-source models, and our GPUs run in European data centres. We don't keep your prompts or outputs, and we never use them for training.

One CLI call deploys the worked example:

lyceum infer deploy Qwen/Qwen3.8-27B \
  -g gpu.h100 \
  --min-replicas 1 \
  --max-replicas 3 \
  --wait

The replica count scales between the minimum and maximum on two targets. One is requests per second per replica, 10 by default. The other is p95 latency, the time 95% of requests finish within, 5,000 ms by default. A 300-second stabilisation window stops it from scaling down and up in quick succession. You are billed for the time replicas run, not per request. A deployment with no requests for one hour scales to zero and stops billing. The next request resumes it, and that first answer is slower while the replicas start.

Flow diagram of a dedicated deployment on Lyceum. Your app, an OpenAI client with your API key, sends a request with the model set to the deployment ID to our endpoint, one per deployment and load-balanced. The endpoint passes it to the replicas, one to three copies of the model that autoscale, and the answer returns in the OpenAI format. Highlighted: after one hour without requests the deployment is paused at zero replicas, billing stops, and the next request resumes it with a slower first answer.
On our dedicated endpoints, one OpenAI-compatible endpoint sits in front of the replicas, which pause after an hour without requests.

Your application then calls the deployment with any OpenAI client. The model field is the `deployment_id` the deploy call returns:

from openai import OpenAI

client = OpenAI(
    api_key="lk_...",
    base_url="https://api.lyceum.technology/api/v2/external",
)

resp = client.chat.completions.create(
    model="<deployment_id>",
    messages=[{"role": "user", "content": "Summarise this ticket in two lines."}],
)
print(resp.choices[0].message.content)

Choose dedicated or serverless inference by traffic shape

Choose a dedicated endpoint for steady traffic and per-token serverless inference for traffic that comes and goes. Reserved GPUs cost the same per hour whether they are busy or idle. The more requests they serve, the less each token costs. Per-token billing follows your traffic instead, so quiet hours cost nothing.

Your trafficBetter fitWhy
Steady all day, predictable latency neededDedicated endpointModel stays loaded; replica time is spread over many tokens
Bursts with long quiet gapsServerless inferenceNo charge between requests; no GPUs to size
A model not in our catalogueDedicated endpointAny Hugging Face model ID can be deployed

Check our catalogue before you deploy anything. Qwen3.8 27B already runs on our serverless inference. On 21 October 2026, our models page listed it at $0.40 input and $2.40 output per 1M tokens. You call it at `https://api.lyceum.technology/openai/v1`, with no base fee. Current latency and incidents are on our status page. Our serverless vs dedicated break-even guide works through when the switch pays off.

Add domain knowledge with a LoRA adapter or RAG

Train a LoRA adapter when the model must change how it answers. The adapter is a small set of extra weights, trained while the model's own weights stay frozen (unchanged). Use RAG (retrieval-augmented generation) when answers must come from documents that change. LoRA stands for low-rank adaptation. Hu et al. compared it with full fine-tuning of GPT-3 175B. They report 10,000 times fewer trainable parameters and a third of the GPU memory. A vLLM server can serve adapters per request with `--enable-lora` and `--lora-modules`, each under its own model name.

RAG leaves the weights alone. It finds relevant passages in your documents and adds them to the prompt at request time. Lewis et al. described the approach in 2020. The passages come from an index, a searchable store of your document chunks. When a document changes, you update the index instead of retraining. Our RAG pipeline infrastructure guide covers the GPU side.

Our fine-tuning is in early access. You upload a few hundred examples and pick GLM-5.3 Flash or Qwen3.8 27B as the base. We train the adapter and serve it behind the same API, and the adapter is yours to download.

Summary: how we help you deploy a Hugging Face model

Deploying a Hugging Face model comes down to three decisions. First, size the GPU for the weights plus the KV cache of every running request. Second, serve the model with vLLM behind an API key, and cap the context length before you pay for a bigger GPU. Third, match billing to your traffic: reserved replicas for steady load, per-token serverless inference for bursts.

Here is where we take that work off your hands:

  • Dedicated endpoints: one CLI call runs any Hugging Face model ID on reserved replicas, with the vLLM setup and autoscaling done for you.
  • Serverless inference: models already in our catalogue, such as Qwen3.8 27B, are billed per token with no base fee.
  • Fine-tuning in early access: we train a LoRA adapter on your examples and serve it behind the same API.
  • European by default: our GPUs run in European data centres, and prompts and outputs are not stored or used for training.

Start with the memory. Enter your model, context length and number of concurrent requests in our model sizing tool. If it fits your traffic, deploy it with the steps in our dedicated inference docs.

Sources

  1. Qwen, Qwen3.8-27B config.json on Hugging Face, read 14 October 2026
  2. Kwon et al., Efficient Memory Management for Large Language Model Serving with PagedAttention, arXiv:2309.06180, 12 September 2023
  3. Anyscale, How continuous batching enables 23x throughput in LLM inference while reducing p50 latency, 22 June 2023
  4. vLLM Documentation, Engine Arguments, read 14 October 2026
  5. docs.vllm.ai
  6. vLLM Documentation, Online Serving (OpenAI-compatible server), read 3 August 2026
  7. Hugging Face Inference Endpoints, Configuration (Authentication and Network), read 3 August 2026
  8. Hugging Face Inference Endpoints, Security and Compliance, read 3 August 2026
  9. Hu et al., LoRA: Low-Rank Adaptation of Large Language Models, arXiv:2106.09685, 2021
  10. vLLM Documentation, LoRA Adapters, read 14 October 2026
  11. Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, arXiv:2005.11401, 2020