Skip to content

fix(llm): honor per-device 'available' flag in device validation#2081

Open
github-actions[bot] wants to merge 1 commit into
mainfrom
autofix/issue-2079
Open

fix(llm): honor per-device 'available' flag in device validation#2081
github-actions[bot] wants to merge 1 commit into
mainfrom
autofix/issue-2079

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Before this fix, a REQUIRED_HARDWARE check could pass on hardware that isn't actually usable: LemonadeManager treated the mere presence of a device key in get_system_info()'s devices dict as "detected." A device reported with available: false — e.g. an NPU that's present but disabled or unpowered — was misread as detected, so an agent requiring that device would proceed against hardware it can't use. Now detection keys off the per-device available boolean (the documented get_system_info() contract), so present-but-unavailable devices fail the requirement with the existing actionable device error.

A missing available flag is still treated as available, preserving behavior for sysinfo payloads that omit it. The device-error message contract is unchanged, so the blast radius across agents that set REQUIRED_HARDWARE stays behavior-compatible except for the disabled-device case this fixes.

Closes #2079

Test plan

  • python -m pytest tests/unit/test_multi_device_wiring.py -x passes
  • python util/lint.py --all passes
  • New TestPerDeviceAvailableFlag cases cover: available: true passes, available: false fails with the gaia init --profile npu remedy, key-absent fails, missing-flag treated as available
🔍 Technical details

Root cause: _validate_device_requirement built its detected set from set(devices.keys()) (src/gaia/llm/lemonade_manager.py), ignoring each entry's available boolean.

Changes:

  • Added module-level _device_is_available(info) helper — truthy available for a dict entry, any(...) over a list entry (amd_dgpu can be a list), and a missing flag treated as available for backwards compatibility.
  • The dict branch now builds detected via {name for name, info in devices.items() if _device_is_available(info)}; the list-of-dicts branch skips entries that aren't available before extracting the device type.
  • Added TestPerDeviceAvailableFlag in tests/unit/test_multi_device_wiring.py covering the three acceptance cases plus the missing-flag backwards-compat case.

Verified: tests/unit/test_multi_device_wiring.py device classes, test_npu_device_support.py, and test_hardware_selection.py all pass (44 device tests); python util/lint.py --black --isort --flake8 --pylint clean. The import-validation lint step and one unrelated fastapi-dependent test in this file fail only because optional extras aren't installed in this environment — neither is touched by this change.

LemonadeManager._validate_device_requirement treated any device key
present in get_system_info()'s devices dict as detected, so a device
listed with available: false (e.g. an NPU present but disabled/unpowered)
wrongly satisfied a REQUIRED_HARDWARE floor. Detection now keys off the
per-device 'available' boolean, matching get_system_info()'s documented
contract. A missing flag is still treated as available for backwards
compatibility with payloads that omit it.

Closes #2079
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.

fix(llm): LemonadeManager device validation ignores the per-device 'available' flag

1 participant