lora: an unload of an adapter in use drains it instead of answering 409

POST /v1/unload_lora_adapter for an adapter requests still hold marks it draining and answers
202 {"action": "draining", "lora_name", "in_flight": N}: from then on a request naming it gets the
404 an unknown model gets and /v1/models leaves it out, the N requests finish normally, and the
last hold to go frees the slot, which then cools for three step-loop rounds like any freed slot.
An idle adapter still unloads at once with 200; a second unload while it drains answers 202 with
the count as it is then, and 404 once it is gone; a load of the same name while it drains answers
409 (is being unloaded).

The slots' bookkeeping moves out of Engine into lora::SlotTable (core/lora/slots.h): reserve,
publish, acquire with its hold, unload, names. It has its own lock, so a request's hold and an
unload no longer wait behind a load's device copy; Engine::lora_mu_ now only serialises loads,
which is what keeps a reserved slot from being handed out twice. lora_test drives the table
through both paths, and server_test drives the routes over a real table with a streamed request
held open: 200 idle, 202 draining twice, 404 for a new request and on /v1/models/:id, 409 for a
load while draining, the slot freed when the stream ends, 503 while it cools, 200 after.
This commit is contained in:
baKon committed 2026-10-16 20:52:09 -05:00
1 parent 582cda0a53
commit 91127395ee
10 files changed
+495 -93

No files matched your search

+9 -1
View File
@@ -1145,7 +1145,15 @@ all-reduce, so it works at any `--tp`.
A and B for every targeted weight; startup prints the size. With free slots, adapters load and
unload while serving: `POST /v1/load_lora_adapter {"lora_name": "x", "lora_path": "/dir"}` and
`POST /v1/unload_lora_adapter {"lora_name": "x"}` (vLLM's routes; loopback-only without
`--api-key`). An unload is refused (409) while a request uses the adapter.
`--api-key`).
- An unload of an idle adapter answers 200 and frees its slot. An unload of an adapter requests
are still using **drains** it and answers 202
`{"action": "draining", "lora_name": "x", "in_flight": N}`: from then on a request naming `x`
gets the 404 an unknown model gets and `/v1/models` no longer lists it, the N requests finish
normally, and the last of them frees the slot. Asking again while it drains answers 202 with the
count as it is then, and 404 once it is gone. Loading the same name while it drains answers 409;
load it again once the unload answers 404. A freed slot is reused a few steps later (a step
already on the card may still read it), which a load waits for by itself.
- `--max-lora-rank R` (default 16) is the rank every slot is sized for. A smaller rank is padded,
a larger one refused.
- `--lora-target-modules q_proj,k_proj,...` names what adapters may target. Default: what the