LocalAI icon indicating copy to clipboard operation
LocalAI copied to clipboard

Model Gallery sizing ("YOUR HOST") ignores registered Distributed Mode nodes

Open AMXELA-Official opened this issue 3 months ago • 5 comments

Description

In Distributed Mode, the Model Gallery's "will this model fit" sizing check (the "YOUR HOST" panel and per-model fit indicators on /app/models) reads from /api/resources, which only reports the frontend's own local resources — not the aggregated/best-fit capacity of registered worker nodes from /api/nodes. This makes the Gallery sizing feature actively misleading (and in our case, useless) for any deployment where the frontend itself is a lightweight/non-compute host and real compute lives on registered distributed nodes.

Setup

  • v4.9.0, Distributed Mode enabled (LOCALAI_DISTRIBUTED=true, NATS + Postgres backing store, two nodes registered via local-ai worker --register-to)
  • Frontend runs on a small LXC container with 2GB RAM and no GPU — intentionally, it's meant to be a thin gateway
  • Two healthy compute nodes registered: one with an NVIDIA GPU (12GB VRAM), one Apple Silicon (16GB unified memory, capability: metal)

Evidence

GET /api/nodes correctly reports both real nodes:

[
  {"name":"AMXELA-Main","status":"healthy","gpu_vendor":"nvidia","total_vram":12884901888,"total_ram":67208949760,...},
  {"name":"MacBookAir.localdomain","status":"healthy","gpu_vendor":"apple","capability":"metal","total_vram":17179869184,"total_ram":17179869184,...}
]

But GET /api/resources (what the Gallery's "YOUR HOST" panel and sizing checks use) only ever reports the frontend's own tiny footprint, oblivious to any registered node:

{"aggregate":{"total_memory":2147483648,"used_memory":176013312,"free_memory":1971470336,"usage_percent":8.2,"gpu_count":0},"gpus":null,"ram":{"total":2147483648,...},"type":"ram",...}

Actual model scheduling/placement (via /api/node/register, NATS backend.install, and LOCALAI_MODEL_SCHEDULING node selectors) correctly uses the real node capacity from /api/nodes — we confirmed models schedule and run correctly on the appropriate node based on real hardware. So the underlying distributed capability-awareness works; it's specifically the Gallery UI's "will this fit" sizing feature that's still wired to the pre-distributed-mode single-host /api/resources data source and was never updated to consider the cluster.

Expected behavior

When Distributed Mode is enabled and nodes are registered, the Gallery's sizing/fit indicators should evaluate against the best-fit registered node's capacity (or an aggregate/max across nodes), not just the frontend host's own resources. As-is, on a thin-gateway deployment, the Gallery reports every model as basically not fitting anywhere, regardless of what real compute is actually available on the cluster.

Also observed (may be a separate/related issue)

The Gallery's model list gets stuck on "Checking availability..." indefinitely once 2 nodes are registered (worked fine, if inaccurately, with a single implicit host). Unconfirmed whether this is a performance issue from checking many gallery models against multiple nodes, or a separate bug — noting it here in case it's related to the same code path.

AMXELA-Official avatar Sep 01 '26 06:09 AMXELA-Official

I'll work on this. Could you assign it to me?

I'll look at the current code, add a focused test, and send a small PR.

modelpath-dev avatar Sep 04 '26 08:09 modelpath-dev

Some context from the code that may save duplicated effort here:

The sizing part is already fixed on master, but not in a release yet. #11765 (merged 2026-08-28, after v4.9.0 was tagged on 2026-08-20) adds a cluster block to /api/resources and to the gallery listing, populated from NodeRegistry.HealthyNodeMemory — the largest model budget any single healthy backend node offers, GPU preferred over RAM — and modelBudget() in the React UI now sizes against that block when present, falling back to the frontend's own aggregate otherwise. The "YOUR HOST" panel keeps showing the controller's genuine usage on purpose; only the fit checks switch to the cluster reading. That should cover the thin-gateway case described here as of the next release, or master builds now.

The "Checking availability..." hang looks like a separate bug and is not addressed by #11765. That text is just one of the rotating phrases in the generic GalleryLoader skeleton, so what it really means is that the initial gallery listing request never resolved once two nodes were registered. I'm going to trace that path on v4.9.0 vs master and post a repro/finding here.

@modelpath-dev — since you asked to take this a few hours ago: happy to leave the sizing follow-ups (if any remain once you've tried master) to you and focus on the hang, or the other way round, whichever you prefer. Just say which so we don't overlap.

Dennisadira avatar Sep 04 '26 11:09 Dennisadira

Follow-up with actual measurements. I built both v4.9.0 (tag) and current master (1f2f931f5) and ran each as a distributed frontend (Postgres 16 + NATS 2 in docker, LOCALAI_AUTH=true, LOCALAI_DISTRIBUTED=true) with two generic local-ai worker --register-to … nodes registered, approved and reporting healthy.

Sizing (the main report) — confirmed on v4.9.0, confirmed fixed on master:

version /api/resources cluster block /api/models cluster block
v4.9.0 absent (only the frontend's own aggregate) absent
master {enabled: true, node_count: 2, node_name: "worker-2", total_memory: 8585740288, is_gpu: true} same

So on master the fit checks size against the best healthy backend node, exactly as #11765 intended. This should land in the next release.

"Checking availability…" hang — could not reproduce on either version. With two healthy nodes registered, the exact requests the Models page issues all return immediately:

request v4.9.0 master
GET /api/models?page=1&collapse_variants=true 200, 0.03 s 200, 0.01 s
GET /api/models?page=1&sort=installed&order=desc&collapse_variants=true 200, 0.03 s 200, 0.02 s
GET /api/models/capabilities 200, 0.01 s 200, 0.01 s
GET /api/models/estimate/<id> 200, 0.7 s 200, 0.9 s

The only slow call I saw was the very first /api/models after a cold start (~3 s), which is the blocking gallery-index download before the cache is warm. That is independent of node count.

Reading the code, the v4.9.0 listing handler makes no per-node calls at all, and that loader text is just one of the rotating phrases in the generic GalleryLoader skeleton, shown until the first /api/models response arrives. So a stuck loader means that one request never completed in your environment. Two things would pin it down:

  1. In the browser devtools Network tab, is /api/models?… shown as pending forever, or did it fail (4xx/5xx/CORS)? A failure would surface as a toast and clear the loader, so I'd expect pending.
  2. Can the frontend LXC reach index.localai.io (and GitHub as the mirror)? On a thin gateway with restricted egress, the initial gallery fetch can block for a long time before the cache exists, and the timing of that is easy to confuse with node registration. LOCALAI_LOG_LEVEL=debug on the frontend around a page load would show it.

If it does turn out to be egress, that's still worth a fix (the listing shouldn't block the UI indefinitely on gallery fetch), but it would be a different bug from the one in the title. Happy to take that one if you can confirm.

Dennisadira avatar Sep 04 '26 12:09 Dennisadira

Following up on the "Checking availability..." hang — checked egress and debug logs (LOCALAI_LOG_LEVEL=debug) on our gateway node just now while reloading the Models page, and couldn't reproduce it this time. /api/models came back with status=200 essentially instantly, and outbound connectivity to the gallery index/GitHub was fast with no timeouts either. Not sure what caused it originally — seems intermittent rather than consistently broken on our end. Will report back with more if it recurs and we can catch it live.

AMXELA-Official avatar Sep 08 '26 14:09 AMXELA-Official

Fixed in v4.10.0 (commit 29899cd1e0, #11765): in distributed mode the gallery fit checks use the largest healthy worker node instead of the frontend. The "Checking availability" hang could not be reproduced; please open a new issue if it comes back.

mudler-agent avatar Dec 01 '26 17:12 mudler-agent