Skip to content

gufo: the container's logs use the host time zone (TZ, read-only zoneinfo mount) - #158

Open
smfworks wants to merge 19 commits into
jayleaton:mainfrom
smfworks:upstream/gufo-host-tz
Open

smfworks wants to merge 19 commits into
jayleaton:mainfrom
smfworks:upstream/gufo-host-tz

Conversation

@smfworks

Copy link
Copy Markdown
Contributor

Stacked on #155 (ROCm Whisper, pinned Gufo; that PR stacks on #154). tools/gufo exists only there. Until #155 merges, the diff here includes it; review the last commit, "gufo: the container's logs use the host zone". It is independent of the scheduler and /v1/status PRs. (If you'd rather, this can go into #155 as one more commit.)

Gufo's container logs were always in UTC, while the daemon's and the other workers' logs use the host clock, so lining up a Gufo log with the router's meant converting by hand.

  • serve.sh passes TZ into the container. It takes $TZ, else /etc/timezone, else the zone named by the /etc/localtime link. Only a zone name gets through ([A-Za-z0-9_+/-]); anything else falls back to UTC, so a value can't turn into another podman argument.
  • The pinned image ships no zone database, so TZ alone isn't enough. When the host has /usr/share/zoneinfo, it is mounted read-only at the same path (GUFO_ZONEINFO overrides the host path). Without one, the container stays on UTC as before.
  • README and the script header document both.

Checks run locally:

  • bash tools/gufo/test_serve.sh: 13 passed, 0 failed (8 on the base branch). New checks:
    • podman receives the host TZ
    • the zoneinfo directory is mounted read-only when it is present and left off when it is missing
    • a zone name is still passed when TZ is unset
  • bash -n tools/gufo/*.sh
  • git diff --check

Hardware: deployed on AMD Strix Halo (gfx1151), 128 GB unified memory (ROCm, podman).

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).
@jayleaton

Copy link
Copy Markdown
Owner

Randy reviewed the scoped commit (container logs use the host time zone) and found nothing to change. Zoneinfo is mounted read-only, a missing directory just leaves the mount out, and the 13 Gufo tests pass. I'll approve and merge it once #155 lands (it still has the serve.sh zombie-watcher blocker) and this branch is rebased or has main merged in.

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

@jayleaton jayleaton left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Round 3: the TZ change is safe and in scope. All 16 Gufo checks pass, including host TZ forwarding, the read-only zoneinfo mount and delayed-reap cleanup.

Blocking: .github/workflows/ci.yml:35. This inherits #155's CI conflict. Please restack this commit onto main once #155 lands.

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.

2 participants