- README: how it's split (the hardware service and the app), what setup.ps1 now does, updating from the elevated version, a security model section (what the pipe allows and checks, the unelevated app, and that this is not a boundary against malware running as the user: the service runs code from user-writable folders), where each setting lives (hw-settings.json and the legacy sections), the 503s, the service log, identifying fan ports with the service stopped, running either part by hand, and the new layout. - The USB hub note, in the README and case_fans.py: the LCD is now on a back-panel port (Intel root hub); the CORE shares the Genesys hub with the Commander PRO. The ~22 frames/s cap stays as a margin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
498 lines
32 KiB
Markdown
498 lines
32 KiB
Markdown
# The Kurgan
|
||
|
||

|
||
|
||
Runs this PC's backend systems, with one web UI at **<http://127.0.0.1:8080/>**:
|
||
|
||
| Capability | What it does | Package |
|
||
| --- | --- | --- |
|
||
| Telemetry | CPU, GPU and whole-PC power readings, once a second, with 10 minutes of history | `kurgan/telemetry` |
|
||
| Display | The CPU/GPU/power dashboard on the Thermaltake 3.9" LCD | `kurgan/display` |
|
||
| Cooling | Commander PRO case fans and motherboard top fans on selectable profiles | `kurgan/cooling`, run by `kurgan/hw` |
|
||
| Lighting | Case fan, RAM and GPU LEDs: off, temperature or the red side chase | `kurgan/lighting` |
|
||
| AI | Serves Strata and llama.cpp at `/strata/v1` and `/llama/v1`, running **one** at a time: a request starts the one it needs, and an unused one stops | `kurgan/ai` |
|
||
| Web UI | Control and monitoring for all of the above, plus a JSON API | `kurgan/web` |
|
||
|
||
It replaces three background programs: the TT LCD Dashboard task, Strata's tray service and
|
||
the Qwen4 service (llama.cpp plus its monitor page on port 8084).
|
||
|
||
## How it's split
|
||
|
||
Two processes, so that only the part that needs admin rights has them:
|
||
|
||
- **The hardware service**, "The Kurgan hardware" (`KurganHw`, `kurgan/hw`): a Windows service
|
||
running as LocalSystem from boot, before anyone logs on. It does what needs PawnIO, plus what
|
||
must never depend on anything else: the case and top fan curves with their fail-safes, the
|
||
CPU package temperature and power, the GPU temperature it needs for the curves, and the RAM
|
||
lighting. It listens on no network port; its only interface is the named pipe
|
||
`\\.\pipe\kurgan-hw`. If it crashes, Windows restarts it after 5 s, 10 s, then 60 s.
|
||
- **The app**, "The Kurgan" (`python -m kurgan`): everything else, without admin rights, from a
|
||
logon task: the web UI, the AI servers (as its own children), telemetry, the LCD, the case fan
|
||
and GPU lighting, and the tray icon. It shows what the hardware service reports and asks it
|
||
for profile and RAM lighting changes. While the service is unavailable the app says so (UI,
|
||
tray balloon) and carries on without those readings.
|
||
|
||
Restarting or killing the app never touches the fans. Sensors the app reads itself are read
|
||
once and shared, so the LCD, the lighting and the web UI all use the same readings.
|
||
|
||
## Setup
|
||
|
||
```powershell
|
||
powershell -ExecutionPolicy Bypass -File .\setup.ps1 -RetireAIServices
|
||
```
|
||
|
||
Run it from a normal (not elevated) PowerShell window; it asks for admin rights itself. It:
|
||
|
||
- Installs the Python packages into the project's `.venv` (creating it if needed; the hardware service runs from it too).
|
||
- Installs [PawnIO](https://pawnio.eu). PawnIO is the signed driver LibreHardwareMonitor and FanControl also use. It reads the Intel CPU sensors and drives the motherboard fan headers and the RAM lighting.
|
||
- Installs or updates the **The Kurgan hardware** service (`KurganHw`): LocalSystem, automatic start, restart on failure. It runs the base Python interpreter (not the venv's `python.exe`, a redirector) on `hw_service.py`, after checking that it can.
|
||
- Creates `%ProgramData%\Kurgan` (Administrators and SYSTEM write, users read) and, once, moves the fan settings and the RAM lighting mode from your `settings.json` into `hw-settings.json` there. `settings.json` keeps a dated `.bak` copy from before.
|
||
- Replaces the old **TT LCD Dashboard** task (and an older, elevated **The Kurgan** task) with a **The Kurgan** scheduled task, registered as you. The task runs `pythonw -m kurgan` hidden, without admin rights, at every logon.
|
||
- Prints what the hardware service reports (`python -m kurgan.hw.client` does that any time).
|
||
|
||
Run `setup.ps1` again after updating The Kurgan: it stops, updates and restarts both parts.
|
||
|
||
**Updating from the elevated version:** run `setup.ps1` before restarting the old elevated
|
||
"The Kurgan" task with this code. Until then there's no hardware service: the new app would
|
||
have no fan control to show, and (being elevated) it refuses to start the AI servers.
|
||
|
||
`-RetireAIServices` stops and disables the **Strata Local Service** and **Qwen4 Local Service**
|
||
tasks, so The Kurgan can run whichever server you select. Without that switch, The Kurgan finds
|
||
those servers already listening on their ports. It shows them as "running outside The Kurgan"
|
||
and monitors them, but it never starts a second copy. Requests go to one only once it answers
|
||
as the expected server; a port held by some other program is reported, not served.
|
||
|
||
`uninstall.ps1` removes the task and the hardware service (stopping it leaves the case fans at
|
||
100% and the top fans on the BIOS curve). `uninstall.ps1 -RestoreAIServices` also re-enables and
|
||
starts the two LLM service tasks. `-RemovePawnIO` uninstalls PawnIO. Settings stay in
|
||
`%LOCALAPPDATA%\Kurgan` and `%ProgramData%\Kurgan`.
|
||
|
||
### Security model
|
||
|
||
- **Only the hardware service has admin rights**, and it has no network interface. Its pipe
|
||
allows SYSTEM, Administrators and the user who ran `setup.ps1` (read and write, but not
|
||
creating pipe instances, so nothing running as you can impersonate the service's end), and
|
||
refuses remote clients. It accepts five operations (`hello`, `state`, `set_profile`,
|
||
`set_ram_lighting`, `ram_chase`), checked strictly, in messages of at most 64 KiB; a client
|
||
silent for 30 s is dropped, and no client can hold up the fan loop. The app checks that the
|
||
pipe belongs to SYSTEM or Administrators before using it.
|
||
- **The app runs without admin rights**: the web UI (127.0.0.1 only), the proxy, and the LLM
|
||
servers, which are its own children in job objects at medium integrity. If the app is ever
|
||
started elevated it refuses to start them rather than pass admin rights on (see
|
||
`kurgan/ai/launcher.py`); the UI then warns "Running elevated", and shows each server's
|
||
integrity level. Anything running as you can use the web API, and through it (or the pipe)
|
||
change the fan profile and the RAM lighting, nothing more.
|
||
- **Not a boundary against malware running as you.** The service runs code from this repo and
|
||
the Python install in your profile, both of which you (and so anything running as you) can
|
||
change; the change would run as SYSTEM at the service's next start. That is the trust the
|
||
old elevated logon task had, at a higher level. A real boundary would need the service's code
|
||
and interpreter in an admin-only folder; that's not done.
|
||
|
||
## Web UI
|
||
|
||
Open it from the tray icon (left-click, or **Open The Kurgan** in its menu) or browse to
|
||
<http://127.0.0.1:8080/>. It only listens on 127.0.0.1. The page refreshes once a second while it
|
||
is visible. Every chart has a **Table** button that shows the same numbers as a table. The tray
|
||
icon also pops a balloon tip when something starts to go wrong — a fan group entering failsafe,
|
||
an AI server reporting an error, a sensor source starting to fail, or the hardware service
|
||
becoming unavailable. Problems that start together
|
||
share one balloon (Windows shows one at a time), and a problem that clears and comes back
|
||
balloons again only after 10 minutes. What is already wrong when The Kurgan starts is not
|
||
ballooned; it sits in the tray menu and the UI. The header shows whether the hardware service
|
||
is reachable (hover for its version and uptime, or why not).
|
||
|
||
- **System**: CPU and GPU temperature, load, clock and power; GPU memory; the LCD's state. Charts show whole-PC power (stacked: other, CPU, GPU) and temperatures over the last 10 minutes. A range selector above the charts switches them to hourly averages for 24 hours, 7 days, 30 days or a year. Those long-term rollups live in `%LOCALAPPDATA%\Kurgan\records-YYYY-MM.jsonl` — one JSON line per hour with min, average and max per metric (the average only over the samples that had the metric), about 400 days kept. The hour in progress is checkpointed to `records-current.json` every minute and on exit and resumed at the next start, so a restart — even `schtasks /End` — loses at most a minute. Writing is best effort: a failing disk is logged at most once an hour, and finished hours wait in memory (up to two days) until it works again. `--demo` never records. When a sensor source is failing — its read raised, or it has returned no temperature three times in a row (a lost GPU driver, an unavailable MSR reader) — a pill in the header names it and hover shows the error.
|
||
- **Cooling**: the fan profile selector; each fan group's duty, temperature and RPMs; fan speeds over time; and the selected profile's curves, with a dot for each group's current operating point. Hover over a profile to preview its curves. All of it comes from the hardware service, and a profile change goes to it.
|
||
- **Lighting**: a mode selector per zone (case fans, RAM, GPU), the zone's status, and the shared chase speed.
|
||
- **AI**: pick Strata (and its model), llama.cpp or None; requests to either address also pick it. Then see the server's process, model, context size, live request progress and token speeds, and when it will stop if unused; load or unload the model; GPU memory over time; and recent requests.
|
||
|
||
Every choice is saved immediately and restored at the next start: the fan profile and the RAM
|
||
lighting by the hardware service in `%ProgramData%\Kurgan\hw-settings.json`, the rest in
|
||
`%LOCALAPPDATA%\Kurgan\settings.json`.
|
||
|
||
### JSON API
|
||
|
||
| Request | Body / result |
|
||
| --- | --- |
|
||
| `GET /api/state` | Everything live (what the UI polls), including `telemetry.health`: the sensor sources that are failing (latest read raised, or no temperature three reads running), each with its error and age |
|
||
| `GET /api/history` | The last 10 minutes of telemetry and fan duty |
|
||
| `GET /api/records?days=N` | Hourly min/avg/max rollups for the last N days (1-400), oldest first |
|
||
| `GET /api/config` | Fan profiles and LCD theme thresholds |
|
||
| `POST /api/lighting` | `{"zone": "case_fans"\|"memory"\|"gpu", "mode": "off"\|"temperature"\|"chase"}` |
|
||
| `POST /api/cooling/profile` | `{"profile": "quiet"\|"balanced"\|"performance"\|"full"}` |
|
||
| `POST /api/ai/active` | `{"backend": "strata"\|"llama"\|null, "variant": "q5"\|"iq3"}` (variant: Strata only, optional) |
|
||
| `POST /api/ai/model` | `{"action": "load"\|"unload"}` |
|
||
| any `/strata/...`, `/llama/...` | Passed to that LLM server (see [AI](#ai-strata-and-llamacpp)) |
|
||
|
||
POSTs to `/api/...` need `Content-Type: application/json` and an `X-Kurgan: 1` header. A web page on another
|
||
site can't send that header without a CORS preflight, which this server never answers. Requests
|
||
must also name `127.0.0.1:<port>` or `localhost:<port>` as the Host, which blocks DNS rebinding.
|
||
There is no other authentication: any program already running on this PC as you can use the API.
|
||
`POST /api/cooling/profile`, and `/api/lighting` for the RAM, answer **503** while the hardware
|
||
service can't be reached (or can't save the change).
|
||
|
||
```powershell
|
||
curl.exe -s -X POST -H "Content-Type: application/json" -H "X-Kurgan: 1" `
|
||
-d '{\"profile\":\"quiet\"}' http://127.0.0.1:8080/api/cooling/profile
|
||
```
|
||
|
||
## Settings
|
||
|
||
The app's: `%LOCALAPPDATA%\Kurgan\settings.json`, created on the first start:
|
||
|
||
```json
|
||
{
|
||
"lighting": {"case_fans": "chase", "gpu": "off"},
|
||
"ai": {"active": "strata", "strata_model": "q5", "idle_stop_minutes": 40},
|
||
"web": {"port": 8080}
|
||
}
|
||
```
|
||
|
||
The hardware service's: `%ProgramData%\Kurgan\hw-settings.json` (admins write, users read):
|
||
|
||
```json
|
||
{
|
||
"cooling": {"profile": "balanced", "gpu_ports": [4, 5, 6], "cpu_ports": [1, 2, 3], "top_channels": [2, 5]},
|
||
"lighting": {"memory": "off"}
|
||
}
|
||
```
|
||
|
||
Both files are checked strictly, and a failed save leaves the previous setting in place, both in
|
||
memory and on disk. An invalid `settings.json` stops the app with a message. An invalid
|
||
`hw-settings.json` doesn't stop the service: it holds every case fan at 100% and says why in the
|
||
UI's cooling section; fix the file and `Restart-Service KurganHw` (elevated). A `settings.json`
|
||
from before the split may still hold `cooling` and `lighting.memory`: they're checked and kept,
|
||
but nothing uses them (`setup.ps1` moves them).
|
||
|
||
On the first start, The Kurgan imports the TT LCD Dashboard's settings from
|
||
`%LOCALAPPDATA%\TTLcdDashboard` into `settings.json` (`setup.ps1` then moves the fan and RAM
|
||
parts). The old task's `--rgb-side-chase` becomes `case_fans: chase`.
|
||
|
||
`idle_stop_minutes` is how long a server may go unused before The Kurgan stops it (0 = never,
|
||
up to 1440). The `ai` section also accepts these optional keys, for when an install moves:
|
||
|
||
- `strata_root` (default `D:\AI\Strata`) and `strata_port` (8082, internal)
|
||
- `llama_server` (llama.cpp **b12977**), `llama_presets`, `llama_model` and `llama_port` (8083, internal)
|
||
|
||
See `kurgan/ai/config.py`. Restart The Kurgan after editing the file by hand.
|
||
|
||
Command-line lighting options such as `--rgb-side-chase` apply to that run only. The UI marks
|
||
them "this run only"; choosing a mode in the UI saves it. The RAM has none: it's the hardware
|
||
service's, and only the UI changes it.
|
||
|
||
Logs: `%LOCALAPPDATA%\Kurgan\kurgan.log` (the app), `%ProgramData%\Kurgan\kurgan-hw.log` (the
|
||
hardware service; it logs each change of a fan group's status, which carries its temperature,
|
||
duty and speeds, so it shows fan control running even before logon).
|
||
|
||
## AI: Strata and llama.cpp
|
||
|
||
Point OpenAI-compatible clients at The Kurgan:
|
||
|
||
| Server | Base URL | Chat page | Model |
|
||
| --- | --- | --- | --- |
|
||
| Strata | `http://127.0.0.1:8080/strata/v1` | <http://127.0.0.1:8080/strata/> | OrcaRouter Qwen3.8 Flash Next, Q5_K_M or IQ3_XXS (selectable) |
|
||
| llama.cpp | `http://127.0.0.1:8080/llama/v1` | <http://127.0.0.1:8080/llama/> | Qwen4 35B-A3B UD-Q5_K_XL |
|
||
|
||
No API key is needed. Clients that insist on one can send any key.
|
||
|
||
Only one server runs at a time, so the two never share the RTX 4090's 24 GB. A request starts the
|
||
server it is addressed to. If the other server is running, it is stopped first:
|
||
|
||
- If the other server is busy (a request in progress, a reply being generated, or a model
|
||
loading), the new request waits until it finishes, for up to 10 minutes, rather than
|
||
cutting it off.
|
||
- Stopping means stopping completely: every process in its job object has ended and its port
|
||
has closed. Only then does the other server start.
|
||
- A server with a request in flight is never stopped or replaced mid-reply, however the switch
|
||
happens: the old server finishes its request first, and the new one doesn't start until the
|
||
GPU's memory is free again.
|
||
- A request that has to start its server waits for it. A swap takes a few seconds, plus the model's
|
||
load time (about 45 s for either model). Give clients a generous timeout.
|
||
|
||
A server nobody has used for `idle_stop_minutes` (40) is stopped, and the UI shows **None**. The next
|
||
request starts it again. Choosing a server in the UI starts it straight away. If a request is
|
||
in progress there, the UI asks before switching.
|
||
|
||
How the proxy behaves (`kurgan/web/proxy.py`):
|
||
|
||
- Replies stream through as they are generated.
|
||
- A client that hangs up (a timeout, or a cancel) is noticed within a second, even while its request is still waiting: it gives up its place, so it never makes the servers swap, and the server is told to drop it. The log says how long the client waited and at which stage.
|
||
- Clients' own timeouts must allow for the waits above. opencode, for example, gives up after 5 minutes without a reply unless its provider options set `headerTimeout`.
|
||
- `GET /v1/models` is answered by The Kurgan while a server is stopped, so a client that lists the
|
||
models of both doesn't make them swap.
|
||
- Requests from web pages of other sites are refused, as for the UI's own API.
|
||
|
||
Behind the proxy each server listens on its own port on 127.0.0.1. Clients shouldn't use these
|
||
ports: requests sent straight to them don't start or keep a server running.
|
||
|
||
| Server | Internal port | What The Kurgan runs |
|
||
| --- | --- | --- |
|
||
| Strata | 8082 | `kurgan/ai/strata_host.py`, using Strata's own `terminal\.venv` |
|
||
| llama.cpp | 8083, under `/llama` | `llama-server.exe` b12977 in router mode, from the Qwen4 service's `presets.ini`, with `--api-prefix /llama` and its API key (`sk-local`), which the proxy supplies |
|
||
|
||
Strata's optional API-monitor page (`/api-monitor`) uses absolute paths, so it doesn't work under
|
||
`/strata/`. The Kurgan's own AI section shows the same requests.
|
||
|
||
Both start with no model in memory. The model loads on the first request, or when you press
|
||
**Load model**. Strata unloads it after 2000 s idle; llama.cpp sleeps after its preset's idle
|
||
time. Strata is stopped gracefully through a named event, and gets 45 s to finish; if the server
|
||
somehow never returns from that, it ends its engine processes and exits by itself after 40 s
|
||
(The Kurgan's kill stays as the last resort). llama.cpp is ended through its job object. Each
|
||
server gets the same environment its own service gave it: Strata runs with
|
||
`GGML_CUDA_DISABLE_GRAPHS=1`, and llama.cpp runs without it. Both use OpenBLAS's default
|
||
threading, not the single-thread pin The Kurgan uses for itself.
|
||
|
||
Live progress comes from different places:
|
||
|
||
- **Strata**: its `/metrics` endpoint.
|
||
- **llama.cpp**: its log. Polling `/slots` would reset the idle timer.
|
||
|
||
Logs:
|
||
|
||
- `%LOCALAPPDATA%\Kurgan\logs\strata-host.log` and `llama-server.log` (each keeps the previous
|
||
run's log as `.prev`)
|
||
- Strata's own `D:\AI\Strata\logs\local-service-*.log`: the task log keeps one `.prev`, and the
|
||
newest seven stdout/stderr pairs are kept
|
||
|
||
A server that exits on its own is restarted after 5 seconds. After 5 exits within 5 minutes,
|
||
The Kurgan waits 5 minutes before trying again, and the UI shows why.
|
||
|
||
**Updating Strata**: Strata's `LOCAL-SERVICE-HANDOFF.md` assumes its own tray service. Once that
|
||
service is retired, select **None** in the UI before updating Strata, then select Strata again.
|
||
Until the update is finished, don't send requests to `/strata/`: any one of them starts Strata again.
|
||
The Kurgan starts `strata_host.py` with Strata's own `server.main`, so the update procedure
|
||
otherwise stays the same.
|
||
|
||
## Cooling
|
||
|
||
### Profiles
|
||
|
||
| Profile | GPU-side case fans | CPU-side case fans | Top fans |
|
||
| --- | --- | --- | --- |
|
||
| Quiet | 35% to 45 C, 100% at 75 C | 35% to 55 C, 100% at 85 C | start 55 C, stop below 50 C |
|
||
| **Balanced** (the original curves) | 40% to 40 C, 50% at 50 C, 65% at 60 C, 100% at 70 C | 40% to 50 C, 50% at 60 C, 65% at 70 C, 100% at 80 C | start 50 C, stop below 45 C; 30% at 50 C, 60% at 60 C, 100% at 70 C |
|
||
| Performance | 50% to 35 C, 100% at 65 C | 50% to 45 C, 100% at 75 C | start 45 C, stop below 40 C |
|
||
| Full speed | 100% | 100% | 100% |
|
||
|
||
The exact points are in `kurgan/cooling/profiles.py`. Duty between points is interpolated.
|
||
A profile change raises speeds at once. Lower speeds follow the usual ramp-down: they wait 10
|
||
seconds after the last rise, then fall at most 2 points per second. These fail-safes apply in
|
||
every profile:
|
||
|
||
- Fans run at 100% on start-up.
|
||
- They run at 100% after a polling gap of over 5 seconds.
|
||
- They run at 100% when a temperature is missing or invalid.
|
||
- A group runs at 100% when one of its fans reads below 200 RPM on three consecutive polls
|
||
after its 10-second spin-up; a single glitchy reading doesn't count.
|
||
- The top fans run at 100% when a fan that was seen turning then reads 0 RPM on three
|
||
consecutive polls.
|
||
- The top fans are held at 100% while either case-fan group runs at 85% or more. They are released once both groups are at 65% or less.
|
||
|
||
### Ports and channels
|
||
|
||
On this machine, identification confirmed these mappings:
|
||
|
||
- Commander PRO PWM ports **1-3 are the CPU side** and **4-6 the GPU side**. This is separate from the RGB chain order.
|
||
- The two top extractors are on **SYS_FAN1 and SYS_FAN4** (NCT6687D PWM channels 2 and 5).
|
||
- The CPU cooler is on CPU_FAN1 (channel 0), which is never touched.
|
||
|
||
The mapping is in `hw-settings.json`. To identify or change it, from an elevated PowerShell,
|
||
stop the hardware service (the case fans go to 100%), run the tools, then start it again:
|
||
|
||
```powershell
|
||
Stop-Service KurganHw
|
||
.\.venv\Scripts\python.exe -m kurgan.cooling.control --identify 1,2,3 # these ports to 100%; watch which side speeds up
|
||
.\.venv\Scripts\python.exe -m kurgan.cooling.control --save-ports 4,5,6 # GPU side
|
||
.\.venv\Scripts\python.exe -m kurgan.cooling.control --save-cpu-ports 1,2,3 # CPU side (GPU side first)
|
||
.\.venv\Scripts\python.exe -m kurgan.cooling.board_fans --probe # read-only motherboard headers (admin)
|
||
.\.venv\Scripts\python.exe -m kurgan.cooling.board_fans --identify 2,5 # hold channels at 100% (admin)
|
||
.\.venv\Scripts\python.exe -m kurgan.cooling.board_fans --auto 2,5 # hand them back to the BIOS (admin)
|
||
.\.venv\Scripts\python.exe -m kurgan.cooling.control --save-top-channels 2,5
|
||
Start-Service KurganHw
|
||
```
|
||
|
||
`--identify` leaves the selected group at 100%, rather than guessing its previous profile. Do not
|
||
guess the port mapping. (The app's old `--gpu-fan-ports` and `--no-gpu-fan-control` options are
|
||
gone: the hardware service owns the fans and reads the mapping from its own settings.)
|
||
|
||
**Controller ownership:** exit iCUE, FanControl and other Commander PRO tools. If you run OpenRGB,
|
||
disable its **Corsair Commander Pro** and **Corsair Lighting Node Core** detectors in both
|
||
`%APPDATA%\OpenRGB\OpenRGB.json` and `C:\Program Files\OpenRGB\service_config\OpenRGB.json`. While
|
||
another tool has a device, The Kurgan leaves that device alone and says so in the UI. The top fans
|
||
share LibreHardwareMonitor's ISA-bus mutex, so don't let another tool control the same headers.
|
||
When the hardware service stops (including at shutdown), the case fans are left at 100% and the
|
||
top fans go back to the BIOS Smart Fan curve.
|
||
|
||
This is software control, not a hardware thermal safeguard. It can't guarantee a speed change
|
||
after a USB failure, a forced kill of the hardware service or a system hang, and the Commander
|
||
PRO keeps its last duty until the service is back (Windows restarts it within seconds). If a top-fan write fails, The Kurgan hands those headers back to the BIOS curve at
|
||
once; if even that fails, the UI says what duty they are left at. Verify temperatures and fan
|
||
rotation under your real workloads. Only SYS_FAN4's tach is wired to the EC, so top-fan stall
|
||
detection covers that fan only: a channel whose tach has never been seen turning is left alone
|
||
rather than crying wolf, and the UI shows "no tach reading" for it instead of 0 rpm. If the
|
||
top-fan code fails in any unexpected way, those headers go back to the BIOS curve and the case
|
||
fans carry on; if the case fans' control loop itself hits an unexpected error, all fans go to 100%.
|
||
|
||
## Lighting
|
||
|
||
| Zone | Device | Modes |
|
||
| --- | --- | --- |
|
||
| Case fans | Corsair Lighting Node CORE (`1B1C:0C1A`), six QL120 fans on header 1 | off, temperature, red side chase |
|
||
| RAM | Four Corsair Dominator Platinum DDR5 sticks, over the Intel SMBus through PawnIO (driven by the hardware service) | off, temperature, red side chase |
|
||
| GPU | ASUS ROG STRIX RTX 4090 LED row, over NVIDIA's `nvapi64.dll` | off, red side chase |
|
||
|
||
- **Off**: the case fans return to the CORE's own hardware effect. The RAM is held dark while The Kurgan runs; black frames are refreshed every 5 s, and the stored effects are untouched. The GPU's previous direct colours and mode are restored.
|
||
- **Temperature**:
|
||
- Case fans: the CPU-side fans follow CPU temperature and the GPU-side fans follow GPU temperature. They are green below `--temp-warn` (50 C), yellow up to `--temp-hot` (80 C), and red above.
|
||
- RAM: the hotter of CPU and GPU blends from dark red `(24, 0, 0)` to warm orange `(255, 48, 0)`, between 50 C and 80 C (the hardware service's fixed range; `--temp-warn` and `--temp-hot` don't reach it).
|
||
- **Red side chase**: warm-orange heads with four fading trail LEDs over dark red. All three zones share one power-paced clock, so they stay in step: the app sends it to the hardware service for the RAM once a second. The pace is 150 ms per LED at 150 W or less, speeding up evenly to 25 ms at 550 W or more (`--rgb-chase-*`).
|
||
- Case fans: the CPU route is bottom → middle → top → middle, and the GPU side is mirrored.
|
||
- RAM: two mirrored heads visit sticks 4 → 3 → 2 → 1 → 2 → 3 once per fan cycle.
|
||
- GPU: one head runs front to back and back again once per cycle.
|
||
|
||
Calibrated case-fan outer-ring indices (zero-based within each 34-LED fan: hub 0-9, outer ring
|
||
10-21, inner ring 22-33):
|
||
|
||
| Chain fan | Location | Outer ring left / right of 12 |
|
||
| --- | --- | --- |
|
||
| 1 | GPU bottom | 16 / 17 |
|
||
| 2 | GPU middle | 16 / 17 |
|
||
| 3 | GPU top | 16 / 17 |
|
||
| 4 | CPU top | 19 / 20 |
|
||
| 5 | CPU bottom | 10 / 11 |
|
||
| 6 | CPU middle | 19 / 20 |
|
||
|
||
The CORE needs a keep-alive every 5 seconds or it drops back to its hardware effect. Updates on
|
||
every device are capped at about 22 per second. The CORE and the LCD used to share a Genesys
|
||
USB 2.0 hub, and heavier traffic once hung the LCD firmware until it was power-cycled. The LCD is
|
||
now on a back-panel port, directly on the Intel root hub; the CORE shares the Genesys hub
|
||
(`05E3:0610`, then `05E3:0608`) with the Commander PRO, which sends little. The cap stays as a
|
||
margin. If the LCD repeatedly reports a handshake timeout (opcode `0x85`), set the case fans to
|
||
off. Then safely power-cycle the LCD and check the cable, power and hub routing before
|
||
re-enabling the chase. Do not unplug internal cables while the PC is powered.
|
||
|
||
The RAM controllers are at `0x18`-`0x1B`, top to bottom. They are written directly over SMBus
|
||
with PawnIO's I801 module (PawnIO Modules 0.2.12; its LGPL source and licence are in
|
||
`kurgan/hardware/pawnio/`). RAM control never changes the stored lighting effects. The GPU driver
|
||
is restricted to PCI `10DE:2684`, subsystem `1043:8932`, with supported ENE firmware at I2C
|
||
`0x67`. It never sends ENE's save-to-flash command. Exit ASUS lighting software, iCUE and OpenRGB
|
||
before using either.
|
||
|
||
**NVIDIA services:**
|
||
|
||
- Keep `NVDisplay.ContainerLocalSystem` running. With it disabled, the card stayed in P0 at full clocks (about 63 W) when idle.
|
||
- Its `nvgwls.exe` plugin is blocked instead, because it repeatedly loaded the GPU at about 270 W. The block is an Image File Execution Options `Debugger` value under `HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\nvgwls.exe`; delete that key to undo it.
|
||
- `NvContainerLocalSystem`, `FvSvc` and the NVIDIA App self-update task remain disabled. Driver updates may re-enable them.
|
||
|
||
## Display
|
||
|
||
The Thermaltake 3.9" bar LCD (USB `264A:233D`, 480×128) needs no TT RGB Plus. The GPU is on the
|
||
left and the CPU on the right, matching the case; all gauges fill clockwise.
|
||
|
||
| Element | Shows |
|
||
| --- | --- |
|
||
| Outer gauges | CPU package temperature (20–100 °C), GPU temperature (20–90 °C) |
|
||
| Inner gauges | CPU and GPU load % |
|
||
| MHz readouts | CPU effective clock, GPU graphics clock |
|
||
| Centre tank | Total power, full = the PSU rating (1000 W). From the bottom: other (copper), CPU (blue), GPU (aqua). Each tick is 10% |
|
||
| TOTAL readout | CPU + GPU + other, in watts |
|
||
| Bottom readouts | The three tank layers: GPU W, other W, CPU W |
|
||
|
||
The background is `kurgan/display/background.png`, loaded once at start-up; restart after
|
||
replacing it. The panel falls back to its own screen if it gets no frame for a few seconds. When
|
||
the LCD is unplugged or the PC sleeps, The Kurgan reconnects; everything else keeps running.
|
||
|
||
## Where the watts come from
|
||
|
||
All figures are DC watts, i.e. load on the power supply; wall draw is roughly 8–12% higher.
|
||
|
||
| Part | Source |
|
||
| --- | --- |
|
||
| CPU | Measured: the package's energy counter (RAPL), via PawnIO, read by the hardware service |
|
||
| GPU | Measured: board power from NVIDIA (the whole card, including its fans and lighting) |
|
||
| CPU regulator losses | Derived: CPU watts × 11% |
|
||
| Memory | Estimated per module (4 × DDR5): 2.5 W idle to 5.5 W, scaled by CPU load |
|
||
| Drives | Estimated from each drive's activity and rated power (Lexar NQ790 3.5 W, Kingston KC3000 8.8 W; the USB hard drive as bus-powered, spun down after 10 minutes idle) |
|
||
| Case fans | Estimated from the Commander PRO's fan speeds, read by the hardware service (about 2 W per fan at 1500 rpm) |
|
||
| Motherboard & chipset | Fixed 15 W |
|
||
| Motherboard-header fans/pump | Fixed 5 W |
|
||
| USB devices & RGB lighting | Fixed 12 W |
|
||
|
||
The estimates are in `PowerModel` in `kurgan/telemetry/sensors.py`.
|
||
|
||
## Running by hand
|
||
|
||
The app (no admin rights needed; the hardware service keeps running):
|
||
|
||
```powershell
|
||
Stop-ScheduledTask "The Kurgan" # only one copy runs at a time
|
||
.\.venv\Scripts\python.exe -m kurgan # console, Ctrl+C to stop
|
||
.\.venv\Scripts\python.exe -m kurgan --preview x.png # render one LCD frame from live sensors
|
||
$env:KURGAN_DATA_DIR = "$env:TEMP\kurgan-demo"
|
||
.\.venv\Scripts\python.exe -m kurgan --demo --port 18080 # simulated hardware; separate settings
|
||
Start-ScheduledTask "The Kurgan" # back to the hidden copy
|
||
```
|
||
|
||
The hardware service (elevated PowerShell for all but the first line):
|
||
|
||
```powershell
|
||
.\.venv\Scripts\python.exe -m kurgan.hw.client # is it reachable, and what is it doing?
|
||
Restart-Service KurganHw # e.g. after editing hw-settings.json
|
||
Stop-Service KurganHw # case fans to 100%, top fans to the BIOS
|
||
& (.\.venv\Scripts\python.exe -c "import sys; print(sys._base_executable)") -I -S -B .\hw_service.py -v # in a console instead
|
||
Start-Service KurganHw
|
||
```
|
||
|
||
In demo mode the hardware service runs inside the app on simulated devices, with its settings in
|
||
`demo-hw-settings.json` in the demo's data folder. The LLM servers use ports 18082 and 18083, but
|
||
they are real servers.
|
||
`python -m kurgan --help` lists the LCD and lighting options. To make one permanent, add it to the
|
||
task's arguments. Lighting modes are better chosen in the UI.
|
||
|
||
| Tool | Use |
|
||
| --- | --- |
|
||
| `python -m kurgan.telemetry.sensors` | Print the live readings and power breakdown (elevated, with the hardware service stopped: one program at a time should poll the Commander PRO) |
|
||
| `python -m kurgan.display.renderer demo.png` | Render the LCD with fixed demo values |
|
||
| `python -m kurgan.display.tt_lcd` | LCD test card |
|
||
| `python -m kurgan.tray` | Show a test tray icon for 20 seconds |
|
||
|
||
Tests: `.\.venv\Scripts\python.exe -m unittest discover -s tests`
|
||
|
||
## Layout
|
||
|
||
```text
|
||
kurgan/
|
||
app.py wires the capabilities together; command line; single instance
|
||
settings.py settings.json: defaults, strict validation, atomic saves, legacy import
|
||
paths.py, theme.py, tray.py, demo.py (simulated hardware for --demo)
|
||
telemetry/ sensors.py (CPU/GPU/system power), readings.py, service.py (sampling + history),
|
||
record.py (hourly rollups for the long-term charts)
|
||
display/ tt_lcd.py (panel HID protocol), renderer.py, service.py (LCD loop), background.png
|
||
cooling/ profiles.py, control.py (case-fan groups, top-fan curve), board_fans.py (NCT6687D)
|
||
lighting/ case_fans.py (CORE patterns + shared chase clock), lighting_node.py, memory.py, gpu.py, service.py
|
||
ai/ config.py, launcher.py (non-elevated child processes in job objects),
|
||
backends.py (Strata, llama.cpp), service.py (one-at-a-time supervisor), strata_host.py
|
||
web/ server.py (API), static/ (index.html, app.js, style.css, logo.png, favicon.ico)
|
||
assets/ sword.png, hilt.png, kurgan.ico (tray icon); make_assets.py rebuilds them and the
|
||
web UI's logo and favicon from The-Kurgan-Sword.png
|
||
hardware/ hid.py (Windows HID), pawnio/ (signed PawnIO modules, LGPL-2.1)
|
||
hw/ the hardware service: protocol.py, pipe.py (access-controlled named pipe),
|
||
service.py (fan loop, RAM lighting, state), main.py, winservice.py (pywin32 host),
|
||
settings.py (hw-settings.json), install.py and migrate.py (setup.ps1),
|
||
client.py (the app's side)
|
||
hw_service.py the hardware service's entry point (what the service manager runs)
|
||
tests/ unittest suites
|
||
docs/ design references and research notes
|
||
lcd_dashboard.py compatibility shim for the old "TT LCD Dashboard" task until setup.ps1 is re-run
|
||
```
|
||
|
||
## LCD protocol notes
|
||
|
||
The panel protocol was worked out by [ttlcd](https://github.com/bekindpleaserewind/ttlcd),
|
||
[thermaltaked](https://github.com/GregDuhamel/thermaltaked) and
|
||
[Tower-500-LCD-Controller](https://github.com/JohnathanKong/Tower-500-LCD-Controller). This is an
|
||
independent implementation.
|
||
|
||
- Interface 0: commands (440-byte reports). Handshake `85 87 85 87 84 81`, brightness `12`, heartbeat `82`.
|
||
- Interface 1: frames (1024-byte reports). A baseline JPEG in 1020-byte chunks: header `08 count 00 80`, then `08 index 00 00`.
|