Repository navigation
rpc: do not abort on shutdown when a teardown round trip fails - #203
danielhanchen wants to merge 329 commits into
Conversation
The Linux and Windows CPU app bundles narrowed the build to
`--target llama-server llama-quantize`, so app-*-{linux,windows}-x64-cpu
shipped without llama-cli and the rest of the tool set that the macOS bins
already include. This broke the consolidated-tests-ci "llama.cpp build +
smoke" assertion that llama-cli exists at the install root.
Drop the --target narrowing so the CPU builds compile the full set like the
macOS/ROCm children, and set LLAMA_BUILD_TOOLS/SERVER=ON explicitly on
Linux. The package step already tars all of build/bin, so the extra
binaries ship automatically.
…32) Co-authored-by: danielhanchen <[email protected]>
* Prebuilt: carry macOS 14 paravirtual mmap fix; drop stale GGML_METAL_USE_BF16 define Pin #37 in pr-set.json: on macOS 14 VMs the Apple Paravirtual GPU returns stale data for mmap-backed weight buffers, so the patch makes the Metal backend stop advertising buffer_from_host_ptr there and llama.cpp falls back to copied weights (same path as --no-mmap). GGML_METAL_USE_BF16 no longer exists in current llama.cpp (bf16 is runtime-probed since the ggml-metal rewrite), so the define was a no-op; remove it from the macOS matrix entry. * Keep the pin-set unchanged; this PR only drops the stale define GGML_METAL_USE_BF16 no longer exists as a build option in the current source tree (bf16 is runtime-probed), so passing it was a no-op. The macOS 14 paravirtual mmap pin moves to a separate decision.
…#39) Both pins pointed at commits that no longer merge onto the selected upstream base, so the nightly full release build failed while resolving the PR set. ggml-org#24523 was pinned to 66f43aa6, which was not even the PR head at the time (the resolver logged that the head had moved to 0b78558a). That commit conflicts in common/chat.cpp against both b10107 and b10133. The PR has since been rebased onto current master, so the pin now points at its new head a58a7fa6, which merges cleanly. ggml-org#25731 was pinned to ce16fff, which conflicts on its own in ggml/src/ggml-cuda/mmq.cuh, src/llama-model-saver.cpp and src/llama-vocab.h. This never surfaced in the log because the resolver stops at the first failing entry. Its current head 453c438 merges cleanly by itself. Note that ggml-org#24523 and ggml-org#25731 still conflict with each other in common/chat.cpp and src/llama-arch.h: both append a new llm_arch enum value immediately before LLM_ARCH_UNKNOWN and both add a chat parser in the same region. Reordering does not help, since whichever entry is applied second hits the same conflict. Resolving that needs a decision about which of the two to carry, so it is left alone here. Requires a base of b10133 or newer: b10107 predates the rename of common_chat_params::thinking_end_tag to thinking_end_tags, which the rebased ggml-org#24523 depends on. Co-authored-by: Daniel Han <[email protected]>
#39 landed the first pin refresh only, so master still points at commits that have since moved on and that conflict with each other. ggml-org ggml-org#24523 was force-pushed: it now places LLM_ARCH_MINIMAX_M3 next to LLM_ARCH_MINIMAX_M2 rather than at the tail of the enum, matching how llama-arch.cpp already groups the name table. That removes the src/llama-arch.h half of its collision with ggml-org#25731, which appends LLM_ARCH_INKLING at the tail. New head baee0f5. ggml-org ggml-org#25731 has picked up current master and the thinking_end_tags rename, so it now builds on its own against b10133 and newer. Its entry is replaced by unslothai #40, which carries what is still unresolvable between the two: both add a chat parser and a detection block in the same region of common/chat.cpp, immediately before "namespace workaround {". chat.cpp has no MiniMax-M2 parser to sit beside, so there is no principled alternative anchor for that half. Replaying the resolver sequence on b10133: OK ggml-org ggml-org#24423 @ c3fb972 OK ggml-org ggml-org#24523 @ baee0f5 OK unslothai #40 @ 233cedb Drop the #40 entry and repin ggml-org#25731 upstream once either PR lands. Co-authored-by: Daniel Han <[email protected]>
The nightly died in resolve: #40 carried MiniMax-M3 plus Inkling, upstream master now ships its own MiniMax-M3, and the two collided in src/models/models.h and tests/test-backend-ops.cpp. Every build job was skipped. Drop the two MiniMax entries (ggml-org#24523 is closed anyway, so it was already inert) and repin on the four PRs we actually want: ggml-org#24423 DiffusionGemma ggml-org#25731 TML Inkling #44 Kimi-K3 fixes + MoonViT-3d vision tower ggml-org#26185 Kimi-K3 text ggml-org#25731 and #44 both had their conflicts against current master fixed on their own branches, and #44 also carries the Inkling merge: the two archs land in the same arch/model/mtmd registries, so they cannot go in as two independent heads and one of them has to know about the other. ggml-org#26185 is last on purpose. Its head is an ancestor of #44, so by the time the resolver gets there the merge is a no-op; listed before #44 it conflicts on tests/test-llama-archs.cpp. It stays in the set so the release manifest names it. Verified locally against b10173: the four merge in this order with zero unmerged paths, and the merged tree builds with -DGGML_CUDA=OFF -DLLAMA_CURL=OFF -DLLAMA_BUILD_TESTS=ON. Assisted-by: Claude Code
…head (#49) The nightly has been red since 2026-07-31. pwilkin force-pushed ggml-org#26185 at 21:16Z that day, eleven minutes before the schedule fired, and the pin in this file still named cf67f0d -- a merge commit that the rebase wrote out of the branch. The membership gate in the resolve step caught it and refused, so every build job was skipped. Runs 30666643530 and 30718507279 both died there. Two more things were wrong once that was unblocked: - Inkling was pinned to d69b7e6, which is the commit three separate reporters got garbage output from (CPU, Mac, and ROCm with -fa on). ggml-org#25731 fixed all of those in 02142bb; the nightly was shipping the broken one. - The rebase left ggml-org#26185 unmergeable against current master, and Kimi-K3 and Inkling register in the same arch, model and mtmd tables. Two independent heads cannot both land, so one of them has to know about the other. #48 now carries that. Its base branch was advanced to the rebased ggml-org#26185 head, then merged with b10223 and with Inkling, resolving four collisions: src/llama-arch.cpp KIMI_K3 and INKLING share a fallthrough src/llama-model.cpp same, in the ROPE_TYPE_NONE group tests/test-llama-archs.cpp master's MINIMAX_M3 vs KIMI_K3 tools/mtmd/ CMake source list and the graph registry All four are additive; both arches belong in every group. The two Kimi-K3 commits were rebased on top, so #48 is still a 10-file stacked diff against its base. ggml-org#26185 stays listed, last. Its head is now an ancestor of #48, so the resolver merges it as a no-op and the release manifest still names it. Verified against b10223: the four merge in this order with zero unmerged paths, and the merged tree builds with -DGGML_CUDA=ON. On the merged tree test-chat passes and test-llama-archs -a kimi-k3 is OK on both CUDA and CPU (NMSE 8.77e-08); it fails to even load the model without this repin.
The 2026-08-02 schedule (run 30767267935) failed in resolve: ggml-org#25731 (02142bb) does not merge cleanly onto b10229 + the PRs listed before it Not the pin rot that broke the previous two nights -- all four pins passed the membership gate this time. Upstream added LLM_ARCH_DEEPSEEK4 to the same fallthrough group in src/llama-arch.cpp that Inkling registers in, between b10226 and b10229, and the resolver has no conflict resolution. Fixed on the branch rather than here: b10229 is merged into add-inkling and both cases are kept, since both arches belong in that group. That also clears ggml-org#25731's own mergeable state against master, which had gone red for the same reason. No other pin moves. #48 needed nothing -- it already carries b10223 and the new arch does not collide with Kimi-K3. Verified against b10229: the four merge in order with zero unmerged paths, and the merged tree builds with -DGGML_CUDA=ON. test-chat passes and test-llama-archs -a kimi-k3 is OK on CUDA and CPU (NMSE 8.77e-08). The new Inkling head also merge-tree's clean against upstream master, which is six commits past b10229, so the next tag should resolve too.
The nightly has no failure notification at all. There is no `if: failure()`
step, no webhook and no issue creation anywhere in the repo, so a failed
scheduled run only emails whoever last touched the cron file. That is how
07-31, 08-01 and 08-02 all failed unnoticed and the fork sat three days
behind upstream.
Adds three things:
- .github/actions/prebuilt-alert: opens, updates or closes a deduplicated
issue. Alerts sharing a key collapse onto one thread, so a multi-night
outage reads as one issue with a run-by-run history instead of one issue
per night. Closes itself on the next success.
- An alert job on the orchestrator, gated on publish-intent runs so subset
test dispatches stay quiet. It quotes the actual refusal out of the failed
job log, so the issue says which pin broke rather than just "a job failed".
'skipped' counts as healthy: a scheduled no-op legitimately skips every
build job.
- unsloth-prebuilt-deadman.yml: a run can go green while publishing nothing,
which nothing keyed off job failure can see. Upstream cuts releases several
times a day, so two days without one of ours is a fault.
Also closes a silent capability regression in resolve. A pinned PR that gets
merged or closed upstream currently drops out of $PRS with a plain echo,
which changes SETHASH, which changes the tag, so the release ships without
that architecture under a new tag and nobody is told. Entries may now be
{"url", "required": false}; bare strings stay valid and mean required, so the
file needs no migration. A non-open required pin refuses instead. The lint
workflow takes the same schema.
Verified: bash -n over every run block in both workflows and the action, and
the pin loop exercised for open, merged-required and merged-optional.
…h the resident threshold
unsloth: repin Inkling onto b11556, qwen4exp shared MTP onto b11552, MoE cache auto threshold
unsloth: repin DiffusionGemma onto c9b81be (multi-GPU visual server)
…ave-count ROCm Linux: rebuild libhsa-runtime64 with the KFD CWSR wave count
pr-set: repin Inkling (ggml-org#25731) onto current master
Pin #270: two-subgroup coopmat1 FA tile for 32 KiB shared memory
# Conflicts: # ggml/src/ggml-rpc/ggml-rpc.cpp
# Conflicts: # .github/workflows/build-cache.yml # .github/workflows/build-openvino.yml # .github/workflows/release.yml # CODEOWNERS
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d29d78ade7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -1,244 +0,0 @@ | |||
| name: CI (cpu) | |||
There was a problem hiding this comment.
Rebase without replacing the repository automation
When this commit is applied to its recorded parent, it removes the existing CPU PR workflow along with dozens of other build, test, release, and maintenance workflows, then installs fork-specific Unsloth automation; for example, the replacement CPU workflow is reusable only and the parent workflow runs on a schedule or manual dispatch, so ordinary pull requests no longer receive the CPU checks that included ggml/src/ggml-rpc/**. This contradicts the commit's stated one-file scope and leaves the RPC change untested in normal PR CI; the commit needs to be rebased so it contains only the intended RPC delta rather than the fork tree overlay.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this: that is the fork's own CI layout, which every branch of this repository carries (master replaces the upstream workflows with the Unsloth ones). The PR targets base/upstream-af50f2f24, upstream b11582, so the overlay shows in the diff the same way it does for #187; the change under review is ggml/src/ggml-rpc/ggml-rpc.cpp alone.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
What happens
llama-serverbuilt withGGML_RPCaborts on exit, after it has already printedcleaning up before exit:Why
common_memory_breakdown_print()is called afterclean_up(), which callsllama_backend_free(). The RPC device answersget_memorywith a round trip to the peer,and by that point the round trip fails, so
RPC_STATUS_ASSERTaborts the process.This was first seen on a two node layer split where the peer
ggml-rpc-serverhad beenstopped before the local server exited.
Correction, 2026-09-08. This paragraph previously claimed the abort reproduces with a
peer that is alive and healthy, and therefore fires on every shutdown of a server using
--rpc. Re-tested on the pair, that is wrong: with a healthy peer the master exitscleanly. The trigger is an unreachable peer, which is the case the original report
came from. Three of the four cells below reproduce exactly as written, including the log
line counts, so the defect and the fix are unchanged; only this claim about how often it
fires was too broad.
That still makes it worth fixing rather than a corner case. A peer going away before the
coordinator exits is the normal shutdown order for a split: the orchestrator tears down
the remote servers first, and any crash, kill or network loss on the peer puts the
coordinator in exactly this state. An informational property should not abort a process
that has already finished its work.
The fix
Device memory is an informational property, not part of the data path, and
ggml_backend_rpc_get_device_memory()already has a defined answer for an endpoint itcannot reach at all: report 0 free and 0 total. Report the same when the query itself
fails, and log an error.
Freeing a remote buffer is released state and is also a teardown operation, so a failure
there is logged instead of aborting: if the peer is gone then so is the buffer, and the
local context is freed either way. Without this second hunk the process still aborts a few
microseconds later in
ggml_backend_rpc_buffer_free_bufferfromggml_backend_sched_free, on the way out of~llama_context.Every other
RPC_STATUS_ASSERT, including all of the data path ones, is unchanged. Afailure while setting or getting a tensor or running a graph still aborts.
The alternative, teaching
common_memory_breakdown_print()to skip backends whoseconnection has dropped, was rejected: that code is shared with every non-RPC build and has
no way to ask a backend whether it is still reachable, so it would need a new backend
interface entry for one caller. Caching the last known figure inside the RPC backend was
also rejected: it adds state to keep in sync in order to print a number that is meaningless
by the time it is printed.
What was measured
CPU only,
stories15M-q4_0.gguf,--rpc HOST:PORT --device RPC0 -ngl 99, one completionserved, then SIGINT. The verdict is the process exit status: 134 is SIGABRT, 0 is a clean exit.
A fixed delay after SIGINT does not test this. The teardown round trip is microseconds wide, so
a reset injected 20 or 50 ms after the signal always lands outside it and comes back clean on
both arms, saying nothing (rows c7 and c8 below, kept as a negative control). What does work is
a proxy that parses the client to server RPC framing (
cmd:1 | size:8 | payload) and resets theconnection the instant a chosen command byte is issued, before forwarding it.
RPC_CMD_GET_DEVICE_MEMORYis 11 andRPC_CMD_FREE_BUFFERis 4.Single node,
127.0.0.1:SIGKILLed before shutdownreporting 0, 3connection is goneSIGTERMed before shutdownRPC_CMD_GET_DEVICE_MEMORYis issuedggml-rpc.cpp:831reporting 0, 3connection is goneRPC_CMD_FREE_BUFFERis issuedggml-rpc.cpp:397connection is goneTwo nodes,
ggml-rpc-serveron a second DGX Spark over the LAN, which is the topology theoriginal report came from:
SIGKILLed before shutdownreporting 0, 3connection is goneSIGTERMed before shutdown8 of the 8 injections that actually reach the teardown round trip abort before and are clean
after, across five fault shapes and two topologies. c9b is the row that shows the second hunk
is load bearing rather than defensive: with the reset landing on the free, the abort is in
ggml_backend_rpc_buffer_free_bufferatggml-rpc.cpp:397, not inget_device_memory.A healthy peer exits cleanly before the change, on both topologies (c1 and n1). An earlier
revision of this description claimed otherwise; that claim was wrong and is corrected here.
Follow ups this does not fix
Neither is a regression and neither is introduced here, but both are in the same file and both
turned up while testing this change.
1. There is no socket timeout anywhere in the RPC transport, so a peer that accepts a
connection and then never answers hangs the shutdown forever.
ggml/src/ggml-rpc/transport.cppsets
TCP_NODELAYandSO_REUSEADDRand nothing else: noSO_RCVTIMEO, noSO_SNDTIMEO, noconnect timeout.
socket_t::impl::recv_data()loops onrecv(fd, ..., 0)until it has thebytes, gets 0 (peer performed an orderly shutdown) or gets -1. A peer holding the socket open
and sending nothing produces none of those, so the process blocks and SIGINT is never serviced.
Reproduced before and after this change alike, row c6 above.
2. The transport sends with no
MSG_NOSIGNAL, so an RPC client that is notllama-servercanbe killed by SIGPIPE before either the old abort or the new log line is reached. Nothing in
the RPC backend installs a SIGPIPE handler or sets
SO_NOSIGPIPE; the only place in the treethat ignores SIGPIPE is
tools/server/server.cpp, added for MCP child processes, which is whyllama-serverreaches this code path at all.llama-cli,llama-benchand embedders do not.This one is a source level hazard I could not demonstrate: with
llama-cli --rpcand thepeer killed mid session, the first failing operation on this kernel is a
recv()that returns0, so
RPC_STATUS_ASSERTinnegotiate_hello()(ggml-rpc.cpp:348) fires first, identicallybefore and after. Stated as unproven rather than as a reproduction.
Also unchanged and out of scope here:
negotiate_hello()still has anRPC_STATUS_ASSERT, so areconnect to a half dead peer still aborts. That is a connect time path, not a teardown path.
Non-RPC builds
The change touches one file,
ggml/src/ggml-rpc/ggml-rpc.cpp. That file is compiled onlythrough
ggml_add_backend(RPC)inggml/src/CMakeLists.txt, which adds the subdirectoryonly if
GGML_RPCis set, andGGML_RPCdefaults to OFF inggml/CMakeLists.txt. Noheader, no public signature and no shared code path changes, so NVIDIA, AMD and CPU only
builds without RPC are byte for byte unaffected.