Punica: High-Throughput Multi-Tenant LoRA Serving for LLMs

Jul 29, 2025

Introduction

Serving multiple fine-tuned Large Language Models (LLMs) typically requires a massive amount of GPU memory, as each model instance often needs its own dedicated copy of the base model. For developers and ML providers, this creates a scaling bottleneck where the cost of serving specialized models for different tenants increases linearly with the number of models. Punica is an open-source framework designed to solve this by allowing the serving of multiple LoRA (Low-Rank Adaptation) models as if they were a single model, significantly reducing GPU overhead. With over 1.1k GitHub stars, Punica introduces a specialized CUDA kernel that enables high-throughput, multi-tenant serving without the typical latency penalties associated with swapping adapters.

What Is Punica?

Punica is a multi-tenant LoRA serving system that enables a single GPU to hold only one copy of a pre-trained base model while concurrently serving multiple, different LoRA adapters. It is written primarily in Python and CUDA, licensed under the Apache License 2.0, and is designed to maximize GPU efficiency in terms of both memory and computation.

The core innovation of Punica is its custom CUDA kernel, which allows for the batching of GPU operations across different LoRA models. This prevents the need to load and unload adapters from memory constantly, allowing the system to handle requests for different adapters in a single batch, which is the primary differentiator from traditional inference servers.

Why Punica Matters

In the current AI landscape, Low-Rank Adaptation (LoRA) has become the gold standard for specializing LLMs for domain-specific tasks. However, the challenge shifted from training these adapters to serving them. Traditionally, if a provider wanted to serve 100 different LoRA adapters, they would either need to merge the adapters into the base model (creating 100 separate base models) or swap adapters in and out of the GPU memory, which introduces significant latency.

Punica fills this gap by treating the LoRA serving problem as a batching problem. By implementing a Segmented Gather Matrix-Vector Multiplication (SGMV) kernel, Punica allows requests for different adapters to be processed in the same GPU operation. This means ML providers can serve hundreds of specialized models for the price of one, drastically lowering the cost per token and increasing the accessibility of specialized AI.

The project has gained significant traction among researchers and developers who need to implement “Just-in-time Fine-tuning” or multi-tenant AI services where each user has their own personalized model.

Key Features

  • SGMV CUDA Kernel: The Segmented Gather Matrix-Vector Multiplication kernel is the heart of Punica, allowing the system to batch GPU operations for different LoRA models in a single pass.
  • Multi-Tenant Architecture: Designed specifically for scenarios where a single GPU cluster serves a large number of distinct LoRA adapters for different users or tasks.
  • High Throughput: According to the project’s benchmarks, Punica can achieve up to 12x higher throughput compared to state-of-the-art LLM serving systems when serving multiple distinct LoRA models.
  • Memory Efficiency: By sharing a single base model across all adapters, Punica eliminates the redundant memory consumption that typically occurs when serving multiple fine-tuned models.
  • Low Latency Overhead: The system is designed to add only a negligible amount of latency (approximately 2ms per token) while providing the benefits of multi-tenancy.
  • Weight Conversion Tools: Punica provides utilities to convert PEFT (Parameter-Efficient Fine-Tuning) weights into the specialized Punica format for optimized serving.

How Punica Compares

Punica is often compared to other multi-LoRA serving frameworks like S-LoRA and the native LoRA support in vLLM. While vLLM has integrated some of Punica’s kernel concepts to improve its own multi-LoRA capabilities, Punica remains a specialized tool for maximizing throughput in highly heterogeneous batches.

Feature Punica vLLM (LoRA) S-LoRA
Primary Goal Max Throughput for Multi-Tenant General Purpose Serving Massive Adapter Scaling
Kernel Design SGMV (Segmented Gather) Integrated Punica Kernels Paged LoRA
Throughput Gain Up to 12x vs SOTA High (Optimized) High (Scalable)
Ease of Setup Moderate Easy Moderate

The primary tradeoff is that while vLLM is a more comprehensive serving stack, Punica provides the specialized kernel and architecture specifically tuned for the most extreme cases of multi-tenant LoRA serving. For developers who are building a specialized AI service where every single request might target a different adapter, Punica’s SGMV kernel provides a significant performance advantage.

Getting Started: Installation

Punica requires a GPU environment with CUDA support. You can install it either via pre-built wheels or by building from source.

Installation via Wheels

Install the necessary dependencies first, then install Punica using the specific wheel for your CUDA version (replace cu121 with your installed CUDA version, e.g., cu118):

pip install ninja torch
pip install punica -i https://punica-ai.github.io/whl/cu121/ --extra-index-url https://pypi.org/simple

Build from Source

If you are using a custom environment or a specific CUDA version not covered by the wheels, you can build Punica from the source code:

pip install ninja numpy torch
git clone https://github.com/punica-ai/punica
cd punica
pip install .

Prerequisites: Ensure you have ninja and torch installed before attempting to build from source, as these are necessary for the CUDA kernel compilation.

How to Use Punica

The basic workflow in Punica involves preparing your LoRA adapters, converting them to the Punica format, and then serving them using the provided kernels.

First, you can use the provided examples to prepare fine-tuning data for common datasets like GSM8K. For instance, to create data for GSM8K, run:

python examples/finetune/create-finetune-data.py --preset gsm8k

