Skip to content

fix(worker): match a process by its advertised address - #13422

Merged
mudler merged 1 commit into
mudler:masterfrom
CodeByZach:fix/worker-match-advertised-address
Nov 23, 2026
Merged

mudler merged 1 commit into
mudler:masterfrom
CodeByZach:fix/worker-match-advertised-address

Conversation

@CodeByZach

Copy link
Copy Markdown
Contributor

Description

In distributed mode, model.unload frees nothing on a worker that runs on another machine than the frontend. The worker records each backend process under its listen address (127.0.0.1:<port>), but its backend.install reply gives the frontend the advertised address (the worker's advertised host with the same port). The frontend stores that and sends it back in model.unload, and the worker compared the two literally:

model.unload target has no process in this worker; nothing to free model="..." addr="<advertised host>:50051"

while the process was running at 127.0.0.1:50051. The model.stop address check (stopModelExact) compared the same way.

This PR derives the advertised address in one helper, advertisedBackendAddr, used by the install reply and by a matcher that accepts either form for the same process. A different host with the same port still does not match. model.unload now dials the matched process's own address for Free().

Notes for Reviewers

  • model.unload is what router eviction and reconciler scale-down send, so on such workers they removed the registry row but left the model in VRAM, and the next load ran out of memory (seen while testing Distributed mode: a model is loaded on a node without room instead of evicting there #13366). The node unload endpoint was not affected, because it also sends backend.stop by name.
  • Checked on a worker with an NVIDIA card on another host: before, the log line above and the model stayed loaded; with this change, model.unload stops the right process and the next model loads in its place.
  • New specs: unload and stop by the advertised address, by the listen address, and no match for the same port on another host. Each key spec fails without its change. Tests and golangci-lint pass.

Signed commits

  • Yes, I signed my commits.
  • Documentation updated (docs/content/) for user-facing changes, or not applicable

The worker records each backend process under its listen address
(127.0.0.1:<port>), but its backend.install reply gives the frontend the
advertised address (the worker's advertised host with the same port),
and the frontend stores that and sends it back. model.unload and the
model.stop address check compared the two literally, so whenever the
advertised host is not the loopback address -- a worker on another
machine -- model.unload logged "target has no process in this worker"
and freed nothing, and model.stop reported an address mismatch.

Derive the advertised address in one helper, used by the install reply
and by a matcher that accepts either form for the same process. A
different host with the same port still does not match. model.unload
now dials the matched process's own address for Free().

Assisted-by: Claude:claude-opus-5-5 [golangci-lint]
Signed-off-by: Zachary Miller <20159826+CodeByZach@users.noreply.github.com>

@mudler mudler left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mudler
mudler merged commit a7caa76 into mudler:master Nov 23, 2026
1 check passed
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.

2 participants