Skip to content

/health names the release, the backend and the GPU it serves on - #854

Merged
ashhart merged 2 commits into
ashhart:mainfrom
ThinkOffApp:health-version-backend
Oct 16, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
ThinkOffApp:health-version-backend

Conversation

@ThinkOffApp

Copy link
Copy Markdown
Contributor

What this changes

The open GET /health now also names the TensorFold version, the GPU backend and the GPU device. A monitor can then show which release runs on which GPU without a shell on the machine.

The server reads the three values once at startup. The version comes from the build. The backend is the built-in engine module's backends entry (metal or cuda). The device is the Metal system GPU, or the CUDA device that --device or TF_CUDA_DEVICE picks, read with cuDeviceGetName and no context.

The new keys come after the existing ones. The existing keys and their order do not change. The version is always named. A backend or device the binary does not know is left out: a backend module without deviceName reports its backend without a device, and a binary with no engine module names only the version. The parity test servers set no identity, so their bodies, and the frozen goldens, are unchanged. With keys configured, /health still sends only {"status": "ok"}.

The second commit moves the three values into one builder (zig/src/server/identity.zig) that the binary and the tests both call, and adds a socket test for the keyed body.

Receipt

Model: TensorFold/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-MLX-4bit, revision d9d758f. Machines: an Apple M5 Max with 128 GB (macOS 27.0.1) and an NVIDIA GB10 (Ubuntu 24.04, driver 580.178.04, CUDA 13.0).

  • Environment, with the TensorFold commit, MLX or PyTorch version, machine and GPU, checkpoint and revision: main at c7137bb (1.0.11) before, b2c75a9 (first commit) and 8884431 (second commit) after. The host tests and the first live run below are of these commits, built with -Dversion=1.0.11 and Zig 0.17.0; the earlier live runs name their own base. The Mac build is zig build native -Dcpu=apple_m1 with the macOS 27.0 SDK. The GB10 build is zig build native -Dsm=121 with nvcc 13.0. Native builds only, so no MLX or PyTorch.
  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false: not run. The change does not touch requests, lanes, drafts or sampling.
  • Decode speed before and after, from tools/bench_openai.py: not run, for the same reason.
  • Prompt speed before and after, from tools/prefill_cold.py: not run, for the same reason.
  • Tests run, with pass, fail and skip counts: below.
  • Not run, and why: ROCm/HIP, because as of 14 Oct 2026 main at c7137bb has no served HIP backend, and no AMD machine was available for this run. M1 to M4, because no such Mac was available for this run; the Mac binary is built for the M1 CPU target as usual. The speed and exactness runs above.

Host tests, on the M5 Max and the GB10, each from a fresh tree of the commit:

Command Machine c7137bb (main) 8884431 (this branch)
zig build test test-golden -Dcpu=apple_m1 M5 Max 1981 passed, 8 skipped, 0 failed; exit 0 1987 passed, 8 skipped, 0 failed; exit 0
test-golden, in the command above M5 Max 309 of 319 equal, 0 unexpected 309 of 319 equal, 0 unexpected
zig build test-cuda-host GB10 465 passed of 465; exit 0 468 passed of 468; exit 0
zig build test-golden GB10 309 of 319 equal, 0 unexpected; exit 0 309 of 319 equal, 0 unexpected; exit 0
zig build native -Dsm=121 GB10 builds; exit 0 builds; exit 0

The three new tests are in zig/src/server/health_test.zig. The Mac runs them in two test binaries, so its count grows by 6; the GB10 runs them once.
Two tests call the identity builder with stand-in engine modules (a GPU, no GPU found, no backend) and check the open body's keys in order. The third serves /health on a loopback socket with a key configured and a full identity, and checks the body is exactly {"status": "ok"} with and without a valid key, while /v1/models answers 401 without the key and 200 with it.
Each test fails on a broken variant, run once on the second commit before the rebase; the rebase changed neither commit's patch. The tests do not compile on main, which has no identity.zig. With the three new keys removed from the open body, or put before live, the two body tests fail. With the keyed path sending version, backend and device after its status, or with the keyed early return removed, the socket test fails. With the builder leaving out the version when there is no backend, the engine-less test fails.
zig fmt --check is clean on both commits. tools/zig/lean_check.py reports 527 problems on main at c7137bb and on this branch, all inherited; the changed and new files add none.

