Skip to content

Anonym0usWork1221/Kelvin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kelvin — AI-aware thermal governor and gaming performance engine for rooted Android

Kelvin

AI-aware thermal governor + gaming engine + on-device AI studio for rooted Android.
A tiny root daemon that sustains on-device LLM inference and maximizes game FPS — safely — plus a private, offline AI studio (local chat + image generation) and a RAM manager, wrapped in a neo-brutalist app with a floating performance HUD.

Latest release MIT License Android 14+ Magisk / KernelSU / APatch Snapdragon 8 Gen 2 / 8 Elite Kotlin + Jetpack Compose

Install · AI studio · Using the app · How it works · Build · Architecture · Safety


On-device AI is throttled by thermals: run a local LLM (llama.cpp, MediaPipe, ONNX Runtime, QNN Genie) for a minute and GPU/CPU clocks collapse (680 → 300 MHz) as the phone protects itself. Gaming thermal mods exist, but they chase short FPS bursts, not sustained AI workloads — and nobody ships a governor that reshapes thermal behaviour specifically for NPU/CPU-heavy inference.

Kelvin does both. It detects whether you're gaming or running inference and loads the right frequency/thermal curve in real time:

  • 🎮 Game — burst: raise the GPU + big-core floors for frame stability.
  • 🧠 AI-Sustained — soak: hold clocks flat at a raised-but-bounded ceiling so inference throughput doesn't cliff after a few runs. (The genuinely new part.)
  • ⚖️ Balanced / 🔋 Battery — stock-ish / efficiency.

All behind a hard temperature ceiling, a stock-config backup, and a bootloop watchdog — Kelvin reshapes the thermal curve, it never removes the safety net.

Kelvin — sustained on-device AI inference on one side, mobile gaming burst performance on the other

📱 The app

A neo-brutalist Kotlin + Compose companion: live telemetry, one-tap profiles, per-app rules, a safety panel, a draggable floating HUD you can pin over any game or LLM front-end, plus a full on-device AI studio (local chat + image generation) and a RAM manager. Smallest-possible APK — no analytics, offline-first.

Kelvin dashboard — live skin/SoC/GPU temperature, thermal headroom, and one-tap Game / AI-Sustained / Balanced / Battery profiles   Kelvin live telemetry — per-cluster CPU clocks, GPU frequency and busy percent, RAM, and engine detection toggles   Kelvin safety panel — bootloop watchdog status, editable skin-temperature ceiling, hard thermal limits, and restore-stock  

Dashboard · Live sensors · Safety · Per-app profiles — all streaming from the root daemon over a local socket.

🧠 On-device AI studio

Kelvin isn't just a governor — it ships a fully local, private AI studio that runs entirely on your phone. No cloud, no account, no data leaves the device. And because Kelvin is the thermal governor, it flips itself into AI-Sustained the moment inference starts, so your tokens/sec and image steps don't thermally cliff.

Kelvin AI hub — installed on-device models, one-tap chat and image generation, model manager, device RAM and NPU readout   Kelvin local LLM chat — streaming tokens from a llama.cpp GGUF model with load, stop, offload and AI-Sustained controls   Kelvin image studio — on-device Stable Diffusion with a per-device CPU/GPU backend selector and explicit load-then-generate flow  

AI hub · Local chat (llama.cpp) · Image studio (Stable Diffusion) — 100% offline, on-device.

  • 💬 Local LLM chat (llama.cpp / GGUF). Real streaming chat with any GGUF model, token by token, over a bundled llama-server. Multi-turn history that persists to disk, a searchable History screen (rename / delete), a Stop button, and Offload to free RAM. Tool-calling is wired so the model can ask the image engine to draw a picture mid-conversation.
  • 🎨 On-device image generation (Stable Diffusion 1.5 / stable-diffusion.cpp). Type a prompt, get a real image — no gradient placeholders. A persistent server loads the model once (device-specific compute compiled at load, like a warmed-up LLM), then generations run instantly after. A per-device backend picker (Auto / GPU / CPU) is discovered from your actual hardware, with load → generate, Reload / Offload, Stop, and one-tap Save to Photos. Private gallery — nothing touches your camera roll until you export it.
  • 📦 Model manager. Browse a curated catalog or paste any HuggingFace link; downloads are resumable, cancellable, and foregrounded, with an optional token for gated models. Delete models to reclaim storage, and fetch a curated NPU-optimized build when your SoC supports it.
  • 🧮 RAM manager (root). Real per-process PSS/USS from smaps_rollup, safe force-stop of a heavy app behind a server-side deny-list (system-critical processes are protected), and a genuine Clear cached RAM (drop_caches + compact) — the honest "free RAM", not a fake booster.

