Skip to content

check-ubuntu-2604-lemond: --gpu keeps the render GID, and the HRX0 check reads the backend argv - #737

Merged
bong-water-water-bong merged 2 commits into
mainfrom
1bit/u2604-check-gpu-render-gid
Nov 1, 2026
Merged

bong-water-water-bong merged 2 commits into
mainfrom
1bit/u2604-check-gpu-render-gid

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

scripts/check-ubuntu-2604-lemond.sh … --gpu could not pass on Strix Halo before this: the load returned 500 and lemond.log said

[Info] (Process) 1bit serve: memory: need 1.31 GiB … at ctx 4096, free 35.42 GiB
[Error] (Process) error while handling argument "--device": invalid device: HRX0
[Error] (WrappedServer) llama-server process has terminated

Two separate bugs, both in the harness (the engine and Lemonade were fine: the same package ran on HRX0 on the host twice tonight at 277 / 290 tok/s).

1. --group-add is lost at runuser, so /dev/kfd cannot be opened

--group-add <host render gid> reaches the container main process, but the script starts lemond with runuser -u lemonade -- …, and runuser resets the supplementary groups to the image's /etc/group — where stock ubuntu:26.04 has no render group at all. Measured in a container:

--group-add 990,44:  id                                  -> groups=0(root),44(video),990(990)
runuser -u lemonade -- id                                -> groups=1001(lemonade)          ← 990 gone
setpriv --reuid lemonade --regid 1001 --groups 990,44 -- id -> groups=1001(lemonade),44(video),990(990)

So lemond and its llama-server ran without GID 990, could not open /dev/kfd (crw-rw---- root:render), HSA never initialised, libggml-hrx registered no device, and llama-server rejected --device HRX0. Fix: the --gpu branch now passes the host render/video GIDs into the container (-e RENDER_GID=… -e VIDEO_GID=…) and starts lemond with setpriv --reuid lemonade --regid "$(id -g lemonade)" --groups "$RENDER_GID,$VIDEO_GID" -- (no --init-groups: setpriv refuses it together with --groups, exit 1 — that cost one iteration). The no-GPU path still uses runuser, unchanged.

2. The final HRX0 assertion read the wrong place

It grepped /tmp/lemond.log for HRX0, but 1bit serve logs the memory it checked and not the device, so the check failed on a run that had in fact reached HRX0. It now reads the backend argv (/proc/<pid>/cmdline) and requires --device HRX0 there.

Proof (same command, same box, after the patch)

== lemond
listed: Check-HRX llamacpp-hrx
{"checkpoint":"local/check-GGUF:Qwen3-0.6B-Q4_K_M.gguf",…,"recipe":"llamacpp-hrx","status":"success"}
reply: 2 + 3 equals **5**.
== what lemond started
/opt/1bit/hrx/llama/bin/llama-server -m /var/lib/lemonade/.cache/…/Qwen3-0.6B-Q4_K_M.gguf --ctx-size 4096
    --device HRX0 --port 8001 --jinja --metrics --parallel 1 -ngl 99 --cache-reuse 256
GGML_HRX_REPORT=1
GGML_HRX_STRICT=1
IREE_HAL_AMDGPU_LIBHSA_PATH=/opt/rocm-therock/…/libhsa-runtime64.so.1
[Info] (Telemetry) Inference completed: model=Check-HRX, tokens=33 (in=19, out=14), ttft=0.26s, tps=114.57
PASS

Package under test: lemonade-onebit-rc-2026-10-31c (lemond 2026.46.0~5.ef0f3b49) with its 1bit/ as the engine package; PPA lemond 2026.44.1~26.04; model unsloth/Qwen3-0.6B-GGUF:Q4_K_M; kernel 7.3.0-rc4-1bit-perfopt+, ROCm SDK in /opt/rocm-therock. The no-GPU path (CPU stand-in) still passes with the patch.

Note for #715: this run is the shipped packaging's behaviour, i.e. 1bit serve in auto CWSR placement, and amdgpu.cwsr_enable=0 here, so the backend gets no HSA_USE_SVM=0 … trio — it completed fine at ctx 4096, but a longer soak under SVM is exactly what #715 is about; the script does not set the trio and I did not add it (that is the serve-default decision, not the harness's).

…eck reads the backend argv

The --gpu path could not work on Strix Halo. On 2026-10-31, with the shipped package
(lemond 2026.46.0~5.ef0f3b49, engine 1bit/ from rc-2026-10-31c):

    == lemond
    listed: Check-HRX llamacpp-hrx
    [Info] (Process) 1bit serve: memory: need 1.31 GiB ... at ctx 4096, free 35.42 GiB
    [Error] (Process) error while handling argument "--device": invalid device: HRX0
    [Error] (WrappedServer) llama-server process has terminated

Two separate bugs, both in the harness:

1. --group-add puts the host render GID (990 here) on the container main process, but the
   script starts lemond with runuser -u lemonade, and runuser resets the supplementary
   groups to the image /etc/group - where stock ubuntu:26.04 has no render group at all.
   Measured in the container:

       --group-add 990,44: id            -> groups=0(root),44(video),990(990)
       runuser -u lemonade -- id         -> groups=1001(lemonade)
       setpriv --reuid lemonade --regid 1001 --groups 990,44 -- id
                                         -> groups=1001(lemonade),44(video),990(990)

   So lemond and its llama-server ran without GID 990, could not open /dev/kfd
   (crw-rw---- root:render), HSA never came up, libggml-hrx registered no device and
   llama-server rejected --device HRX0. The --gpu branch now passes the host render and
   video GIDs into the container and starts lemond with setpriv (without --init-groups:
   setpriv refuses it together with --groups). The no-GPU path still uses runuser.