Live /health, model and machines as above. Each binary served the model with --parallel 1 --context 8192 for a minute, and /health was read three times. Every read on a machine gave the same body.

M5 Max, this branch at 8884431:

{"status": "ok", "model": "NVIDIA-Nemotron-3.5-Lightning-30B-A3B-MLX-4bit", "model_ids": ["NVIDIA-Nemotron-3.5-Lightning-30B-A3B-MLX-4bit"], "max_batch_size": 1, "warming": false, "memory": {}, "live": {"connections": 0, "waiting": 0, "decode_tokens_per_second": 0.0, "prefill_tokens_per_second": 0.0}, "version": "1.0.11", "backend": "metal", "device": "Apple M5 Max"}

The runs below were made before the rebase onto 1.0.11, on main at 1e76a70 and on the first commit's patch over it, built with -Dversion=1.0.10. The GB10 served the checkpoint's snapshot folder, so its served name is the revision. The second commit does not change the CUDA lookup, so the GB10 was not served again.

M5 Max, main at 1e76a70:

{"status": "ok", "model": "NVIDIA-Nemotron-3.5-Lightning-30B-A3B-MLX-4bit", "model_ids": ["NVIDIA-Nemotron-3.5-Lightning-30B-A3B-MLX-4bit"], "max_batch_size": 1, "warming": false, "memory": {}, "live": {"connections": 0, "waiting": 0, "decode_tokens_per_second": 0.0, "prefill_tokens_per_second": 0.0}}

GB10, main at 1e76a70:

{"status": "ok", "model": "d9d758fb83953437f7263256b0d96157e2a348b8", "model_ids": ["d9d758fb83953437f7263256b0d96157e2a348b8"], "max_batch_size": 1, "warming": false, "memory": {"active": 19966017136, "cache": 0, "peak": 19966017136}, "live": {"connections": 0, "waiting": 0, "decode_tokens_per_second": 0.0, "prefill_tokens_per_second": 0.0}}

GB10, the first commit over 1e76a70:

{"status": "ok", "model": "d9d758fb83953437f7263256b0d96157e2a348b8", "model_ids": ["d9d758fb83953437f7263256b0d96157e2a348b8"], "max_batch_size": 1, "warming": false, "memory": {"active": 19966017136, "cache": 0, "peak": 19966017136}, "live": {"connections": 0, "waiting": 0, "decode_tokens_per_second": 0.0, "prefill_tokens_per_second": 0.0}, "version": "1.0.10", "backend": "cuda", "device": "NVIDIA GB10"}

With an API key file configured, the first commit's binary over 1e76a70 on the M5 Max answered /health with {"status": "ok"}, with and without a valid key, and /v1/models without a key with 401. The socket test above now checks this on every run.

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.
  • No precision traded for speed. If the bits change, the description says which sums change and why.
  • Prompt processing is no slower than the last release.
  • The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.

The two unticked items were not measured. The change does not touch the token path or the prompt path.

The open /health adds `version`, `backend` and `device` after its existing keys, for example
"1.0.10", "metal" and "Apple M5 Max", or "cuda" and "NVIDIA GB10". The binary reads them once at
startup: the version from the build, the backend from the built-in engine module, and the name of
the GPU a serve opens (the Metal system device, or the CUDA device that --device or TF_CUDA_DEVICE
picks). A field that is not known is left out, so an engine-less build sends the same body as before,
and with keys configured /health still sends only {"status": "ok"}.
…ked over a socket

The version is always the build's, so a binary with no engine module names it too. The earlier commit
said such a build sends the same body as before; that holds only for the test servers, which set no
identity. The identity now comes from `of` in identity.zig. engines.zig calls it with the built-in
engine module, and the tests call it with stand-in modules: one with a GPU, one that finds no GPU, and
one with no backend, as native/none.zig declares it.

A new test serves /health over a loopback socket with a key configured and a full identity. With and
without a valid key the body is exactly {"status": "ok"}, while /v1/models answers 401 and 200, so the
gate is on and the key is valid. The API docs say the version is named whenever keys are off.
@ashhart

ashhart commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Thanks, @ThinkOffApp. Ready; we'll fix the test cleanup at landing.