Why root helps AI: Android's phantom-process killer SIGKILLs a CPU-heavy inference child the instant it spikes; Kelvin launches its engines as a root-owned process that survives, and holds AI-Sustained clocks so throughput stays flat. Everything degrades gracefully without root — chat and images still run, you just lose the governor + full RAM manager.

🧩 Two planes, one product

A root module can't draw a UI; an app can't write /sys. So Kelvin is split, and the two halves talk over a root-owned abstract AF_UNIX socket (@kelvin, line-delimited JSON):

  • kelvind — a tiny (~31 KB) native C daemon in a Magisk/KernelSU/APatch module: the workload detector, profile engine, safety layer, and per-SoC path providers.
  • Kelvin app — a Kotlin + Compose companion: floating HUD (FPS, clocks, temps, tokens/sec, RAM), one-tap profiles, per-app rules, a safety panel, and launcher-icon hide/show. It renders what the daemon reports and sends it commands — it never touches /sys.

See docs/architecture.md and the socket contract in protocol/README.md.

📦 Repository layout

kelvin/
├── daemon/     native C governor (kelvind) + RAM manager + per-SoC providers   ← the core
├── module/     Magisk/KernelSU/APatch packaging
├── app/        Kotlin + Compose companion — HUD, dashboard, per-app profiles, safety,
│               AI studio (local chat + image gen), RAM manager
├── protocol/   daemon↔app control-socket contract
├── docs/       architecture · safety · SoC matrix · ai-engine · tooling
├── scripts/    build-daemon.sh · build-sd.sh (NDK cross-compile)
└── .github/    CI: daemon build · app build · tag → signed release

⚙️ How it works

Each ~5 Hz tick, the daemon: reads sensors → detects the workload (foreground app + a /proc scan for inference-engine signatures) → runs the safety interlock → resolves a profile (with hysteresis to avoid clock thrash) → applies only safe, reversible knobs (cpufreq scaling_min/max, GPU devfreq min/max) → publishes stats to the app. Full write-safety rules: docs/safety.md.

On-device finding: the vendor thermal-engine continuously rewrites scaling_max, so max-caps are best-effort — raising the floor (scaling_min) is the authoritative lever, which is exactly why the AI-Sustained curve holds.

📲 Install

  1. Download kelvin.zip from Releases.
  2. Flash it in Magisk / KernelSU / APatch Manager.
  3. Reboot.
  4. (Recommended) install the companion app: grab Kelvin-<version>.apk from the same release and open it. It's signed and offline — no Play Store, no internet permission.

Requires root (Magisk 20.4+, KernelSU, or APatch). Fully systemless and reversible — disable or remove the module to restore stock.

