Skip to content

gufo: send the container's output only to the tool's log, not also to the journal - #166

Draft
smfworks wants to merge 22 commits into
jayleaton:mainfrom
smfworks:upstream/gufo-log-driver-none
Draft

smfworks wants to merge 22 commits into
jayleaton:mainfrom
smfworks:upstream/gufo-log-driver-none

Conversation

@smfworks

Copy link
Copy Markdown
Contributor

Stacked on #158 (same file). Draft: review #158 first.

Problem

tools/gufo/serve.sh runs podman run attached, so the container's stdout and stderr already reach the daemon, which copies them into the tool's log. On a systemd host, podman's default log driver is journald, so every line was also written to the journal, with stderr at priority 3. Each worker message appeared twice, once as an error, which makes journalctl -p err noisy and misleading.

Change

  • podman run --log-driver=none: the attached output is unchanged, and the journal copy is gone. podman logs has nothing; the tool's log has everything, as before.
  • A --log-driver passed to serve.sh among its podman options comes later on the command line and wins, so an operator who wants journald back can have it.
  • The header comment explains why.

Tests

  • tools/gufo/test_serve.sh: podman run gets --log-driver=none, and a caller's --log-driver comes after it. 15 passed, 0 failed (13 before).
  • On a Strix Halo host with podman's default journald driver, an attached container's stderr line was printed and also landed in the journal at priority 3. With --log-driver=none it was printed and the journal had none.
  • bash -n and git diff --check are clean; shellcheck warnings are unchanged.

lib.sh: when nvidia-smi sees no GPU, hw_gpu/hw_driver/hw_vram/hw_summary read the
first amdgpu card (sysfs) and rocminfo (marketing name, gfx target), hw_rocm the ROCm
version, hw_gtt/hw_gtt_used the GTT pool an APU's GPU maps. hw_match gains optional
hardware.min_rocm, hardware.gfx and hardware.min_gtt_gib. The NVIDIA and macOS paths
are unchanged.

doctor.sh: the free-memory warning reads hardware.min_free_gib (default 88, as before)
and, on AMD, shows GTT in use and AMD-side hints; a deploy.service of
"systemd-transient" (systemd-run --user) is checked by is-active instead of a unit file.
…he CPU

tools/install/test_amd.sh runs lib.sh's detection against four recorded hosts in
tests/fixtures/amd (a sysfs tree, rocminfo output, ROCm's version file and
nvidia-smi answers; no GPU needed):
- strix-halo: Radeon 8060S (gfx1151) APU, 96 GiB GTT, a 4 GiB carve-out that is not
  VRAM, connector entries (card1-DP-1) beside the card