At 8884431, zig/src/server/health_test.zig:193 stops waiting after five seconds even if connection threads remain alive, then the deferred server deinit frees their owner. A partial-request client can remain blocked for the 120-second read timeout. The connection count also increments inside the detached worker, so zero does not prove every spawned worker has started and finished.

We'll make cleanup cancel or join all connection workers before freeing the server, including timeout paths. The production identity refactor preserves the existing behavior, and keyed /health still returns only its status.

@ThinkOffApp

Copy link
Copy Markdown
Contributor Author

Thank you, @ashhart. Agreed on the cleanup: joining every connection worker before the server is freed is the right fix.

@ashhart
ashhart merged commit 8df3720 into ashhart:main Oct 16, 2026
4 checks passed
ashhart added a commit that referenced this pull request Oct 16, 2026
… so cuda.zig stays under 600 lines

#854's deviceName took native/cuda.zig to 607 lines. chip, deviceName, chipClass, getenv, envNumber and setting move
unchanged with their two tests (getenv and setting become pub for cuda.zig); cuda.zig is 555 lines.
ashhart added a commit that referenced this pull request Oct 16, 2026
…back test never frees the server under one

The /health test waited at most 5 s for open connections to reach zero and then freed the server, its keys and the engine and text on its stack, even if a connection thread still ran. Its quiesce now stops the test with a panic after 5 s rather than free anything a live thread reads. The count also rose only once a connection's thread ran, so zero after the accept loop ended did not prove that an accepted connection had no thread still to start; serve() now counts each connection before spawning its thread (and uncounts it if the spawn fails), which also makes the server's own shutdown wait exact.
ashhart added a commit that referenced this pull request Oct 16, 2026
…status_routes.zig)

Layout only, by zig fmt after closing commas; two one-statement for bodies take braces.
ashhart added a commit that referenced this pull request Oct 16, 2026
…alth table (#866)

#866 documented the open /health fields as public main had them; #854, landed first, appends version, backend and device after live. The merge kept #866's shorter route row, so the three fields are listed in its table instead.
ashhart added a commit that referenced this pull request Oct 16, 2026
@ashhart

ashhart commented Oct 16, 2026

Copy link
Copy Markdown
Owner

Thank you, @ThinkOffApp. One identity builder that the tests call, and a /health that names the release, the backend and the GPU only when no keys are set, is the shape we wanted.

Both commits ship in TensorFold 1.0.12 as they are, merged in 8df3720d0, so this pull request shows as merged. Ours follow. aea04333c moves the CUDA device helpers into their own file, unchanged, because deviceName took native/cuda.zig past our 600-line limit. 458278a8f fixes the loopback test's cleanup, which waited at most five seconds for connection threads and then freed the server under any still running, so it now stops the test instead, and the server counts a connection before its thread starts. 4f55f1b8b wraps the new lines, and 626cbda2b adds your three fields to the Health table in docs/api.md that #866 brought.

The host suites pass on macOS and Linux, and every model in the release gate served the same replies with it in the build.

Posted by Ash's AI Assistant Synthena

BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
… it serves on

serve.zig's server config keeps the candidate's saved_conversations beside the head's identity.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
… so cuda.zig stays under 600 lines

ashhart#854's deviceName took native/cuda.zig to 607 lines. chip, deviceName, chipClass, getenv, envNumber and setting move
unchanged with their two tests (getenv and setting become pub for cuda.zig); cuda.zig is 555 lines.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…s loopback test never frees the server under one

The /health test waited at most 5 s for open connections to reach zero and then freed the server, its keys and the engine and text on its stack, even if a connection thread still ran. Its quiesce now stops the test with a panic after 5 s rather than free anything a live thread reads. The count also rose only once a connection's thread ran, so zero after the accept loop ended did not prove that an accepted connection had no thread still to start; serve() now counts each connection before spawning its thread (and uncounts it if the spawn fails), which also makes the server's own shutdown wait exact.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…y.zig, status_routes.zig)

Layout only, by zig fmt after closing commas; two one-statement for bodies take braces.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
… the Health table (ashhart#866)

ashhart#866 documented the open /health fields as public main had them; ashhart#854, landed first, appends version, backend and device after live. The merge kept ashhart#866's shorter route row, so the three fields are listed in its table instead.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
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