Overview
Multi-LoRA support enables:- Dynamic adapter loading: Load adapters on-demand without restarting
- Efficient memory usage: Share the base model across multiple adapters
- Adapter switching: Change adapters between generations
- Reference counting: Automatically manage adapter lifecycle
Use Cases
Multi-Tenant Serving
Serve different fine-tuned models to different users while sharing the base model
Task-Specific Adaptation
Switch between adapters optimized for different tasks (summarization, translation, etc.)
A/B Testing
Test different adapter versions without infrastructure changes
Personalization
Provide personalized model behavior per user or session
Preparing LoRA Adapters
First, create your LoRA adapters using the Model Builder:- Base model weights should be in
path_to_base_model - LoRA adapter weights should be in
path_to_lora_weights - The adapter must be compatible with the base model architecture
Using Multi-LoRA at Runtime
Python Example
Here’s a complete example showing how to use multiple LoRA adapters:C++ Example
C# Example
API Reference
Adapters Class
method
Creates an Adapters manager instance for the given model.Parameters:
model: The base model to manage adapters for
method
Loads a LoRA adapter from disk.Parameters:
adapter_file_path: Path to the adapter weights fileadapter_name: Unique identifier for this adapter
method
Unloads a previously loaded adapter.Parameters:
adapter_name: Name of the adapter to unload
- Error if adapter not found
- Error if adapter is still in use (ref count > 0)
Generator Methods
method
Sets the active LoRA adapter for this generator.Parameters:
adapters: The Adapters manager instanceadapter_name: Name of the adapter to activate
Best Practices
Adapter Lifecycle Management
Adapter Lifecycle Management
- Load adapters at application startup for better performance
- Unload adapters only when they’re no longer needed across all sessions
- The library uses reference counting to prevent unloading adapters that are in use
Naming Convention
Naming Convention
Use descriptive, consistent names for your adapters:
task-based: “summarization”, “translation”, “code-generation”user-based: “user_123”, “tenant_abc”version-based: “summarization_v1”, “summarization_v2”
Memory Considerations
Memory Considerations
- Each adapter adds memory overhead (typically small compared to base model)
- Monitor memory usage when loading many adapters
- Consider lazy-loading adapters on-demand for large deployments
Adapter Compatibility
Adapter Compatibility
- Ensure adapters are created from the same base model
- Use consistent precision (fp16, fp32) across base model and adapters
- Verify adapter architecture matches the base model
Performance Tips
1
Pre-load Common Adapters
Load frequently-used adapters at startup to avoid latency during inference.
2
Reuse Generator Instances
When possible, reuse generator instances and just switch adapters rather than creating new generators.
3
Batch Similar Requests
Group requests that use the same adapter together to minimize adapter switching overhead.
4
Monitor Reference Counts
Keep track of which adapters are in use to optimize when to load/unload them.
Troubleshooting
Next Steps
Model Builder
Learn how to create LoRA adapters
Runtime Options
Configure additional runtime settings
Python API
Explore the Adapters API reference
Examples
View complete examples on GitHub