🚀 Using the Kelvin app

  1. Onboarding. On first launch Kelvin checks that the root daemon is reachable (kelvind detected — you're linked), then walks you through granting the display-over- other-apps permission (for the HUD) and the notification permission.
  2. Dashboard. See live skin / SoC / GPU temperature, thermal headroom against the ceiling, and per-cluster clocks. Leave Auto-Switch on to let the daemon pick the profile from the detected workload, or tap Game / AI-Sustained / Balanced / Battery to pin one.
  3. Floating HUD. From the HUD tab, launch the overlay: a draggable, snap-to-edge strip of FPS · clocks · temps · tokens/sec · RAM. Tap it to toggle compact/expanded; tune opacity, corner, refresh rate, and which stats show.
  4. Per-app profiles. In Apps, assign a profile to any package — it auto-loads whenever that game or your llama.cpp front-end comes to the foreground.
  5. Safety. View the bootloop-watchdog / interlock status, lower the skin-temp ceiling within the daemon's hard limit, and one-tap Restore stock.
  6. AI studio (AI tab). Tap Add model to download a GGUF chat model or a Stable Diffusion image model (or paste a HuggingFace link). Open a model to chat (streaming, saved history), or the Image studio to pick a compute backend (Auto / GPU / CPU), Load the model once, then Generate — save to Photos when you like it. RAM tab: stop a heavy app or clear cached RAM.
  7. Hide the icon (Settings). Kelvin can drop its launcher icon; reopen it with the Quick Settings tile or the dialer secret code *#*#5358#*#*.

🔨 Build

Toolchain setup (Ubuntu): docs/tooling.md.

Daemon (module):

export ANDROID_NDK_HOME=/path/to/ndk
bash scripts/build-daemon.sh          # → module/bin/{arm64-v8a,armeabi-v7a}/kelvind
cd module && zip -r ../kelvin.zip .   # package (CI does this on a v* tag)

Host sanity build (no NDK): gcc -std=c11 -D_GNU_SOURCE -Wall -Wextra -Idaemon/include daemon/src/*.c daemon/soc/*.c -o kelvind.

App:

cd app && ./gradlew assembleDebug     # or assembleRelease (signed when a keystore is present)

AI engine binaries (bundled in the APK, git-ignored + CI-built like kelvind): the chat engine is llama.cpp's llama-server and the image engine is stable-diffusion.cpp's sd-server. Reproduce the image one with scripts/build-sd.sh [cpu|vulkan]app/src/main/jniLibs/arm64-v8a/ libstable-diffusion-server.so.

Tag a version (git tag v0.6.0 && git push --tags) and CI cross-compiles both ABIs, packages kelvin.zip, builds a signed Kelvin-<version>.apk, and publishes the GitHub Release.

🖥️ Supported hardware

v1 (now) Qualcomm Snapdragon — 8 Gen 2 (SM8550; RedMagic 8/8S Pro test bench) and 8 Elite Gen 5.
v2 (roadmap) MediaTek (Dimensity 9500), Samsung Exynos (2600 + HPB), gaming-phone fans (RedMagic/ROG/Legion).

On unsupported SoCs the daemon runs read-only (telemetry only) — it never guesses write paths. Full targeting map: docs/soc-matrix.md.

🛡️ Safety

Kelvin runs as root and writes /sys. It enforces an absolute skin/junction/battery ceiling, backs up stock config before the first write, restores it on exit or thermal interlock, and holds stock config for a boot if the previous boot looked unstable. It never writes emul_temp, never disables a critical thermal zone, and never removes the last software thermal layer. Read docs/safety.md before touching write paths.

🤝 Contributing

Confirm or request your chipset via the device-support template (include the sysfs probe). New SoCs are drop-in providers — see docs/soc-matrix.md.

📄 License

MIT © 2026 Abdul Moez (@Anonym0usWork1221). See LICENSE.

⚠️ Kelvin changes CPU/GPU/thermal behaviour on rooted devices. It ships extensive safeguards, but you run it at your own risk.

Keywords: on-device AI · local LLM · offline AI chat · llama.cpp · GGUF · on-device Stable Diffusion · stable-diffusion.cpp · local image generation · Magisk module · KernelSU · APatch · AI thermal governor · CPU/GPU frequency scaling · sustained inference · gaming performance · FPS boost · tokens/sec · Snapdragon 8 Gen 2 / 8 Elite · Adreno · Hexagon NPU · QNN · rooted Android · Android RAM manager · drop_caches · floating performance HUD · Kotlin Jetpack Compose.

About

AI-aware thermal governor + gaming performance engine for rooted Android. Sustains on-device LLM inference (llama.cpp, ONNX, QNN) and maximizes game FPS by safely tuning CPU/GPU/thermal. Magisk/KernelSU/APatch · Snapdragon-first.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages