Skip to content

fix(npu): stop reporting no NPU on Linux APUs with a large GPU carve-out - #6736

Merged
kovtcharov-amd merged 1 commit into
mainfrom
kalin/linux-npu-carve-out
Nov 5, 2026
Merged

kovtcharov-amd merged 1 commit into
mainfrom
kalin/linux-npu-carve-out

Conversation

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

On Linux, a Ryzen AI Max PC with a large GPU memory carve-out was told it has no NPU. gaia init --profile npu stopped with "Lemonade reports no available AMD NPU", and setup hid the NPU models. A 128 GB Strix Halo set to 64 GB of VRAM is a common setup for local LLMs and hits this. It also fails the release gate's Linux NPU chat job on every RC since rc10 (runs 42022209446, 41973946000, both on runner sjlab-stx-halo-19). With this fix, such a PC gets its NPU offered and sized correctly.

This PR alone won't turn that job green. Runner sjlab-stx-halo-19's locked-memory limit is 7.8 GB and the NPU model needs about 10.6 GB, so the job will next fail on GAIA's own "locked-memory limit" message. That's the accurate error, and the fix is on the runner.

🔍 Technical details
  • Lemonade's Physical Memory is installed DIMM capacity on Windows (WMI Win32_PhysicalMemory) but /proc/meminfo MemTotal on Linux, which already excludes the carve-out. _npu_memory_gb subtracted the carve-out on both, so on halo-19 it computed 62.4 − 64 → 0 → None → "no NPU". Lemonade itself logged NPU hardware: Yes.
  • The carve-out now comes off only when OS Version starts with Windows. The Go mirror (tui/internal/lemonade/capacity.go) gets the same rule, so the TUI picker agrees.
  • The old STRIX_HALO_128 fixture claimed to be a Linux report but carried 128 GB of Physical Memory, which a Linux Lemonade never sends. That is the wrong assumption behind the bug, so it now carries MemTotal.
  • Introduced with the NPU profile in feat(npu): offer GAIA's Gemma on the Ryzen AI NPU, GPU stays default #5892.

Test plan

  • python -m pytest tests/unit/test_flm_models.py tests/unit/test_npu_twin_models.py passes. The four new Linux cases fail on main with the CI job's exact "no available AMD NPU" error.
  • cd tui && go test ./internal/lemonade/ passes.
  • After the runner's memlock is set to unlimited, dispatch test_npu_agent_chat.yml and confirm the Linux job gets past "Downloading models".

On Linux, `gaia init --profile npu` told a Strix Halo with a 64 GB GPU
carve-out that it had no NPU, and setup hid the NPU models there. Lemonade's
Physical Memory is installed RAM on Windows but MemTotal on Linux, which
already excludes the carve-out; GAIA subtracted the carve-out on both, so a
carve-out as large as the RAM Linux sees left zero memory for the NPU.

The carve-out now comes off only for a Windows report, in both the Python
capacity reader and the TUI's Go mirror.
@kovtcharov-amd kovtcharov-amd added this to the v0.25.4 milestone Nov 5, 2026
@github-actions github-actions Bot added llm LLM backend changes tests Test changes performance Performance-critical changes tui Go terminal UI (gaia-tui) labels Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

On Linux, a Ryzen AI Max PC with a large GPU memory carve-out was wrongly told it had no NPU. This PR fixes that. GAIA was subtracting the carve-out from a memory figure that Linux has already taken it out of. Now it subtracts only on Windows, where Lemonade reports installed RAM. The Python setup path and the TUI's copy of the rule are changed together and agree, and the tests now use the memory figure a real Linux Lemonade reports. Nothing blocks the merge.

One small hardening point: if Lemonade ever leaves out the OS name, GAIA quietly assumes Linux. On a Windows PC that would overstate the memory the NPU has.

Real-world evidence

The evidence stage ran the real Agent UI backend twice against a stubbed Lemonade that answers like a Linux Strix Halo (62.4 GB of system memory, 64 GB carve-out, NPU available): once on this PR and once on its parent.

