[GH-ISSUE #5016] [GUI] Monitor: Apple Silicon GPU temperature and power without root or installing extra packages (opt-in) #2320

Open
opened 2026-11-04 01:58:25 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @alexjyong on GitHub (Nov 2, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5016

Area

[GUI] (the desktop app)

What do you want to do?

  • Problem: on a Mac the Monitor's GPU temp and Power cards are a dash, because both need root (powermetrics).
  • Proposal: read them without root, in-process, the way Stats does (MIT, as Strata is), behind an opt-in switch, STRATA_MACOS_SENSORS=1.
  • Private API: HID, SMC and IOReport are undocumented and can change in any macOS release. Every call fails soft.
  • Chips: the temperature keys are a per-chip table copied from Stats. I ran the M5 Pro only. Owners of other chips would need to test theirs.
  • Status: I got a local checkout I've been testing out. Screenshots
Image Image

Problem and result

On a Mac the Monitor's GPU temp and Power cards are a dash, and the note says both need root. The cards already draw whatever value they are given; nothing reads one. This is the need in #2942 / #2943 (the macmon helper, closed in the 0.2.0 tracker reset; thank you, @mjhagen). The IOKit reader from #2360 stays as it is.

With STRATA_MACOS_SENSORS=1 the cards fill, without root and without a helper program. On an M5 Pro (macOS 26.4.1, Strata 870aedd9):

  • Power: IOReport's "Energy Model" group has a GPU Energy channel. Idle about 0.1 W; about 3 to 6 W at roughly 70 % GPU load while a Q2_0 model generated.
  • Temperature: the HID service lists 76 temperature sensors and none is a GPU MTR Temp*, so Stats' HID rule would read nothing here. Stats reads this chip's GPU temperature from AppleSMC keys instead; 7 of the 8 keys its M5 table names answer on this Mac.
  • Cost: about 2 ms per read, once a second.

Without the variable nothing changes. With it unset I compared the server's now, history and hardware_static keys and the
Monitor note with untouched upstream on this Mac [on the full branch; same code path], and they are identical.

#2942 / #2943 (closed in the tracker reset, no review), #2360 (the IOKit reader), and #3682 (Windows AMD sensors), which
edits the same two places in serve/telemetry.py (gpu_reader and the module docstring). I will rebase on whichever lands first.

Scope questions:

  1. Is a private-API reader acceptable behind an opt-in switch? If not, I stop here.
  2. Is shipping Stats' rows for chips I could not run acceptable (labelled as untested), or should the PR hold the M5 only until owners confirm theirs?
  3. Switch name: STRATA_MACOS_SENSORS=1, or STRATA_MACOS_TELEMETRY=1 as in #2943?

Approach

serve/telemetry.py, serve/test_apple_sensors.py and a short section in docs/MAC.md. Every symbol is looked up by name; a missing one leaves that reading empty and never raises. Power is IOReport's GPU Energy over the time since the last read.

The SMC keys differ by chip, so the temperature needs a table keyed by chip, as Stats has
(values.swift at
032f4a5e4). A key does not keep its meaning: Tg0j is GPU 2 on an M2, GPU 7 on an M4 and GPU 5 on an M5; an M3's keys are Tf..; the M4's base chip and its Pro/Max differ in two keys.

  • The PR holds Stats' GPU rows for M1 to M6 and the A18 Pro, generated from that commit, not retyped. The code comment and docs/MAC.md say so.
  • Kept up to date by hand, against the recorded Stats commit, when a chip is added or Stats changes a row. Nothing is vendored.
  • The reader only takes a key that answers as a four-byte float between 0 and 110 °C. A chip with no key that answers falls back to the HID GPU MTR Temp* sensors, as Stats does (from its code; I have not seen it run).

Validation

Passed (M5 Pro, fresh 870aedd9 + the PR):

  • python -m unittest serve.test_apple_sensors serve.test_server.MacTelemetry: 19 tests, OK. They cover the lookup by chip (each generation, the M4 tiers, an unknown chip) but cannot show a row is right for a chip.
  • Switch on: temperature and power read (72.7 °C, 3.05 W in one reading while something else loaded the GPU). Off or unset: both None, old note.
  • 5,000 reads from a background thread: memory flat (27.0 MB), no errors.

Failed: none observed.

Not run:

  • Any chip but the M5 Pro. Stats ships the other rows, but I have not run them. Owners of other chips: please try it and report. Nor any macOS but 26.4.1, nor the HID fallback on any chip.
  • The web Monitor and the app with the switch on in the final build.

Limits

  • Untested rows: a wrong row would show a plausible temperature under the wrong label, and nothing in the reader can tell. The switch being opt-in limits who sees it.
  • Private API: can change in any macOS release.
  • HID fallback: it re-reads the whole HID list every second (about 85 ms on this Mac's 76 sensors; Stats refreshes every 60 s). Not cached yet. [decide: cache it, or leave it listed]

What do you do today instead?

Stats for the temperature and sudo powermetrics --samplers gpu_power -i 1000 for power. Neither shows next to tokens per second in Strata's Monitor.

Originally created by @alexjyong on GitHub (Nov 2, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/5016 ### Area [GUI] (the desktop app) ## What do you want to do? - **Problem:** on a Mac the Monitor's GPU temp and Power cards are a dash, because both need root (`powermetrics`). - **Proposal:** read them without root, in-process, the way [Stats](https://github.com/exelban/stats) does (MIT, as Strata is), behind an opt-in switch, `STRATA_MACOS_SENSORS=1`. - **Private API:** HID, SMC and IOReport are undocumented and can change in any macOS release. Every call fails soft. - **Chips:** the temperature keys are a per-chip table copied from Stats. I ran the M5 Pro only. Owners of other chips would need to test theirs. - **Status:** I got a local checkout I've been testing out. Screenshots <img width="1874" height="508" alt="Image" src="https://github.com/user-attachments/assets/5d40ad73-7c6e-4d33-987e-19b537f7f05a" /> <img width="1864" height="407" alt="Image" src="https://github.com/user-attachments/assets/05b767f7-cacc-4f81-b129-f6f925375b54" /> ### Problem and result On a Mac the Monitor's **GPU temp** and **Power** cards are a dash, and the note says both need root. The cards already draw whatever value they are given; nothing reads one. This is the need in #2942 / #2943 (the `macmon` helper, closed in the 0.2.0 tracker reset; thank you, @mjhagen). The IOKit reader from #2360 stays as it is. With `STRATA_MACOS_SENSORS=1` the cards fill, without root and **without a helper program**. On an M5 Pro (macOS 26.4.1, Strata `870aedd9`): - **Power:** IOReport's "Energy Model" group has a `GPU Energy` channel. Idle about 0.1 W; about 3 to 6 W at roughly 70 % GPU load while a Q2_0 model generated. - **Temperature:** the HID service lists 76 temperature sensors and none is a `GPU MTR Temp*`, so Stats' HID rule would read nothing here. Stats reads this chip's GPU temperature from `AppleSMC` keys instead; 7 of the 8 keys its M5 table names answer on this Mac. - **Cost:** about 2 ms per read, once a second. Without the variable nothing changes. With it unset I compared the server's `now`, `history` and `hardware_static` keys and the Monitor note with untouched upstream on this Mac [on the full branch; same code path], and they are identical. ### Related discussion #2942 / #2943 (closed in the tracker reset, no review), #2360 (the IOKit reader), and #3682 (Windows AMD sensors), which edits the same two places in `serve/telemetry.py` (`gpu_reader` and the module docstring). I will rebase on whichever lands first. **Scope questions:** 1. Is a private-API reader acceptable behind an opt-in switch? If not, I stop here. 2. Is shipping Stats' rows for chips I could not run acceptable (labelled as untested), or should the PR hold the M5 only until owners confirm theirs? 3. Switch name: `STRATA_MACOS_SENSORS=1`, or `STRATA_MACOS_TELEMETRY=1` as in #2943? ### Approach `serve/telemetry.py`, `serve/test_apple_sensors.py` and a short section in `docs/MAC.md`. Every symbol is looked up by name; a missing one leaves that reading empty and never raises. Power is IOReport's `GPU Energy` over the time since the last read. The SMC keys differ by chip, so the temperature needs a table keyed by chip, as Stats has ([`values.swift`](https://github.com/exelban/stats/blob/032f4a5e4/Modules/Sensors/values.swift) at [`032f4a5e4`](https://github.com/exelban/stats/commit/032f4a5e4)). A key does not keep its meaning: `Tg0j` is GPU 2 on an M2, GPU 7 on an M4 and GPU 5 on an M5; an M3's keys are `Tf..`; the M4's base chip and its Pro/Max differ in two keys. - The PR holds Stats' GPU rows for M1 to M6 and the A18 Pro, generated from that commit, not retyped. The code comment and `docs/MAC.md` say so. - **Kept up to date by hand**, against the recorded Stats commit, when a chip is added or Stats changes a row. Nothing is vendored. - The reader only takes a key that answers as a four-byte float between 0 and 110 °C. A chip with no key that answers falls back to the HID `GPU MTR Temp*` sensors, as Stats does (from its code; I have not seen it run). ### Validation **Passed** (M5 Pro, fresh `870aedd9` + the PR): - `python -m unittest serve.test_apple_sensors serve.test_server.MacTelemetry`: 19 tests, OK. They cover the lookup by chip (each generation, the M4 tiers, an unknown chip) but cannot show a row is right for a chip. - Switch on: temperature and power read (72.7 °C, 3.05 W in one reading while something else loaded the GPU). Off or unset: both `None`, old note. - 5,000 reads from a background thread: memory flat (27.0 MB), no errors. **Failed:** none observed. **Not run:** - **Any chip but the M5 Pro.** Stats ships the other rows, but I have not run them. Owners of other chips: please try it and report. Nor any macOS but 26.4.1, nor the HID fallback on any chip. - The web Monitor and the app with the switch on in the final build. ### Limits - **Untested rows:** a wrong row would show a plausible temperature under the wrong label, and nothing in the reader can tell. The switch being opt-in limits who sees it. - **Private API:** can change in any macOS release. - **HID fallback:** it re-reads the whole HID list every second (about 85 ms on this Mac's 76 sensors; Stats refreshes every 60 s). Not cached yet. [decide: cache it, or leave it listed] ## What do you do today instead? Stats for the temperature and `sudo powermetrics --samplers gpu_power -i 1000` for power. Neither shows next to tokens per second in Strata's Monitor.
Author
Owner

@github-actions[bot] commented on GitHub (Nov 2, 2026):

Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

  • Fill in "Area".

Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

<!-- gh-comment-id:6583239449 --> @github-actions[bot] commented on GitHub (Nov 2, 2026): Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing: - [ ] Fill in "Area". Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment `/reopen`. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

@github-actions[bot] commented on GitHub (Nov 2, 2026):

Thanks, this follows the format now.

<!-- gh-comment-id:6586276673 --> @github-actions[bot] commented on GitHub (Nov 2, 2026): Thanks, this follows the format now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2320
No description provided.