Commit graph

2 commits

Author SHA1 Message Date
Daniel Han
6b62b2b5c0
Guard Apple GPU power against negative counter-reset readings (#6235)
IOReport energy counters can reset (sleep/wake, power gating), making a poll
delta negative. Return None for a negative total so the monitor shows -- for
that poll instead of a bogus negative wattage; it self-corrects next poll.
2026-06-12 01:56:05 -07:00
Ban
de0c5a2f09
Studio: show Apple GPU temperature and power in the GPU monitor (macOS) (#6187)
* Studio: show Apple GPU temperature and power in the GPU monitor (macOS)

The GPU monitor on Apple Silicon always showed -- for Temperature and
Power: the MLX branch of get_gpu_utilization() hardcoded None because
ioreg's AGXAccelerator PerformanceStatistics carries neither metric.

Add utils/hardware/apple.py, mirroring macmon's no-sudo approach:
- Temperature: average of the AppleSMC "Tg*" float keys via the
  AppleSMCKeysEndpoint user client (ctypes/IOKit, macOS 14+).
- Power: IOReport "Energy Model" group, "GPU Energy" channels; each
  poll diffs the energy counter against the previous poll's sample, so
  the value is the average wattage over the polling window. The first
  poll only sets the baseline and returns None.

Both readers latch to None on first failure and never raise, so
non-Mac platforms and locked-down hosts keep the previous behavior.

* Sample IOReport with the subscribed channels descriptor for PR #6187

IOReportCreateSubscription writes the channel descriptor that later samples
must use; sampling with the original requested group can return no Energy
Model entries on hosts that normalize the channel set, leaving power_draw_w
null after the baseline. Use the subscribed descriptor (matching macmon) and
fall back to the requested channels if the OS leaves it unset.

---------

Co-authored-by: Lee Jackson <130007945+Imagineer99@users.noreply.github.com>
Co-authored-by: danielhanchen <23090290+danielhanchen@users.noreply.github.com>
2026-06-12 01:50:45 -07:00