Skip to content

fix(server): reconcile alias_to_name on reload (#150)#153

Draft
marksverdhei wants to merge 1 commit into
htfrom
fix/150-alias-reload
Draft

fix(server): reconcile alias_to_name on reload (#150)#153
marksverdhei wants to merge 1 commit into
htfrom
fix/150-alias-reload

Conversation

@marksverdhei

Copy link
Copy Markdown

Fixes #150.

Problem

load_models() reload rebuilds each non-running model's meta.aliases but never reconciled the global alias_to_name map (the pre-loop cleanup at server-models.cpp:595 only drops entries whose target model is gone). Since get_meta() consults alias_to_name before the authoritative meta.aliases scan, an alias removed from or moved off a still-existing model kept resolving to the old model — while has_model() (which skips the map) disagreed. Editing a preset INI to rename/move an alias + POST /models/reload reproduces it.

Fix

After the re-parse loop finalizes a model's meta.aliases, reconcile the map: erase that model's own entries, then register its current aliases. Correct for add/remove/move regardless of the order models are iterated.

Scoping (why not clear-and-rebuild the whole map): #135 (ecf2de428) added alias_to_name specifically so aliases still resolve when a loaded instance's meta.aliases are shadowed/lost, and reload only re-parses non-running models. So the reconcile is scoped to the model being re-parsed — a running instance's entries are left untouched, preserving #135's behavior.

Verification

  • CPU cmake --build --target llama-server (GGML_CUDA=OFF) — server-models.cpp compiles clean, links. CI covers the matrix.
  • Independent of fix(server): reserve per-device VRAM for LOADING models (#66) #148 (that PR touches unload_lru/load/update_status; this touches load_models reload) — different regions, no conflict, mergeable in either order.

Testing note

The bug lives in get_meta()'s alias_to_name fast-path, which is hard to isolate through the black-box HTTP API (the correct meta.aliases scan masks it, and no endpoint echoes get_meta's resolved name). Did not add a non-isolating test rather than a flaky one. A targeted C++ unit test on server_models (move an alias between two presets across a reload, assert get_meta follows) would be the right home if a test seam is added.

Known limitation (pre-existing, not introduced here)

Alias-conflict detection during reload (:624) uses meta.aliases, which can be shadowed for a running model — so a re-parsed model could still claim a running model's alias in that compound edge case. That's the pre-existing weakness #135 works around; this PR doesn't widen or fix it.

load_models() reload rebuilds each non-running model's meta.aliases but never
updated the global alias_to_name map (the pre-loop cleanup only drops entries
whose target model is gone). get_meta() consults alias_to_name before the
authoritative meta.aliases scan, so an alias removed from — or moved off — a
still-existing model kept resolving to the old model (has_model, which skips the
map, disagreed).

After re-parsing a model's aliases, reconcile the map: erase that model's own
entries, then register its current aliases. Scoped to the (non-running) model
being re-parsed, so a running instance's entries — which #135 deliberately keeps
when its meta.aliases are shadowed/lost — are left untouched. Correct for
add/remove/move regardless of iteration order.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Router: reload doesn't reconcile alias_to_name → get_meta mis-resolves removed/moved aliases (stale cache)

1 participant