Fine-Tuning with LoRA
LoRA (Low-Rank Adaptation) lets you serve a base model plus one or more fine-tuned adapters without retraining or rebuilding the full model.
NIM LLM and VLM supports two LoRA serving modes:
- Static LoRA: Adapters are discovered from a directory at startup.
- Dynamic LoRA: Adapters can be loaded and unloaded while the server is running.
The following diagram shows how the NIM container selects a LoRA mode and updates /v1/models:
Prerequisites
Before you configure static LoRA or dynamic LoRA, complete the following prerequisites. These settings tell NIM LLM and VLM where to find adapters and select a LoRA-capable profile.
-
Mount a directory that contains LoRA adapters into the container.
-
Set
NIM_PEFT_SOURCEto that directory. -
Optional: Pass native vLLM LoRA flags. NIM passes the following LoRA-related flags to vLLM:
--enable-lora--max-loras--max-cpu-loras--max-lora-rank
-
Select a LoRA-capable profile ID or name from the
list-model-profilesoutput for your container and GPUs. For example, the PB7 GPT-OSS-120B container publishes the following MXFP4 TP1 LoRA profile:For hardware and profile selection, see the Support Matrix for PB NIMs and Model Profiles and Selection. With the Model-Free NIM, choose a LoRA-capable profile for your compatible text model and provide adapters that match its checkpoint.
Use the following adapter layout under NIM_PEFT_SOURCE:
Only valid, readable adapter directories are loaded.
Configure Static LoRA
NIM LLM and VLM uses static LoRA when NIM_PEFT_REFRESH_INTERVAL is not set. In static LoRA mode, the NIM container discovers adapters in NIM_PEFT_SOURCE during startup and loads valid adapters.
To configure static LoRA, complete the following steps:
- Start the NIM container without setting
NIM_PEFT_REFRESH_INTERVAL. - Query
/v1/modelsto confirm that the response includes the base model and the loaded adapters. - Restart the NIM container after you add, remove, or update adapters.
Configure Dynamic LoRA
Use dynamic LoRA when you need to add or remove adapters without restarting the deployment. You can manage adapters through directory monitoring, runtime API calls, or both.
To configure dynamic LoRA, complete the following steps:
-
Set
NIM_PEFT_REFRESH_INTERVALto the polling interval in seconds. -
Start the NIM container with
NIM_PEFT_SOURCEandNIM_PEFT_REFRESH_INTERVALset.When both variables are set, NIM starts the LoRA watcher and enables runtime LoRA updates for vLLM.
The following diagram shows how the watcher loads and unloads adapters:
-
Optional: Use the vLLM runtime endpoints for manual control:
POST /v1/load_lora_adapterPOST /v1/unload_lora_adapter
Load and Unload Adapters at Runtime
To load and unload adapters at runtime, complete the following steps:
- To load an adapter through the directory watcher, copy a new adapter folder into
NIM_PEFT_SOURCE. - To unload an adapter through the directory watcher, remove the adapter folder from
NIM_PEFT_SOURCE. - Wait one refresh interval for
/v1/modelsto reflect changes. - Optional: Load with
POST /v1/load_lora_adapteror unload withPOST /v1/unload_lora_adapter.
If you use both the watcher and the manual API together, an adapter that the API removes but that is still present in the directory can be reloaded by the watcher during the next scan.
Do not give an adapter directory the same name as the served model (NIM_SERVED_MODEL_NAME). Starting with vLLM 0.31, such an adapter is rejected when it is loaded, because its name would shadow the base model.
Serve Multiple Adapters
You can serve multiple adapters at the same time, subject to GPU memory limits.
To serve multiple adapters, complete the following steps:
- Query
/v1/modelsto discover available adapter IDs. - Send the adapter ID in the request
modelfield.
Serve a GPT-OSS-120B LoRA Adapter
This example uses the PB7 GPT-OSS-120B MXFP4 TP1 LoRA profile on a supported GPU.
-
Complete the credential, cache, and registry setup in the Quickstart. Put the adapter files for GPT-OSS-120B in
loras/my_lora_adapterand set the image and profile: -
Start the model by using one of the following options:
-
Use static LoRA loading.
-
Use dynamic LoRA loading with the watcher enabled.
-
-
Verify that the models loaded.
-
Send an inference request to an adapter.
Next Steps
After adapters are listed in /v1/models, continue with the following topics:
- Model Profiles and Selection for LoRA-capable profiles.
- Environment Variables for
NIM_PEFT_SOURCEandNIM_PEFT_REFRESH_INTERVAL.