perf(server): keep CUDA graph replay when LoRA adapters are loaded

Open
#840 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python, pytorch

Research direction

Start at packages/sie_server/src/sie_server/adapters/modernbert_flash/__init__.py and the guard if self._graphs is None or self._peft_model is not None: return None; compare the base and adapter request paths with the graph-capture code cited in #423/#721. Read draft #829 for the runtime-LoRA direction and #647 for Qwen3 batching. Done means base and adapted requests replay graphs on ModernBERT/ColBERT and GLiNER2.5-Decide, parity stays within 0.02 of eager, L4 p50 is reported, and adapter eviction frees recordings within the existing memory budget.

Written by the indexing model from the issue text.

Description

Problem

Loading a LoRA adapter takes a model off CUDA graph replay, and on short encoder calls the eager path is several times slower.

  • On main, the ModernBERT and ColBERT flash adapters run every request eagerly once any PEFT LoRA is loaded, base-model requests included (packages/sie_server/src/sie_server/adapters/modernbert_flash/__init__.py: if self._graphs is None or self._peft_model is not None: return None). For gte-modernbert-base on an L4, graphs are worth 17.5 → 2.4 ms per query (#423).
  • Draft #829 (runtime LoRA for GLiNER2.5-Decide, Laya, pplx-decider and GLiClass) keeps graphs for base requests, but adapted requests run eagerly. Eager Decide on an L4 is 46.8 ms p50 against 8.4 ms with graphs (#721), so a tuned Decide would be about 5x slower than the base it was tuned from.
  • Qwen3-Embedding-4B gives up its four batches in flight when LoRA is configured (#647).

Goal

Requests that select a LoRA adapter replay recorded graphs as base requests do, under the same numerics rule as the other graph work: no probability moves more than 0.02 against eager, or the result is no worse against float32.

Possible approaches

  1. Static adapter buffers. Capture graphs with the LoRA A/B matrices read from fixed buffers. Before replay, copy the selected adapter's weights into those buffers, so adapters swap without a recapture. Needs one graph set per rank and target-module layout.
  2. Per-adapter recordings for hot adapters. Record a graph set per (adapter, bucket) inside the existing graph memory budget, and evict a recording together with its adapter in the LoRA LRU.
  3. Merge at staging. Merge a hot adapter into a copy of the base weights and record graphs for that copy. Simplest numerically, but it costs memory per adapter.

Whichever approach is chosen, base-model graphs must stay unaffected when adapters are loaded.

Acceptance

  • Base requests keep graph replay while any adapter is loaded, starting with the ModernBERT and ColBERT flash adapters.
  • Adapted requests replay graphs on GLiNER2.5-Decide and at least one ModernBERT model. Report parity numbers and L4 p50 before and after.
  • Graph memory stays within the existing budget, and evicting an adapter frees its recordings.
Dominant language
Python
Stars
3.5k
Forks
328
Avg merge
17h 8m
Merged PRs (30d)
108

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from superlinked/sie

All issues in superlinked/sie

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.