█

AI/TLDR

Buy me a coffee
Buy me a coffee

LoRAX

Serve thousands of LoRA adapters over one base model on a single GPU

Serving & DeploymentOpen source
Language
Python
License
Apache-2.0
IN SHORT

What is LoRAX?

LoRAX — LoRA eXchange — is an inference server built around a simple observation: a fleet of fine-tuned models usually shares one base model and differs only in its LoRA adapters. It sits in the Serving & Deployment category of the Models & Inference tools and is open-source, written in Python and licensed Apache-2.0.

Overview

LoRAX — LoRA eXchange — is an inference server built around a simple observation: a fleet of fine-tuned models usually shares one base model and differs only in its LoRA adapters. Instead of standing up a GPU per fine-tune, LoRAX keeps the base model resident and swaps adapters per request, which the project frames as serving thousands of fine-tuned models on a single GPU without giving up throughput or latency.

Three mechanisms make that work. Dynamic adapter loading pulls any LoRA adapter from the Hugging Face Hub, Predibase or a local filesystem at request time, just-in-time and without blocking concurrent requests, and adapters can be merged per request to build ensembles on the fly. Heterogeneous continuous batching packs requests for different adapters into the same batch, so latency and throughput stay close to flat as the number of concurrent adapters grows. Adapter exchange scheduling prefetches and offloads adapters between GPU and CPU memory asynchronously, and schedules batching to maximise aggregate throughput.

Underneath it is a conventional optimised serving stack: tensor parallelism, pre-compiled CUDA kernels for flash attention, paged attention and SGMV, quantization and token streaming. Base models can be loaded in fp16 or quantized with bitsandbytes, GPT-Q or AWQ, and supported architectures include Llama (with CodeLlama), Mistral (with Zephyr) and Qwen. Adapters trained with PEFT or Ludwig are supported, and any linear layer in the model can be adapted.

It is packaged for production rather than notebooks: prebuilt Docker images, Helm charts for Kubernetes, Prometheus metrics, distributed tracing through OpenTelemetry, an OpenAI-compatible API with multi-turn chat, per-request tenant isolation for private adapters, and structured JSON output. The licence is Apache 2.0, which the README notes explicitly makes it free for commercial use.

What it does

  • Dynamic adapter loading from the Hugging Face Hub, Predibase or any filesystem, just-in-time and non-blocking
  • Heterogeneous continuous batching — requests for different adapters packed into one batch
  • Adapter exchange scheduling that prefetches and offloads adapters between GPU and CPU memory
  • Per-request adapter merging to build ensembles without a separate deployment
  • Optimised inference: tensor parallelism, flash attention, paged attention, SGMV kernels, quantization, token streaming
  • fp16 or bitsandbytes / GPT-Q / AWQ quantized base models; PEFT and Ludwig adapters on any linear layer
  • Production packaging: Docker images, Helm charts, Prometheus metrics, OpenTelemetry tracing, tenant isolation, JSON mode
  • OpenAI-compatible API alongside its own REST and Python clients

Getting started

The recommended path is the prebuilt Docker image, which avoids compiling the custom CUDA kernels. Minimum requirements are an Ampere-or-newer NVIDIA GPU, CUDA 11.8+ drivers, Linux and Docker with the NVIDIA container toolkit installed.

Launch the server

Point the image at a base model and mount a volume for the weights cache.

bashbash
model=mistralai/Mistral-7B-Instruct-v0.1
volume=$PWD/data

docker run --gpus all --shm-size 1g -p 8080:80 -v $volume:/data \
    ghcr.io/predibase/lorax:main --model-id $model

Prompt the base model over REST

The /generate endpoint takes the prompt and generation parameters.

bashbash
curl 127.0.0.1:8080/generate \
    -X POST \
    -d '{"inputs": "[INST] Your prompt here [/INST]", "parameters": {"max_new_tokens": 64}}' \
    -H 'Content-Type: application/json'

Prompt a LoRA adapter

The same request with an adapter_id loads that adapter just-in-time and serves the request against it.

bashbash
curl 127.0.0.1:8080/generate \
    -X POST \
    -d '{"inputs": "[INST] Your prompt here [/INST]", "parameters": {"max_new_tokens": 64, "adapter_id": "vineetsharma/qlora-adapter-Mistral-7B-Instruct-v0.1-gsm8k"}}' \
    -H 'Content-Type: application/json'

Use the Python client

The client mirrors the REST API, with adapter_id as a per-call argument.

bashbash
pip install lorax-client

Call it from Python

Point the client at the server and pass adapter_id to route a call to a specific fine-tune.

pythonpython
from lorax import Client

client = Client("http://127.0.0.1:8080")
prompt = "[INST] Your prompt here [/INST]"

print(client.generate(prompt, max_new_tokens=64).generated_text)

adapter_id = "vineetsharma/qlora-adapter-Mistral-7B-Instruct-v0.1-gsm8k"
print(client.generate(prompt, max_new_tokens=64, adapter_id=adapter_id).generated_text)

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Reach for it when you have many per-customer or per-task fine-tunes of one base model and a GPU each is unaffordable
  • Reach for it to A/B several adapters in production without redeploying a server for each
  • Reach for it when adapters need to be private per tenant but share the same serving fleet
  • Reach for it to merge adapters per request and test ensembles before committing to a merged checkpoint

How LoRAX compares

LoRAX alongside other open-source serving & deployment tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
Transformers★ 169kHugging Face Transformers is a Python framework that defines and runs state-of-the-art pretrained models for text, vision, audio, and multimodal tasks, for both inference and training.
vLLM★ 97.9kA high-throughput LLM serving engine that uses PagedAttention and continuous batching to serve many requests at once.
SGLang★ 39.2kA serving framework for LLMs and multimodal models that boosts throughput by reusing shared prompt prefixes across requests.
Modular Platform★ 30.2kModular's AI platform: the MAX inference framework with an OpenAI-compatible serving endpoint and GPU kernel library, plus the Mojo language and compiler.
DeepInfer★ 26.5kDeepSeek's own large-scale inference framework for its models, with expert parallelism, confidence-scheduled speculative decoding and NVIDIA plus Ascend support.
TensorRT-LLM★ 15.2kNVIDIA's library that compiles LLMs into optimized engines for the fastest inference on its data-center GPUs.
OpenVINO★ 13.3kAn open-source toolkit from Intel that converts and optimizes deep learning models, then runs fast inference on CPU, GPU, and NPU hardware.
LoRAX★ 3.8kServe thousands of LoRA adapters over one base model on a single GPU