Settings › Model context range for the NPU model (GET /api/providers/local/context?model=gemma4-it-e4b-FLM):

Before (fa200b069): "automatic":65536, ... "memory_source":"NPU, system RAM"
After  (32ae53dc3): "automatic":131072, ... "memory_source":"NPU, system RAM"

Setup path (recommend_npu_chat_model, which gaia init --profile npu calls). The Linux driver check was stubbed out because this runner has no amdxdna driver:

Before: has_npu: False npu_memory_gb: None gpu pool: 96.0 AMD iGPU
gaia.llm.model_fit.ModelFitError: Lemonade reports no available AMD NPU on this PC, so the NPU models (gemma4-it-e4b-FLM) cannot run. ...

After:  has_npu: True npu_memory_gb: 62.4 gpu pool: 96.0 AMD iGPU
recommend_npu_chat_model: ('gemma4-it-e4b-FLM', [], MachineCapacity(memory_gb=62.4, memory_source='NPU, system RAM', ...))

Spot checks came back the same on both versions: on a Windows-shaped report the carve-out still comes off (48 GB NPU), the GPU pool stays at 96 GB, and the GPU model's context, local status and provider list all return 200.

Not exercised here:

  • the NPU row in the model list (this runner has no FLM backend, so the row is filtered out on both versions)
  • the TUI's copy of the rule, which is covered by Go unit tests only
  • gaia init --profile npu run end to end
  • the Agent UI screenshot, pending the strix-halo lane

For those surfaces the verdict rests on static review and unit tests.

🔍 Technical details

Issues

🟢 A missing OS Version is treated as Linux (src/gaia/llm/model_fit.py:406, tui/internal/lemonade/capacity.go:127). _physical_counts_carve_out returns False for an empty or absent OS Version, so the carve-out is skipped. If a Windows Lemonade ever omitted that field, the NPU would be sized against installed RAM, which still includes the carve-out, and a model that can't load could look like it fits. Current Lemonade always sends the field (npu_linux.applies_to already depends on it), so this is low risk. Two cheap options: check the platform the other way (treat only a report that names Linux as Linux), or log a warning when the field is absent. Several fixtures without the field now take the Linux branch: laptopNPU in npu_test.go, plus _system_info and npuMissing.

🟢 Stale number in a test message (tui/internal/lemonade/npu_test.go:80). laptopNPU has no OS Version, so its NPU memory is now 16 GB, not 15.5 GB. The assertion still passes, but the failure message names the old figure.

		t.Fatalf("Gemma NPU should fit 16 GB of NPU RAM: %+v", by["gemma4-it-e4b-FLM"])

Checked, no finding

  • Sibling paths: npu_memory_gb is only produced by capacity_from_system_info, and npu_capacity, has_npu and the setup recommender all read that one value. The GPU pool still uses the unchanged ram, so GPU sizing doesn't move, which matches the evidence. The Go mirror applies the same rule with the same case-insensitive windows prefix.
  • Docs: docs/guides/npu.mdx:107 and CLAUDE.md say "installed RAM less any GPU carve-out". That is still true in effect: Linux's MemTotal is installed RAM minus the carve-out. No drift.
  • Known bug classes: this is a fix for the cold-start / non-default-setup class (a common Strix Halo VRAM setting). It adds no new waits, shared state or subprocesses.

Strengths

  • The old STRIX_HALO_128 fixture claimed to be a Linux report but carried a Windows-style memory figure. That mismatch is why the bug got through, and correcting it fixes the root cause rather than the symptom.
  • New tests cover both operating systems, the large-carve-out case (64 GB and 96 GB), the setup recommender end to end, and the Windows case where the carve-out fills RAM. The Go and Python tables are kept in step.
  • The PR description is clear about what it won't fix: the runner's locked-memory limit.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit c9f5148 Nov 5, 2026
79 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/linux-npu-carve-out branch November 5, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llm LLM backend changes performance Performance-critical changes tests Test changes tui Go terminal UI (gaia-tui)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant