Skip to main content
SGLang enables efficient serving of LoRA adapters with a base model. Using techniques from S-LoRA and Punica, SGLang can serve multiple LoRA adapters for different sequences within a single batch.

Quick Start

Basic LoRA Serving

Launch a server with a single LoRA adapter:
Make a request using the adapter:

Multiple Adapters

Serve multiple LoRA adapters simultaneously:
Batch requests with different adapters:

Configuration Parameters

Server Arguments

LoRA Path Formats

You can specify adapters in multiple formats:

Dynamic Adapter Management

Load and unload adapters at runtime without restarting the server.

Initial Server Setup

When using dynamic loading, explicitly specify --max-lora-rank and --lora-target-modules to ensure compatibility with all adapters you plan to load.

Load Adapter

Unload Adapter

OpenAI-Compatible API

Use LoRA adapters through the OpenAI-compatible API by specifying the adapter name with a colon separator:

Advanced Features

GPU Pinning

Pin frequently-used adapters to GPU memory to avoid repeated loading:
Pinned adapters occupy GPU memory slots permanently until unloaded. SGLang limits pinned adapters to max-loras-per-batch - 1 to prevent starvation.

Backend Selection

SGLang supports two LoRA backends:

ChunkedSGMV (csgmv)

Default and recommended. Optimized for high concurrency with 20-80% latency improvements.

Triton

Basic Triton-based implementation. Use for compatibility if needed.

Overlap Loading

Overlap LoRA weight loading with GPU computation to hide data movement latency:
Enable when:
  • High adapter churn (frequently switching adapters)
  • Large adapter weights (high rank)
  • PCIe-bottlenecked workloads
Benchmarks show ~35% reduction in median TTFT under adversarial conditions.
Pros:
  • Reduces adapter load time impact
  • Hides H2D transfer latency
Cons:
  • Requires pinned CPU memory (limits max-loaded-loras to 2× max-loras-per-batch)
  • Reduces multi-adapter prefill batching (may increase TTFT when load time << prefill time)

Implementation Architecture

SGLang’s LoRA implementation consists of several key components:

LoRAManager

The LoRAManager class coordinates adapter lifecycle:
Source: python/sglang/srt/lora/lora_manager.py:50

Memory Pool

The memory pool manages GPU memory allocation for adapter weights, implementing eviction policies (LRU or FIFO) when the pool is full.

Adapter Format

Adapters must follow the PEFT format with:
  • adapter_config.json - Configuration (rank, target modules, alpha)
  • Weight files - Adapter matrices (A and B)
  • Optional added_tokens.json - Additional vocabulary tokens
Source: python/sglang/srt/lora/lora_config.py:22

Tensor Parallelism

LoRA serving supports tensor parallelism for large models:
S-LoRA’s tensor sharding strategy partitions adapter matrices across GPUs to balance computation.

Performance Best Practices

Set based on your concurrency needs. Higher values support more concurrent adapters but increase memory usage.
Pin adapters that are accessed in >50% of requests to avoid repeated loading.
The csgmv backend provides 20-80% better latency than triton at high concurrency.
Use lru (default) for workloads with temporal locality. Use fifo for uniform access patterns.
If adapter loading is a bottleneck, enable --enable-lora-overlap-loading.

Limitations

  • Adding tokens to vocabulary is not currently supported
  • All adapters must have compatible ranks ≤ max-lora-rank
  • Target modules must be subset of lora-target-modules

Future Development

Upcoming features tracked in GitHub Issue #2929:
  • Embedding layer LoRA
  • Unified paging for adapters
  • CUTLASS backend for improved performance
  • Expanded target module support