Once you have your fine-tuned LoRA weights, you must convert them to the Punica format using the conversion utility. This is necessary for the SGMV kernel to process the weights efficiently:

python -m punica.utils.convert_lora_weight model/gsm8k-r16/adapter_model.bin model/gsm8k-r16.punica.pt

After conversion, the weights can be loaded into the Punica serving system, where multiple converted adapters can be shared across a single base model instance in GPU memory.

Code Examples

Punica’s primary value is in its CUDA kernel, but it provides several examples of how to integrate it into a serving pipeline. The following examples are based on the project’s provided scripts.

Example 1: Fine-tuning a LoRA Model

To start the fine-tuning process for a specific dataset, you can use the provided shell script which handles the training loop and adapter creation:

bash examples/finetune/finetune.sh gsm8k

This script automates the process of training a LoRA adapter on the GSM8K dataset, producing the adapter_model.bin file used in the later conversion step.

Example 2: Weight Conversion for Optimized Serving

Punica requires a specific weight layout for its SGMV kernel. To convert a standard PEFT adapter to a Punica-optimized weight file, use the following command:

python -m punica.utils.convert_lora_weight model/gsm8k-r16/adapter_model.bin model/gsm8k-r16.punica.pt

This converts the binary weights into a PyTorch tensor format that the Punica kernel can gather and multiply efficiently during the inference pass.

Real-World Use Cases

Punica is ideal for any scenario where you need to serve a large number of specialized models without the memory overhead of full model duplication.

  • Personalized AI Assistants: An AI provider can serve thousands of individual user-specific LoRA adapters (each trained on a user’s personal data) using a single base model, making personalized AI economically viable.
  • Domain-Specific Expert Models: A company can deploy a set of expert models for different industries (e.g., legal, medical, medical-coding, financial) using Punica, allowing a single GPU cluster to handle requests for any of these experts simultaneously.
  • Just-in-Time Fine-Tuning: For applications where models are fine-tuned on the fly based on a webpage’s content or a fresh novel, Punica allows these new adapters to be loaded and served immediately without disrupting other users’ requests.
  • Multi-Tenant SaaS Platforms: SaaS platforms that offer fine-tuning as a service can use Punica to consolidate their infrastructure, drastically reducing the cost of serving tenant-specific models.

Contributing to Punica

Punica is an open-source project and welcomes contributions from the community. Since the project involves complex CUDA kernels, contributions typically focus on improving the SGMV kernel performance or expanding support for more base models.

To contribute, you can report bugs via GitHub Issues or submit a Pull Request. If you are a new contributor, look for issues labeled as “good first issue” to get started. The project follows the Apache License 2.0, which allows for both personal and commercial use of the contributions.

Community and Support

The primary hub for Punica is its GitHub repository, where developers can track the latest updates, discuss issues, and report bugs. The project is maintained by researchers from the University of Washington and Duke University, and its core concepts have been integrated into other major serving frameworks like vLLM.

For technical support, the most effective channel is the GitHub Discussions tab or by opening an issue in the repository. Documentation is primarily contained within the README and the associated research paper on arXiv.

Conclusion

Punica is a critical tool for the next phase of LLM deployment. As the industry moves from general-purpose models to highly specialized, tenant-specific AI, the infrastructure for serving these models must evolve. Punica’s SGMV kernel solves the memory and throughput bottleneck that allows us to serve hundreds of specialized models for the price of one.

If you are an ML engineer building a multi-tenant AI service or a provider looking to reduce your GPU costs, Punica is the right choice. While it requires a bit more setup than a general-purpose server, the performance gains in high-heterogeneity scenarios are substantial.

Star the repo, try the quickstart, and join the community to help build the more efficient AI infrastructure of the future.

What is Punica and what problem does it solve?

Punica is a multi-tenant LoRA serving system that allows a single GPU to serve multiple different LoRA adapters using a single copy of the base model. It solves the GPU memory bottleneck where serving multiple fine-tuned models traditionally required duplicating the base model for each adapter.

How do I install Punica?

Punica can be installed via pre-built wheels for specific CUDA versions using pip, or by cloning the repository and running pip install . in the root directory. It requires ninja and torch to be installed as prerequisites.

How does Punica compare to vLLM?

While vLLM is a general-purpose serving framework that has integrated some of Punica’s kernels, Punica is a specialized tool focused specifically on maximizing throughput for multi-tenant LoRA serving. Punica can achieve up to 12x higher throughput in scenarios where requests in a batch are for different adapters.

Can I use Punica for real-time personalized AI?

Punica is designed specifically for this use case. By allowing the efficient batching of requests for different adapters, it makes it economically viable to serve personalized models for thousands of users simultaneously.

What is the SGMV kernel in Punica?

The SGMV (Segmented Gather Matrix-Vector Multiplication) kernel is a custom CUDA kernel that allows the system to batch GPU operations for different LoRA adapters in a single pass, eliminating the need to load/unload weights from memory during a batch.

Is Punica open source?

Yes, Punica is licensed under the Apache License 2.0, allowing for both personal and commercial use.

Does Punica support all LLMs?

Punica is designed for models that use LoRA (Low-Rank Adaptation) fine-tuning. Any LLM that uses the standard Transformer architecture and LoRA adapters can be converted to the Punica format and served using the la-kernel.