Skip to content

armgit / PS5LM

Public Imported from GitHub
0

llama.cpp on a jailbroken PS5: run any GGUF model natively on the console, starting with Qwen 3.8

Fork README with credits, screenshots and versioning; v0.2.0

Abhiramedda743c9957
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..803cb5f
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,33 @@
+# Changelog
+
+Versions follow [semver](https://semver.org). The app's version is set in
+`ps5/app/version.hpp` and shown on the dashboard; each release is tagged
+`v<version>` and ships `ps5lm-app-v<version>.zip` (see `scripts/release-app.sh`).
+v0.1.x are the upstream payload releases by cobanov.
+
+## [Unreleased]
+
+## [0.2.0] - 2026-10-10
+
+First release of the native app (title PPSA99581), from this fork.
+
+### Added
+- Native PS5 app running llama-server on the GPU through ggml-vulkan and RADV,
+ with an 11.44 GiB unified device heap.
+- Dashboard on the TV (ps5-homebrew-ui): generation speed, GPU busy, CPU use,
+ memory pool, GPU memory split, session, context and model tiles.
+- Model library with internal storage and USB drive sections; models load
+ straight from USB.
+- Planner that picks context length and KV cache type for the memory free.
+- Sampling presets for Qwen 3.5/3.6/3.8, Gemma 4, gpt-oss, Granite, Nemotron,
+ Mistral and Llama.
+- Model switching by restarting the app (in-place unload leaks GPU memory).
+- `scripts/ps5lm-app.sh` to drive the app from a PC, and the version on the
+ dashboard and in the log.
+
+### Fixed
+- Unloading during a reply no longer hangs the app: it waits at most 10 s for
+ llama-server before restarting.
+
+### Changed
+- A plain launch loads no model and opens the library.
diff --git a/README.md b/README.md
index 15af440..80b6a6c 100644
--- a/README.md
+++ b/README.md
@@ -1,20 +1,80 @@
+<p align="center"><img src="docs/media/app/icon.png" width="128" alt="PS5LM app icon"></p>
+
# PS5LM
-**llama.cpp on a jailbroken PlayStation 5.** Run any GGUF language model on the console itself, first on its Zen 2 CPU, then on its GPU.
+**llama.cpp on a jailbroken PlayStation 5, on its GPU.** Run GGUF language models on the console itself, from a native app with a dashboard on the TV.
+
+> **This is a fork.** PS5LM was created by **[Mert Cobanov](https://github.com/cobanov)** ([cobanov/PS5LM](https://github.com/cobanov/PS5LM), [ps5lm.cobanov.dev](https://ps5lm.cobanov.dev)): the llama.cpp port, the payload, its model library and the research all come from there. This fork, by [Abhiram](https://github.com/abhi245y), adds the **native GPU app** (v0.2.0 and later), offered back upstream in [cobanov/PS5LM#12](https://github.com/cobanov/PS5LM/pull/12).
<p align="center">
- <a href="https://ps5lm.cobanov.dev"><img src="docs/media/ps5lm-demo.gif" width="640" alt="Qwen3.5 0.8B answering in the PS5's browser, typed with a DualSense"></a>
+ <img src="docs/media/app/dashboard-generating.jpg" width="820" alt="The PS5LM dashboard on the TV while Gemma 4 generates">
</p>
-<p align="center"><b><a href="https://ps5lm.cobanov.dev">ps5lm.cobanov.dev</a></b>: the full demo video and how it works</p>
+## The native app
+
+A payload gets about 6 GiB of memory and no GPU; a native app (a title) gets the console's 12 GiB of direct memory and the GPU. The app runs llama-server with ggml's Vulkan backend on Mihawk-99's RADV port, with one 11.44 GiB device heap, and serves the chat at `http://<console IP>:8081` (llama.cpp's web UI and the OpenAI API).
+
+| Model (on the PS5 GPU) | Context | Generation |
+|---|---|---|
+| Qwen3.8-27B UD-Q2_K_XL (9.2 GiB) | 32k, q4_0 cache | 20.3 tok/s; a 7,775-token answer at 19.7 tok/s |
+| Qwen3.8-27B UD-IQ2_XXS (6.8 GiB) | 64k, q8_0 cache | 20.7 tok/s |
+| Gemma 4 E4B QAT q4_0 (4.8 GiB), from USB | 64k, q4_0 cache | 61 tok/s |
+| Llama 3.2 3B Instruct Q4_K_M (1.9 GiB), from USB | 64k, q8_0 cache | 124 tok/s |
+
+For comparison, the 27B on the CPU as a payload, streamed from disk, made about one token a minute.
+
+<table>
+ <tr>
+ <td><img src="docs/media/app/library.jpg" alt="The model library: internal storage and USB drive sections"></td>
+ <td><img src="docs/media/app/dashboard-qwen.jpg" alt="The dashboard with Qwen 3.8 27B UD-Q2_K_XL loaded"></td>
+ </tr>
+ <tr>
+ <td align="center">The model library at launch</td>
+ <td align="center">Qwen 3.8 27B loaded</td>
+ </tr>
+</table>
+
+- **Dashboard:** generation speed, how busy the GPU is, CPU use, the memory pool and how the model, KV cache and the rest split it, context in use, the loaded model, and load progress.
+- **Model library:** every `.gguf` in `/data/PS5LM/models` and in `PS5LM/models` on a USB drive, in two sections. Cross loads or unloads. A model on USB loads straight from the drive.
+- **Planner:** picks the longest context and the best KV cache type that fit the memory free, for each model.
+- **Presets:** sampling settings for Qwen 3.5/3.6/3.8, Gemma 4, gpt-oss, Granite, Nemotron, Mistral and Llama.
+
+### Install the app
+
+You need a jailbroken PS5 on firmware 7.00 to 13.60 with [ShadowMountPlus](https://github.com/drakmor/ShadowMountPlus) (it registers titles from `/data/homebrew`) and an FTP server such as [ftpsrv](https://github.com/ps5-payload-dev/ftpsrv).
+
+1. Download `ps5lm-app-vX.Y.Z.zip` from this fork's [releases](https://github.com/abhi245y/PS5LM/releases) and check it against its `.sha256`.
+2. Unzip it and copy the `PPSA99581` folder to `/data/homebrew/PPSA99581` over FTP. ShadowMountPlus adds **PS5LM** to the home screen.
+3. Copy a model to `/data/PS5LM/models`, or put it in `PS5LM/models` on a USB drive (exFAT).
+4. Start PS5LM, choose the model in the library, and open `http://<console IP>:8081` on a phone or computer once it says Ready.
-The first target is **Qwen 3.8** (27B, hybrid Gated DeltaNet attention), the newest open Qwen. No one has run it on a PS5 yet.
+Which models fit is in [docs/MODELS.md](docs/MODELS.md); anything llama.cpp runs works if the library shows LOAD.
-> **Status:** v0.1 is out. One payload, `ps5lm.elf`, opens a model library in the PS5's browser: download a model on the console, run it, chat. Small models for now (up to 1.6 GB, Qwen3.5 0.8B and 2B). See [docs/ROADMAP.md](docs/ROADMAP.md) and [docs/CONSOLE.md](docs/CONSOLE.md).
->
-> **New: Qwen 3.8 27B on the GPU.** A native app (`ps5/app`) runs llama.cpp's Vulkan backend on Mihawk-99's RADV port with the console's 12 GiB of direct memory: Qwen3.8-27B UD-IQ2_XXS answers at 9 to 21 tok/s, chat at `http://<console IP>:8081`. Built from source for now (below).
+### What it took
+
+The full notes are in [docs/CONSOLE.md](docs/CONSOLE.md). In short:
+
+- **CPU first:** Qwen 3.8 27B ran as a payload on the Zen 2 CPU, streamed from disk at about a token a minute: proof that llama.cpp works on the console, and that the GPU was needed.
+- **A title, not a payload:** llama-server linked into an fSELF `eboot.bin` with a clean-room `libc.prx`, registered through ShadowMountPlus. Titles may not `exit()`, have some libc imports resolve to nothing, and need a working `getaddrinfo`, `accept4` and `HOME`; each was found by a crash.
+- **The GPU:** ggml-vulkan on [PS5_Vulkan](https://github.com/mihawk-99/PS5_Vulkan)'s RADV with no Vulkan loader, and RADV's unified heap for 11.44 GiB in one heap.
+- **The screen:** [ps5-homebrew-ui](https://github.com/blackbearreloaded/ps5-homebrew-ui) through ps5-opengl, in the same process as RADV (the two Mesa builds share 4,399 symbol names, so the GL stack is linked with only its API visible).
+- **Switching models:** unloading in place leaves about 5 GiB of the pool held, so the app restarts itself for each switch.
+
+### Versions and branches
+
+- Releases follow [semver](https://semver.org): tags `vX.Y.Z`, notes in [CHANGELOG.md](CHANGELOG.md), version set in `ps5/app/version.hpp` and shown on the dashboard. v0.1.x are upstream's payload releases.
+- `main` is this fork's integration branch. Each feature is built on its own branch (`feature/...`, `docs/...`) and merged into `main`; the plans are in [docs/plans](docs/plans).
+- `native-gpu-app` is the branch of the upstream pull request.
+
+## The payload (upstream v0.1)
+
+The original PS5LM is a payload that needs no install: one `ps5lm.elf` opens a model library in the PS5's browser, for small models (up to 1.6 GB, Qwen3.5 0.8B and 2B). See [docs/ROADMAP.md](docs/ROADMAP.md) and [docs/CONSOLE.md](docs/CONSOLE.md).
+
+<p align="center">
+ <a href="https://ps5lm.cobanov.dev"><img src="docs/media/ps5lm-demo.gif" width="640" alt="Qwen3.5 0.8B answering in the PS5's browser, typed with a DualSense"></a>
+</p>
-## Install
+### Install the payload
You need a PS5 you own on firmware 7.00 to 13.60, jailbroken, with a payload loader (Payload Manager from WebKit Autoloader, or elfldr on port 9021).
@@ -58,7 +118,7 @@ brew install llvm@21 lld socat cmake ninja
# Debian / Ubuntu
sudo apt install clang-18 lld-18 socat cmake ninja-build
-git clone --recursive https://github.com/cobanov/PS5LM
+git clone --recursive https://github.com/abhi245y/PS5LM
cd PS5LM
scripts/setup-sdk.sh
source scripts/env.sh
@@ -88,7 +148,7 @@ scripts/run.sh llama-cli -m /data/PS5LM/models/model.gguf -p "Hello from a PS5"
scripts/run.sh llama-server -m /data/PS5LM/models/model.gguf --host 0.0.0.0 --port 8081
```
-## The GPU app
+## Building the GPU app
The app links llama.cpp with ggml-vulkan against [PS5_Vulkan](https://github.com/mihawk-99/PS5_Vulkan)'s RADV build. Set up PS5_Vulkan and its forks in `.deps/src` (`PS5_Vulkan`, `PS5_Mesa` and `PS5_PayloadSDK` at the revisions PS5_Vulkan pins), then:
@@ -114,6 +174,7 @@ The app closes itself on request (`/data/PS5LM/quit`), so nothing is killed whil
## Credits
+- **[Mert Cobanov](https://github.com/cobanov)**, who created PS5LM ([cobanov/PS5LM](https://github.com/cobanov/PS5LM)): the llama.cpp port to the PS5, the payload and its library, the build scripts and the research this fork builds on.
- [llama.cpp / ggml](https://github.com/ggml-org/llama.cpp), which does the actual work.
- [PS5_Vulkan](https://github.com/mihawk-99/PS5_Vulkan) (Mihawk-99) for RADV on the PS5, and [ps5-homebrew-ui](https://github.com/blackbearreloaded/ps5-homebrew-ui), [ps5-opengl](https://github.com/blackbearreloaded/ps5-opengl) and ps5-homebrew-dev-protocol (BlackBearReloaded) for the app's screen and tooling.
- [ps5-payload-dev](https://github.com/ps5-payload-dev) (John Törnblom) for the SDK and the ELF loader.
diff --git a/docs/media/app/dashboard-generating.jpg b/docs/media/app/dashboard-generating.jpg
new file mode 100644
index 0000000..5197028
Binary files /dev/null and b/docs/media/app/dashboard-generating.jpg differ
diff --git a/docs/media/app/dashboard-qwen.jpg b/docs/media/app/dashboard-qwen.jpg
new file mode 100644
index 0000000..241598c
Binary files /dev/null and b/docs/media/app/dashboard-qwen.jpg differ
diff --git a/docs/media/app/icon.png b/docs/media/app/icon.png
new file mode 100644
index 0000000..9ff369b
Binary files /dev/null and b/docs/media/app/icon.png differ
diff --git a/docs/media/app/library.jpg b/docs/media/app/library.jpg
new file mode 100644
index 0000000..d5306ee
Binary files /dev/null and b/docs/media/app/library.jpg differ
diff --git a/ps5/app/dashboard.cpp b/ps5/app/dashboard.cpp
index 9682744..3fa955c 100644
--- a/ps5/app/dashboard.cpp
+++ b/ps5/app/dashboard.cpp
@@ -4,6 +4,7 @@
// ps5-homebrew-ui's src/concepts/dashboard.cpp ("Pulse Dashboard",
// BlackBearReloaded, GPL-3.0-or-later); the tiles and their data are PS5LM's.
#include "dashboard.hpp"
+#include "version.hpp"
#include "ui/glyphs.hpp"
@@ -537,7 +538,7 @@ void Dashboard::draw_header(gfx::DrawList & list) const {
list.push_opacity(in);
const float y = 124 - 10.0f * (1.0f - in);
const float w = ui::text(list, fonts_.display, "PS5LM", kGridX - 3, y, 56, kInk);
- std::string sub = "Chat at " + live_.address;
+ std::string sub = "v" PS5LM_VERSION " \xC2\xB7 Chat at " + live_.address;
ui::text(list, fonts_.regular, sub, kGridX + w + 24, y, 24, kInk.with_alpha(kMuted));
const char * word = state_word(live_.state);
diff --git a/ps5/app/main.cpp b/ps5/app/main.cpp
index bd283a8..f46ef05 100644
--- a/ps5/app/main.cpp
+++ b/ps5/app/main.cpp
@@ -39,6 +39,7 @@
#include "ggml-backend.h"
#include "model_plan.hpp"
#include "stats.hpp"
+#include "version.hpp"
#include <ps5platform/heap.h>
#include <ps5platform/kernel.h>
@@ -333,7 +334,17 @@ struct Models {
return;
}
llama_server_terminate();
- pthread_join(server, nullptr);
+ // With a reply in flight llama-server can stay inside its HTTP thread
+ // pool forever (unload during generation hung the app). We are about
+ // to be replaced by LoadExec anyway, so wait 10 s at most.
+ for (int i = 0; i < 100 && g_server_rc < 0; ++i) {
+ usleep(100 * 1000);
+ }
+ if (g_server_rc >= 0) {
+ pthread_join(server, nullptr);
+ } else {
+ std::printf("ps5lm-app: llama_server did not return in 10 s; restarting anyway\n");
+ }
server_started = false;
running.clear();
log_memory("after unloading");
@@ -362,6 +373,7 @@ int main(int, char **) {
if (std::freopen(kLog, "a", stderr) != nullptr) {
setvbuf(stderr, nullptr, _IONBF, 0);
}
+ std::printf("ps5lm-app: version " PS5LM_VERSION "\n");
// One device-local heap over the whole pool (RADV splits an APU's 2/3 to
// 1/3), and a HOME for llama.cpp, which throws without one.
setenv("radv_enable_unified_heap_on_apu", "true", 1);
diff --git a/ps5/app/version.hpp b/ps5/app/version.hpp
new file mode 100644
index 0000000..f521482
--- /dev/null
+++ b/ps5/app/version.hpp
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+#pragma once
+
+// The app's version, semver. The one place it is set: scripts read it from
+// here (scripts/release-app.sh), and git tags are v<this>. Bump it with an
+// entry in CHANGELOG.md.
+#define PS5LM_VERSION "0.2.0"
diff --git a/scripts/release-app.sh b/scripts/release-app.sh
new file mode 100755
index 0000000..477aaf5
--- /dev/null
+++ b/scripts/release-app.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+# Packages the built app for a release: build/release/ps5lm-app-v<version>.zip
+# holding the PPSA99581 title folder, plus its sha256. The version comes from
+# ps5/app/version.hpp; the git tag is v<version>.
+#
+# scripts/build-app.sh && scripts/release-app.sh
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+set -euo pipefail
+
+root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
+version=$(sed -n 's/^#define PS5LM_VERSION "\(.*\)"$/\1/p' "$root/ps5/app/version.hpp")
+title=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["titleId"])' "$root/ps5/app/sce_sys/param.json")
+app="$root/build/app-ps5/title/$title"
+out="$root/build/release"
+zip="$out/ps5lm-app-v$version.zip"
+
+[ -f "$app/eboot.bin" ] || { echo "release-app: build it first (scripts/build-app.sh)" >&2; exit 1; }
+grep -q "^## \[$version\]" "$root/CHANGELOG.md" || { echo "release-app: CHANGELOG.md has no [$version] entry" >&2; exit 1; }
+mkdir -p "$out"
+rm -f "$zip"
+(cd "$(dirname "$app")" && zip -qr -X "$zip" "$title")
+(cd "$out" && sha256sum "$(basename "$zip")" > "$(basename "$zip").sha256")
+echo "release-app: $zip ($(du -h "$zip" | cut -f1))"
+cat "$zip.sha256"