OpenNMT / OpenNMT/CTranslate2

Add runtime LoRA adapter swapping

Open
#2,045 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
4.7k
Forks
536
Avg merge
12h 12m
Merged PRs (30d)
4

Description

Hi,
I've built a working patch for runtime LoRA swapping and want to confirm it's within scope before opening a PR.

What it does: writes W ← W + scale × (B @ A) in-place on an existing StorageView buffer. This allows swapping LoRA adapters at runtime without reloading the model.

Motivation: serving N language-specific adapters on a single base model. Measured on L4 GPU (Whisper-large-v3 float16): cross-adapter swap ~54 ms vs ~1,520 ms for full model reload.

Patch size: 142 lines across 3 files. No existing API changed.

Questions:

Is this within scope for CTranslate2?
Should it be guarded by an experimental build flag?
Where should the Python binding live — currently on WhisperWrapper, but we've verified it works on OmniASR (Encoder/Generator) with the same pattern. Should it be on the base Model instead?
Happy to open a PR if the direction looks good.

Related: #2046

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the proposed 3-file patch and related issue #2046, then trace the existing StorageView and Python binding entry points. Confirm the intended scope, experimental build-flag behavior, and whether the binding belongs on WhisperWrapper, the Encoder/Generator, or the base Model. Done means the API placement and scope are agreed and runtime swapping is validated for the mentioned model paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
machine-learning, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.