2. The final check grepped /tmp/lemond.log for HRX0, but 1bit serve logs the memory it
   checked and not the device, so the check failed on a run that had in fact reached HRX0.
   It now reads the backend argv (/proc/<pid>/cmdline) and requires --device HRX0 there.

Proven on this box, same command, after the patch:

    reply: 2 + 3 equals **5**.
    /opt/1bit/hrx/llama/bin/llama-server -m ... --ctx-size 4096 --device HRX0 --port 8001
        --jinja --metrics --parallel 1 -ngl 99 --cache-reuse 256
    GGML_HRX_REPORT=1
    GGML_HRX_STRICT=1
    IREE_HAL_AMDGPU_LIBHSA_PATH=/opt/rocm-therock/.../libhsa-runtime64.so.1
    Inference completed: model=Check-HRX, tokens=33 (in=19, out=14), ttft=0.26s, tps=114.57
    PASS

and the no-GPU path (CPU stand-in) still passes.
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 09b59be)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

715 - Partially compliant

Compliant requirements:

  • The PR ensures that the correct GIDs are passed to the lemond process, which allows it to access /dev/kfd and initialize HSA properly, thus avoiding the page fault issue described in the ticket.
  • The script now checks that the backend is started with --device HRX0 when --gpu is specified, ensuring the correct device is used.

Non-compliant requirements:

  • The PR does not implement automatic detection of unfavourable capability lines (XNACK enabled: NO / Coherent Host Access: FALSE) to set the trio itself.
  • The PR does not include logging of the libhsa path + sha256 in the HRX init line.
  • The PR does not address the release-runtime question by pinning the nightly or making libhsa selection explicit.

Requires further human verification:

  • Whether the engine automatically detects the unfavourable capability lines and sets the trio itself.
  • Whether the libhsa path and sha256 are logged in the HRX init line.
  • Whether the release-runtime question is fully resolved.
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect GID handling in container

The script modifies the launcher command to use setpriv instead of runuser to preserve the render and video GIDs when starting lemond. This is necessary because runuser resets supplementary groups to those defined in the container image's /etc/group, which does not include the render group. This change ensures that /dev/kfd can be accessed properly, allowing HSA to initialize and the HRX device to be registered.

launcher=(runuser -u lemonade --)
if [ "$GPU" = --gpu ]; then
    # --init-groups and --groups are mutually exclusive in setpriv (it exits 1 on both), and the
    # only supplementary groups this process needs are the two that open the GPU nodes.
    launcher=(setpriv --reuid lemonade --regid "$(id -g lemonade)" --groups "$RENDER_GID,$VIDEO_GID" --)
fi
Backend device check

The script now checks that the backend was started with --device HRX0 by examining the command line arguments of the llama-server process. This ensures that the correct device is being used when the --gpu flag is specified, which is crucial for avoiding the page fault issue described in the ticket.

# --gpu means the engine HRX llama-server on the GPU, i.e. the backend was started with --device HRX0
[ "$GPU" != --gpu ] || grep -q -- "--device HRX0" <<<"$cmdline" || { echo "FAIL: the backend was not started on HRX0"; fail=1; }

@bong-water-water-bong bong-water-water-bong added the tprs-ready TPRS: review verdict READY posted by the standing reviewer; merge gate satisfied label Nov 1, 2026

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

At 977e196b (+23 −5, scripts/check-ubuntu-2604-lemond.sh). A test-harness fix, and the mechanics check out.

The setpriv branch actually runs. The inner container script tests $GPU, and that variable is passed in — $runtime exec -e GPU="$gpu" … — so the --gpu path is not dead code. RENDER_GID/VIDEO_GID are passed with -e in the same opts the run uses, and are only consumed on that branch, so the pair is consistent. setpriv --groups taking the two GIDs (mutually exclusive with --init-groups, as the comment says) is the right shape for keeping the host GIDs that --group-add gave the container's main process, which runuser drops.

The new HRX0 assertion greps the right thing. grep -q -- "--device HRX0" against the backend's /proc/<pid>/cmdline — I can confirm that string is what the engine's launcher actually produces, because a live process on this box shows it:

.../hrx/llama/bin/llama-server -m .../Qwen3-8B... --device HRX0 -ngl 99 --jinja -c 8192 ...

so the check will match a working run rather than depending on lemond's log wording. Replacing a log grep with an argv grep is the correct call here, and the comment says why (1bit serve logs the memory it checked but not the device).

bash -n clean.

Not executed: the container run itself. It needs docker/podman, pulls ubuntu:26.04, installs the Lemonade PPA and the engine package, and starts a GPU-backed lemond — too heavy to start on this box right now under the memory rule while other lanes hold models, and not something I can validate from here. So this verdict covers the script's correctness (variables wired, branch reachable, grep target verified against a real argv, syntax), not that a PASS comes out of the far end. If you want that run gated before merge, it belongs in a systemd-run --user -p MemoryMax= unit when the box is quiet.

tprs-ready applied.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Persistent review updated to latest commit 09b59be

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

At 09b59be6 (rebased onto 4d566349 after #718 merged). Author patch unchanged — patch-id 092b8fd5ced7 at both heads — so my earlier verification carries whole: the setpriv branch is reachable ($runtime exec -e GPU="$gpu"), and the new --device HRX0 argv assertion matches what the engine really launches (I confirmed the string against a live llama-server cmdline on this box). bash -n clean.

tprs-ready stands. Still not executed: the container run itself (docker + Lemonade PPA + a GPU-backed lemond), which stays yours to gate when the box is quiet.

@bong-water-water-bong
bong-water-water-bong merged commit 06bed56 into main Nov 1, 2026
8 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/u2604-check-gpu-render-gid branch November 1, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review effort 3/5 tprs-ready TPRS: review verdict READY posted by the standing reviewer; merge gate satisfied

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant