moodmosaic

A Thermal Guard for Three Macs

Part 5 of Same Prompts, Three Macs.

A terminal split in two, each half showing macmon for one Mac Studio: GPU load, power in watts, CPU and GPU temperature, fan speed and a process list.

macmon on the M3 Ultra and the M5 Ultra while both generate.

Three Macs serve local models to coding agents that run for hours while I am away. Part 2 logged only a thermal pressure level, and needed root for it. The Mac Studios have since moved to a shelf, in a room that reached 37 °C. I wanted degrees per machine and something to act on them.

Degrees without root

macmon reads the sensors of an Apple silicon Mac without sudo. It draws the view in the screenshot, and macmon serve gives the same readings as JSON over HTTP, so the rule in the sudoers file from part 2 is no longer needed. I take three things from it:

In the screenshot both Mac Studios are generating: 167 and 192 W, 62 to 64 °C, fans near 2,500 rpm.

The guard

The agents run in Docker containers on a Linux host, and the Macs only serve them. A shell script on that host asks each Mac’s macmon every 30 seconds and writes one line per poll to a log.

Hottest Mac Action
85 °C or more Freeze the agent containers with docker pause.
75 °C or less Unfreeze them.
90 °C or more Stop the agents and unload the models.

A frozen agent sends no requests, so the Macs cool, and a stop is only undone by hand. When macmon does not answer, the guard falls back to the thermal warning that pmset -g therm prints.

The false cut

The next morning the laptop, an M5 Max MacBook Pro, got its first load. This is the guard’s log for it, in degrees Celsius and watts:

Time (UTC) °C W State
08:40:14 38.5 10 run
08:40:25 62.0 153 run
08:40:44 92.2 153 cut
08:40:55 70.0 24 run
08:41:26 55.4 12 run

One reading over 90 stopped a run that had just started. I then loaded the laptop alone for seven minutes: it reads 98 °C for under a minute at about 135 W while the fans climb to 3,450 rpm, then settles near 66 °C at 65 W, and macOS reports no thermal warning throughout.

Six hours later the laptop read 97.9 °C under load. The guard paused the agents for one poll and resumed them at 70.

A second guard on the Mac

The guard on the Linux host can only stop a server on a Mac over the network. If the host or the link is down, nothing watches the Mac.

So the script that starts the llama.cpp server on a Mac Studio leaves a watchdog beside it, on the Mac. It reads the same macmon locally and stops the server after three readings in a row at 90 °C, or after ten polls with no reading at all. It then writes a file, and the server will not start again until I remove it.

Limits

A temperature needs the machine’s habits beside it. The same 92 °C that would be an alarm on a Mac Studio is the first half minute of every job on the laptop, and the guard was only useful once it knew the difference.