- discrete: an Intel CPU and iGPU beside a Radeon RX 7900 XTX with real VRAM
- nvidia: an NVIDIA GPU and an AMD card on one box; the NVIDIA path wins and says
  what it said before AMD detection existed (checked against main's lib.sh)
- none: no GPU

The fixtures caught one bug: amd_name took the first rocminfo Marketing Name that
was not an AMD CPU, so an Intel CPU agent named the GPU. It now takes the first
agent whose Device Type is GPU. LR_SYSFS (default /sys) points the sysfs reads at
a fixture. CI runs the script.
…rver

tools/speech/openai_audio/worker.py serves speech (POST /v1/audio/speech, raw PCM
streamed into speech.wav) and transcription (POST /v1/audio/transcriptions ->
transcript.json) through a model's own server, which it starts from options.server
({port}, {id}, {weights}) and stops on exit, as openai_server does for chat; or an
existing options.url. Standard library only. Server 4xx -> invalid_request_error,
503/unreachable -> service_unavailable; 64-bit seeds are folded to 32 bits.
test_worker.py runs it against a fake server (no GPU).
Review of 944f585: transcription replaced the requested temperature with 0 and
ignored timestamp granularity, so temperature=0.7 with timestamps=word succeeded
with no words.

- temperature, language and prompt go to the server as asked. A server that cannot
  honour one refuses it, and the caller gets that 400 with the server's reason
  (Gufo's Qwen3-ASR: "supports temperature 0 only").
- options.timestamps lists the granularities the server returns ([] by default).
  A request for a listed one asks for verbose_json with that
  timestamp_granularities[] (word also asks for segment when listed), and a reply
  without them is a server_error, never a transcript missing what was asked.
- word not listed is refused (invalid_request_error) before the server is asked.
  segment not listed keeps the whole clip as one segment, since the daemon asks for
  segments for every verbose_json, srt and vtt reply.

The fake server now records each request's form fields: 23 checks (was 8),
covering forwarding, refusals and both timestamp configurations. CI runs them.
…Strix deployment runs)

# Conflicts:
#	.github/workflows/ci.yml
tools/speech/whisper/rocm/{pyproject.toml,uv.lock}: the same worker and pins as the
Spark, with torch and triton-rocm from PyTorch's ROCm 7.2 index for x86_64 Linux AMD
GPUs. The existing lock is untouched. Measured on gfx1151: WER 4.09% on 73
LibriSpeech clips, 17x real time.
serve.sh NAME PORT [podman opts] -- gufo serve ...: foreground, loopback-only, stops
the container on SIGTERM and waits so GPU memory is free; --replace clears leftovers;
video/render groups by name (keep-groups needs crun).
AMD Strix Halo (Radeon 8060S, gfx1151, 96 GiB GTT): Qwen3.8 Flash-Next chat via Gufo
(Q4 + MTP) and llama.cpp (Q3 + MTP) as openai_server tools, Qwen3-TTS and Qwen3-ASR via
Gufo behind openai_audio, Whisper on ROCm. budget_bytes = GTT less 2 GiB. The daemon
runs as a transient systemd user unit (render/start/stop/status.sh); site files
override env.sh. Tested end to end: /v1 chat, /v1/audio, and the voice loop
(voice_e2e.py --smoke) passing with 1.2-1.4 s first audio on warm turns.
…as a GPU step

Review of 944f585:
- Torch wheel unhashed (whisper/rocm/uv.lock): PyTorch's index publishes no digest,
  so the wheel's sha256 (2ad8066c..., 6227849000 bytes) is added by hand. uv sync
  --locked refuses other bytes (checked with a one-digit change: "Hash mismatch").
  tools/install/check_hashes.py refuses any uv.lock or requirements*.txt artifact
  without a sha256; CI runs it over the checkout, and its tests.
- Gufo pinned by digest: tools/gufo/IMAGE is gufo-runtime:0.34.0@sha256:49b1fce4...
  (engine 2845939b, the build measured here). serve.sh refuses a reference without a
  digest unless GUFO_ALLOW_UNPINNED=1; the profile's step checks the pulled digest.
- Hugging Face weights by commit, every file by size and sha256: pins/*.json for
  Flash-Next Q4 and Q3 (f5d175de), Qwen3-TTS CustomVoice (0c0e3051) and Qwen3-ASR
  (7278e1e7). tools/install/hf_pinned.py downloads the manifest's files at its
  revision through hf (resumable) and verifies them; done is a stamp of the manifest
  plus a size check. The local copies on the test box verify against all four.
- GUFO_IMAGE reaches the workers: start.sh passes it (and GUFO_ALLOW_UNPINNED,
  GUFO_STOP_TIMEOUT when set) into the transient unit; env.sh defaults it from
  tools/gufo/IMAGE. deploy/strix-halo/test_start.sh runs start.sh with a stub
  systemd-run that gives the daemon only --setenv values and a stub podman that
  records the image: default, exported and site-file overrides, a digest-less
  refusal (11 checks; 3 pass against the old start.sh).
- gufo diagnose is its own step, gpu: true, so --no-gpu skips it; the image step only
  pulls and checks the digest.
- CI: bash -n over deploy/strix-halo/*.sh and tools/gufo/*.sh; the hash check,
  hf_pinned tests and the unit test.
The model's server no longer gets a session of its own (start_new_session):
it stays in the worker's process group, so the daemon's SIGKILL of that group
on abort or timeout takes it down too, and PR_SET_PDEATHSIG (SIGTERM) covers
the worker dying alone. Before, a hard kill left the server, and a Gufo
container behind it, holding the GPU. An unload now signals the server and
every process below it (/proc children) instead of its group.

Seed 0 was dropped by a truthiness check: a request's seed is sent whenever it
has one and send_seed is on.

Tests: SIGKILL of the worker's group mid-generation, the server is gone
(fails on the old worker: the server outlived it); the server receives seed 0;
no seed, none sent; send_seed false, none sent.
With the openai_audio worker's server now in the worker's process group, the
daemon's SIGKILL of that group (abort, timeout) kills serve.sh and the podman
client, but not the container: conmon runs it outside the group, and the
SIGTERM trap never runs. serve.sh starts a watcher in its own session that
removes this run's container, by its --cidfile id (never a later run's of the
same name), once the script is gone.

test_serve.sh (8 checks, stub podman whose container is outside the group):
SIGKILL of the group removes the container, by id, and the watcher cleans up;
SIGTERM still stops it through the trap; a run started right after a killed
one keeps its container. 3 of them fail on the old serve.sh. CI runs it.
serve.sh passes the host zone into the Gufo container ($TZ, else
/etc/timezone, else the /etc/localtime link; anything but a zone name falls
back to UTC). The image has no zone database, so TZ alone leaves its logs on
UTC: when the host has /usr/share/zoneinfo, it is mounted read-only
(GUFO_ZONEINFO overrides the host path).
serve.sh runs podman attached, so the container's output already reaches
the daemon, which copies it into the tool's log. On a systemd host podman's
default log driver (journald) also wrote every line to the journal, stderr
at priority 3: each worker message showed twice, and as an error.
--log-driver=none keeps the attached output and drops the journal copy.
A --log-driver passed to serve.sh comes later and wins.

Checked on a Strix Halo host: with the default driver an attached
container's stderr line lands in the journal at priority 3 and is printed;
with --log-driver=none it is printed and the journal has none.
ci.yml: keep this branch's steps after main's openai_audio step.
…cannot keep the container

The watcher polled serve.sh with kill -0, which succeeds on a zombie. If a
subreaper left serve.sh unreaped after a SIGKILL of the worker's group, the
container kept running until the reap. The watcher now reads the State:
line in /proc/<pid>/status and stops waiting on Z (or X); kill -0 remains
only where /proc is not mounted.

test_serve.sh: a parent that does not reap serve.sh for 60 s; after the
group SIGKILL serve.sh is a zombie and the container must be removed (by
its id) while it still is. 3 new checks; the old watcher fails 2 of them.
…ts a zombie serve.sh as gone) into upstream/gufo-host-tz

# Conflicts:
#	tools/gufo/test_serve.sh
…to this branch

# Conflicts:
#	tools/gufo/test_serve.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant