Skip to content

rpc: cut the protocol cost of uploading weights to a remote server - #199

Draft
danielhanchen wants to merge 155 commits into
base/upstream-af50f2f24from
perf/rpc-load
Draft

danielhanchen wants to merge 155 commits into
base/upstream-af50f2f24from
perf/rpc-load

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Sep 6, 2026 •

Copy link
Copy Markdown
Member

Loading a model that is split across machines spends a large part of its time pushing the
remote half of the weights over RPC, and much of that is protocol overhead rather than wire
time. This branch removes two of those costs on the client.

What changed

Everything is in ggml/src/ggml-rpc/ggml-rpc.cpp.

The hash pass is skipped when it cannot help. SET_TENSOR_HASH lets a server that keeps
a tensor cache (rpc-server -c) answer "I already have this" instead of taking the upload.
A server started without -c has no cache, so the answer is always no and the FNV-1a pass
over every weight tensor above 10 MiB is pure cost. The server now reports that it has no
cache in the byte of the HELLO response that used to be padding
(RPC_SRV_FLAG_NO_CACHE, bit 2; bits 0 and 1 are left for other optional features), and the
client only hashes when that bit is clear. The message keeps its size and the protocol version
is unchanged: an older server sends a zero byte, so a new client keeps hashing against it, and
an older client ignores the byte.

No staging copy for the upload. SET_TENSOR used to allocate a buffer the size of header
plus tensor, copy the header and the tensor into it, and send that. The header and the
caller's payload are now written to the socket one after the other from the caller's memory,
through a blocking send_with_payload on the dispatcher (the caller's data must stay valid
until the send is done, which a blocking send guarantees). The bytes on the wire are the same
as before.

Earlier revisions of this branch also streamed SET_TENSOR into the destination on the
server, pipelined RDMA sends and added a load profiler (GGML_RPC_LOADPROF,
GGML_RPC_LOAD_OPT). Those are not part of the current diff: the RPC backend was restructured
upstream (the dispatcher thread) and only the two changes above were carried over.

Measurements

Taken on the earlier, larger revision (two DGX Sparks, Qwen3.8-27B-UD-Q4_K_XL, RoCE with RDMA).
They bound what the two remaining changes can save, they are not a measurement of this diff:

  • Client profile of a base load on the pair: of 19.4 s, 6.85 s was hashing for a server
    without a cache, which the first change removes entirely, and 2.39 s was host staging, part
    of which is the client copy removed by the second change.
  • Single node, all 15.7 GiB to the remote backend: hashing 12.6 s and host staging 4.3 s out
    of a 41.5 s upload span.

Greedy output over an RPC split is unchanged (the wire bytes are identical), and a build
without the RPC backend compiles identical code (no file outside ggml/src/ggml-rpc/).

Interoperability

client server behaviour
old old unchanged
new old server sends 0, client hashes as before
old new client ignores the byte
new new hashes only when the server has a cache

Checked on CPU builds over loopback RPC (fake Qwen3-0.6B, greedy, all arms the same text): new
client and new server with and without -c, new against the pre-fix revision both ways, and
against a server that sets bit 0 for another feature (the client still hashes and fills the
cache).

Loading a 27B layer split spends most of its time in the weight upload, and most of
that time is protocol, not wire. Measured on one node with an rpc-server on the RoCE
interface (Qwen3.8-27B UD-Q4_K_XL, 15.7 GiB pushed to the remote backend, RDMA
active), the upload phase cost 41.5 s and broke down as:

  hashing   12.6 s    every tensor over 10 MiB hashed with FNV-1a at about 1.2 GiB/s
  staging    4.3 s    a fresh zero filled buffer per tensor, then a copy into it
  wire       4.3 s
  other     20.4 s    client side stalls outside the RPC calls

Four changes, all inside ggml/src/ggml-rpc:

- The server now says at HELLO whether it keeps a tensor cache, in the byte that used
  to be padding in the response. Without a cache the answer to SET_TENSOR_HASH is
  always "not cached", so the hash pass over every large tensor was pure cost. The
  client only hashes when the server can use it. The message keeps its size, an older
  server sends a zero byte and an older client ignores it, so both directions
  interoperate unchanged.

- SET_TENSOR is written from the header and the caller's payload directly instead of
  being copied into one contiguous buffer first. That buffer cost a zero fill and a
  full copy of every tensor. The bytes on the wire are identical.

- The server reads a SET_TENSOR message off the connection instead of into a vector
  sized to the whole message, and receives the payload straight into the destination
  when the backend buffer is host memory. Non host backends reuse one staging
  allocation that is never zero filled.

- The RDMA transport keeps up to eight 256 KiB chunks in flight instead of posting one
  and polling it to completion before posting the next, and drains them at the message
  boundary that flush() already marks. Receives are now consumed byte by byte from the
  completed buffer, so a peer that frames a message differently keeps working instead
  of losing the remainder of a frame.

After the change the same upload phase is 23.5 s, with hashing and staging at zero and
4.9 s on the wire. GGML_RPC_LOAD_OPT=0 restores the previous behaviour for A/B.

GGML_RPC_LOADPROF=1 turns on a load profiler on both sides: per command counts and
times on the client, and the split of the upload into hashing, staging, wire and the
gaps between calls. It is off by default and costs one relaxed atomic load per call.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T14:15:37.039037Z 4e2c0d8 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4b7f23fa19

ℹ️ 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".

Comment thread ggml/src/ggml-rpc/ggml-rpc.cpp Outdated

const void * data = input.data() + sizeof(rpc_tensor) + sizeof(offset);
// only a host buffer can take the payload directly; hashing for the cache also needs it contiguous
const bool direct = ggml_backend_buffer_is_host(tensor->buffer) && cache_dir == nullptr;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve host-buffer set_tensor hooks

When an RPC server uses a host-visible buffer whose set_tensor hook performs more than a memcpy, this shortcut silently bypasses required processing. For example, Hexagon enables host buffers by default, reports them as host-visible, and its hook repacks Q4/Q8/MXFP4 tensors into the tiled layout consumed by its kernels; with no cache directory, these tensors are now received directly in their original layout and the hook is never called, producing incorrect inference results. Direct streaming should be limited to buffers known to have memcpy semantics, or the backend hook must still be invoked.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in bace306. The substance is right and this was a real silent-wrong-results path, so thank you.

One correction to the example, which does not change the verdict. The Hexagon repack buffer type reports is_host = false, so it was never eligible for the shortcut. It is the plain Hexagon buffer type that qualifies: its is_host returns opt_hostbuf, and its set_tensor is the one that repacks Q4_0, Q4_1, Q8_0, IQ4_NL and MXFP4 into the tiled layout.

The shortcut is now limited to the CPU buffer type, whose set_tensor is a memcpy by construction. That keeps the benefit where it exists, since a device-backed rpc-server is not host-visible and was already taking the staged path.

Comment on lines 351 to 354
rdma->rx_buf = aligned_alloc(4096, static_cast<size_t>(RDMA_RX_DEPTH) * RDMA_CHUNK);
if (!rdma->tx_buf || !rdma->rx_buf) return false;

rdma->tx_mr = ibv_reg_mr(rdma->pd, rdma->tx_buf, RDMA_CHUNK, IBV_ACCESS_LOCAL_WRITE);
rdma->rx_mr = ibv_reg_mr(rdma->pd, rdma->rx_buf, static_cast<size_t>(RDMA_RX_DEPTH) * RDMA_CHUNK,
IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retry a smaller TX ring when RX registration fails

On systems whose memlock allowance is sufficient for the previous 256 KiB TX MR plus the 6 MiB RX MR but not the new 2 MiB TX MR plus RX, the largest TX registration succeeds by itself and the RX registration then fails, causing RDMA probing to fall back to TCP. The depth-reduction loop therefore does not provide the claimed graceful degradation for the relevant combined-memory limit; RX registration must be included in the retry so smaller TX depths are attempted.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in f06bbb2. Confirmed, and the code contradicted its own comment about degrading instead of failing, since the limit that binds is TX and RX together and only TX was being retried.

RX registration moved inside the loop. The RX buffer is a fixed size so only its registration is retried, and a TX depth that leaves no room for RX now deregisters and tries the next depth down.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 9, 2026
ggml_backend_buffer_is_host says the memory is addressable, not that set_tensor
is a plain memcpy. ggml-hexagon reports host buffers when opt_hostbuf is set,
and its set_tensor repacks Q4_0, Q4_1, Q8_0, IQ4_NL and MXFP4 into the tiled
layout its kernels read, so receiving into tensor->data and skipping the hook
left those weights in the wrong layout and produced wrong results with nothing
to show for it.

The shortcut is now limited to the CPU buffer type, whose set_tensor is a
memcpy by construction; every other backend keeps the staged path and its hook.
That costs nothing in practice, since a device-backed rpc-server is not
host-visible and was already staging.
The loop halved the TX ring until its registration succeeded, but RX was
registered once afterwards, so the comment's promise that a tight memlock
degrades instead of failing did not hold for the limit that actually binds. On
a system whose allowance covers the largest TX on its own but not TX plus RX,
the loop stopped at the largest TX, RX then failed, and RDMA fell back to TCP
without any smaller depth being tried.

RX is registered inside the loop now. Its buffer is a fixed size, so only the
registration is retried.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f06bbb22d9

ℹ️ 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".

Comment thread ggml/src/ggml-rpc/ggml-rpc.cpp Outdated
printf("Accepted client connection\n");
fflush(stdout);
rpc_serve_client(backends, cache_dir, client_socket);
g_rpc_loadprof_server.print();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reset the load profiler after each client

When the persistent server accepts a second client, this prints cumulative state from the global g_rpc_loadprof_server rather than statistics for that connection. None of its counters or timestamps are cleared, so first_ns still refers to the first client's upload and ns_gap includes the idle time between clients, making the reported span, gaps, and effective rates misleading for subsequent experiments. Reset the profiler after printing or keep one profiler per client connection.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Accepted. g_rpc_loadprof_server is global and nothing clears it between clients, so a second connection prints a span that starts at the first client upload and gaps that include the idle time between clients. The numbers are not merely stale, they are wrong in a way that reads as plausible, which is the worst kind for a profiling aid whose whole purpose is to be quoted.

Of your two options I prefer a reset after printing rather than one profiler per connection: the server serves one client connection at a time, so a per-connection instance would add lifetime management for no extra information, whereas a reset at the point the summary is emitted keeps the reporting boundary and the data boundary the same thing.

Not fixed yet, so no thumbs-up.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Confirmed and fixed in d2ff662.

g_rpc_loadprof_server is a single global and print() is called once per client in the accept loop, with nothing clearing it in between, so every connection after the first reports the earlier ones folded in. All three consequences you list follow: the counters are cumulative, first_ns still points at the first client's first upload, and ns_gap has the idle time between clients added to it, which makes the span, the gap total and the effective rates wrong for precisely the repeat experiments this profiler exists to support.

Took the "reset after printing" option rather than one profiler per connection, since the accept loop serves one client at a time and a per-connection object would be a larger change for the same result.

One detail worth calling out beyond the counters: last_end_ns has to be cleared as well. Left set, the first SET_TENSOR of the next client takes the prev != 0 branch and is charged as a gap from the previous client's last upload, instead of the else branch that records it as a new first_ns. Clearing only the counters would have left that one wrong in a way that is easy to miss, because the report would look plausible.

The constructor now calls reset() too, so the field list is in one place rather than partly initialised in two.

danielhanchen and others added 19 commits September 9, 2026 00:07
The server profiler is a single global printed once per client connection, and
nothing cleared it, so every connection after the first reported the earlier
ones as well. The counters were cumulative, first_ns still pointed at the first
client's first upload, and ns_gap had the idle time between clients folded into
it, which makes the span, the gap total and the effective rates wrong for
exactly the repeat experiments this is meant to support.

Adds reset() and calls it after print(). It clears last_end_ns too, which
matters as much as the counters: left set, the first upload of the next client
is charged as a gap from the previous client's last one rather than treated as a
new start. The constructor now uses it as well, so the field list lives in one
place instead of being partly initialised in two.
…-org#30034)

With GGML_BACKEND_DL=ON, backends must be loaded explicitly before
creating models.

Assisted-by: Codex
* ggml: refactor selective expert copying to user code

* tests: enroll two models into selective expert copy test

* tests: use deepseek2 as test model

* improve comment in ggml-backend.h

Co-authored-by: Georgi Gerganov <[email protected]>

* cont: fix whitespace

* cont : better comments

Co-authored-by: Georgi Gerganov <[email protected]>

---------

Co-authored-by: Georgi Gerganov <[email protected]>
…gml-org#30020)

The speculative MTP init enables NextN extraction on the target and draft
contexts after both were created and their schedulers reserved. With
unmasked extraction the trunk graph keeps every token through the last
layer instead of cropping to the output rows, so the first decode
reallocates to that batch's shape and the next, wider batch trips
GGML_SCHED_DEBUG_REALLOC. Invalidate the reserve when the flags change so
the next compute re-reserves with the new graph shape.

Assisted-by: Claude
…0040)

* add text_config as fallback

* remove redundant llm_config check

Co-authored-by: Sigbjørn Skjæret <[email protected]>

---------

Co-authored-by: Sigbjørn Skjæret <[email protected]>
…#30017)

* mimo2 : always emit h_nextn

the other nextn-capable models set it unconditionally

Assisted-by: pi:llama.cpp/MiMo-V2.6-Flash-MOPD

* models : consolidate nextn row cropping into shared helpers

- replace the duplicated crop conditions and the per-model flags (narrow_early,
  crop_before_ffn, crop_last_layer, emit_h_nextn) with two helpers on llm_graph_context:
  crop_before_nextn() / crop_after_nextn()
- models that only tested embeddings_nextn_masked now share the same condition, so they
  crop the last layer before the nextn capture whenever extraction is off
- t_h_nextn is now set unconditionally in mimo2, qwen4exp and deepseek4 (as in the other
  nextn-capable models); host-side reads stay gated by cparams.embeddings_nextn

Assisted-by: pi:llama.cpp/MiMo-V2.6-Flash-MOPD
A 1.0 loader (e.g. Android 8.1) has no vkEnumerateInstanceVersion, so
backend init called a null pointer. Treat it like any loader under 1.2.

Fixes ggml-org#29871.

Assisted-by: Claude Opus 5.5
* ggml-cuda: chunk large BF16/FP16 to F32 conversions

* Update ggml/src/ggml-cuda/ggml-cuda.cu

Co-authored-by: Johannes Gäßler <[email protected]>

* Update ggml/src/ggml-cuda/ggml-cuda.cu

Co-authored-by: Johannes Gäßler <[email protected]>

* ggml-cuda: respect dst stride in chunked cuBLAS matmul

---------

Co-authored-by: Johannes Gäßler <[email protected]>
* ggml: fix CLAMP on non-contiguous views (CPU, CUDA)

CUDA clamped ggml_nelements values flat and ignored the view strides.
CPU addressed row j as j*nb01 and ignored nb02/nb03. Both now follow the
strides of dims 1..3; CUDA supports_op requires contiguous rows, like
Metal. test_clamp gains a non-contiguous view case.

* cuda: clamp kernel uses fastdiv for the view strides
* rpc: allow -sm tensor

* fix flush for apple rdma

* move graph_uids to rpc_dispatcher

* cont : fix conflict

* cont: stop spinning dispatcher thread

* remove meta backend change

* add TODO to simplify logic

* rpc: bump major version

---------

Co-authored-by: Georgi Gerganov <[email protected]>
…-org#30042)

The gather path attended over the selected latents with a plain
matmul and softmax. It only ran with n_ubatch <= 16, and the flash
attention backends now skip the masked rows through n_kv_max, so
the scatter path covers every case.

Drop the gather flag, the gathered attention branch and
gather_mla_rows. set_input_kpool always maps padding to the n_kv
sentinel, and the slot mask becomes sel_mask since only the
scatter reads it.
* model: K2 Horizon gguf conversion code

* model: loading hparams and tensors in k2-horizon.cpp

* model: K2 Horizon compute graph

* model: K2 Horizon compute graph adjustment and registering tokenizers

* model: K2 Horizon chat template and accomodate safetensors naming

* unicode : add the K2-Horizon pre-tokenizer splitter

The K2-Horizon regex had no arm in unicode_regex_split_custom and fell through to the
general std::regex fallback, which fails two ways.

On MSVC std::regex rejects \p{...}, so no K2-Horizon GGUF loads on Windows at all:
llama-quantize, llama-imatrix and llama-perplexity all abort with
regex_error(error_escape) before a token is produced.

Where the fallback does compile it is still wrong. unicode_regex_split collapses each
codepoint to a single byte naming its Unicode category before matching, and U+200C/U+200D
are category Control, which has no entry in k_ucat_cpt, so both become the 0xD0 fallback
byte. The literal ‌ and ‍ alternatives in K2's regex can then never match and
every ZWNJ or ZWJ ends a letter run.

The splitter is the existing llama3 one with a single rule widened, since K2's regex
differs from llama3's only in that a letter run also takes marks, ZWNJ and ZWJ.

tests/test-unicode.cpp gains a case for this: it fails before the change with
[Amy] [ZWNJ khaham] and passes after with the run intact.

* tests: expand K2 Horizon unicode splitter coverage

* unicode: handle K2 Horizon case folding and empty input

Assisted-by: Codex

* jinja : support sequence indices in selectattr and rejectattr

Assisted-by: Codex

* model : add K2 Horizon dense and MoVA support

Includes the K2 Horizon implementation from ifm-ai/llama.cpp with converter, tensor-parallel and model save/reload fixes.

Assisted-by: Codex

* chat : support K2 Horizon reasoning and tool calls

Assisted-by: Codex

* conversion: remove obsolete K2 Aurora alias

Assisted-by: Codex

* k2-horizon: enforce response schemas and load YaRN betas

Constrain final JSON after reasoning, accept flexible JSON tool envelopes,
enforce XML dialects, and handle repeated or alternate thinking markers.
Load YaRN beta metadata instead of retaining the default values.

Add schema, streaming, continuation, and model reload regressions. Validate
CUDA and CPU builds and 0.9B, 4B, and MoVA conversation/tool round trips.

Assisted-by: Codex

* renaming template fixture

* adressing cisc follows ups

* desloppify the parser / adress aldehir comments

* clean test-chat

* remove fallback : model trained mostly on high anyway

* fix k2 attn_v_exp tn splitting and metal fusion baseline

* k2-horizon : forward expand views before sums

* k2-horizon: copy embds before group norm to fix TP

* disable tesnor parallelism

---------

Co-authored-by: Ryandito Diandaru <[email protected]>
Co-authored-by: WestWaters <[email protected]>
Co-authored-by: Natani L. Mayday <[email protected]>
Co-authored-by: West <[email protected]>
Co-authored-by: aaryamonvikram <[email protected]>
Co-authored-by: aaryamonvikram <[email protected]>
newjordan and others added 18 commits October 12, 2026 04:06
* ui: fix text attachment preview overflow

Set the max height to 80dvh and the max width to full on screens
below medium and 80vw from medium onward.

* style: run formatter
…#30329)

Add an optional ggml_backend_sched_realloc_callback that user code registers with
ggml_backend_sched_set_realloc_callback to be notified when the buffers reserved for a
graph are not sufficient and have to be reserved again. The callback reports whether the
backend assignments and the graph size changed since the previous scheduling.

llama_context registers the callback when creating the scheduler (wrapped into the new
llama_context::sched_new helper) and treats the reallocations that follow a change of the
backend assignments as expected, counting the rest by graph size - unchanged or changed
from the previously scheduled graph. Both counters are reported on one line in the perf
stats.

Assisted-by: pi:llama.cpp/Qwen3.8-Flash-Next
* examples : fix draft sampling and rejection handling

This commit fixes two issues in the speculative example which are
described in detail in the linked issue.

Resolves: ggml-org#29975

* examples : add kv-unified requirement for parallel > 1
* metal : fix mul_mat_id limits and kernel name

* metal : fix mul_mat_id with duplicate ids

kernel_mul_mm_id_map0 assumed at most one match per token and a fixed
capacity of ne21 entries per expert, which produced wrong or dropped
output rows and could overflow into the slice of the next expert when
the ids contain duplicates.

build a compact per-expert list of the (token, slot) entries instead:

- pass 1 counts the entries of every expert, thread 0 computes the
  offsets of the expert slices (tpe now holds [base, count])
- pass 2 writes the entries with one unconditional store per token
  (conditional stores of divergent lanes are very slow), the dummy
  value of the tokens without a match lands on a padding slot of the
  slice that is never read - duplicates are handled by a rare branch
- kernel_mul_mm_id reads the base/count of its expert and loops over
  the entry tiles that do not fit into the grid

The ids buffer is sized as ne20*ne21 + ne02 (entries + padding).

883/883 test-backend-ops MUL_MAT_ID tests pass, llama-bench is within
run-to-run variance of the previous behavior.

Assisted-by: pi:llama.cpp/MiMo-V2.6-Flash-MOPD

* metal : make mul_mat_id map0 ne02 a function constant

use FOR_UNROLL for the id loops of kernel_mul_mm_id_map0 and turn ne02
into the function constant FC_mul_mm_id_map0_ne02 (FC_MUL_MM + 7), so
that the threadgroup offsets of cnt/bas/sids and the prefix-sum bound
fold at compile time.

the pipeline name now encodes ne02 (same convention as the ssm_conv
nc/silu constants) and the map0 pipeline is compiled with the constant
value set. ne02 is no longer part of ggml_metal_kargs_mul_mm_id_map0 -
the dispatch grid still comes from the tensor ne[2] on the host.

no measurable perf change: 883/883 test-backend-ops MUL_MAT_ID tests
pass, op-level and llama-bench results are within run variance.

Assisted-by: pi:llama.cpp/MiMo-V2.6-Flash-MOPD

* cont : clean-up + TODO

* metal : dispatch mul_mat_id entry tiles from the prepass

follow the approach of the vulkan implementation (ggml-org#29998): instead of
launching a grid over experts x ne21 entry tiles and letting most of
the threadgroups early exit, kernel_mul_mm_id_map0 now also emits a
row map - the total tile count plus one (expert, first entry, valid
rows) descriptor per 32-entry tile that has work.

kernel_mul_mm_id is launched with a static upper bound on the number
of tiles (full tiles over all entries plus at most one partial tile
per expert), reads its descriptor and processes a single tile - the
tail early exits. This removes the round loop that was needed to cover
duplicate ids past the grid (register pressure: th_max 768 -> back to
the plain mul_mm level) and duplicates are now handled implicitly,
since they only produce more descriptors within the bound.

The grid shrinks by ~8-16x on typical shapes (e.g. 128 experts,
8 used, 512 tokens: 128 tiles instead of 2048 entry tiles, of which
94% only launched to exit) and ne21 is no longer needed by the mm
kernel kargs.

883/883 test-backend-ops MUL_MAT_ID tests pass. llama-bench
(Qwen3.6-35B-A3B Q8_0) is now faster than master on all pp sizes
(pp2048/4096/8192 +2%, pp512 +0.5%), tg32 unchanged.

Assisted-by: pi:llama.cpp/MiMo-V2.6-Flash-MOPD

* cont : add smem assert
…0299)

Give llama_build() and llama_build_and_test() a LINK keyword (default:
llama-common) so call sites can declare what a test actually needs:

- ggml-only tests now link just ggml: test-opt, test-metal-graph-optimize,
  test-backend-ops, test-tiled-mulmat, test-barrier, test-quantize-fns,
  test-quantize-perf, test-rope, test-col2im-1d, test-gguf, test-alloc
- llama-only tests drop llama-common: test-unicode, test-sampling,
  test-grammar-parser, test-llama-grammar, test-batch-alloc,
  test-gbnf-validator, test-quant-type-selection
- both mtmd tests link mtmd only, dropping the LLAMA_TEST_NAME /
  target_link_libraries workarounds

Both helpers now set cxx_std_17 explicitly, since the tests no longer
inherit it from llama-common's PUBLIC interface.

tests/testing.h no longer includes common.h; the only symbol it used from
there (string_join) is inlined.

Assisted-by: pi:llama.cpp/Qwen3.8-Flash-Next
* models: support pplx-decider

* vllm d2

* update

* clarify naming rule

* stricter validation

* fix ci

* rm redundant filter_tensors
* models: support pplx-decider

* vllm d2

* update

* clarify naming rule

* stricter validation

* d3
)

* vulkan: pack FMA for f16 accumulation, no dot product op

* vulkan: dot_product packs two rows per f16 FMA

* vulkan: rename dot_product to dot_product_v2
…30341)

* hexagon: move the converting CPY in blocks of rows per DMA descriptor so short rows are not DMA-latency bound

* hex-cpy: cleanup cpy cursor handling

* hex-cpy-concat: introduce threaded dma/hvx gather-row helper

Co-authored-by: Ruslan Karymov <[email protected]>

* hex-cpy: remove leftover rejections for extended buffers

* hex-cpy: relax the gate for fast-path

* hex-cpy: remove scalar divs and vtcm access and use explicit gather_sync

* hex-cpy: add proper support for mdev work splitting to fastpath

* hex-cpy: optimize dense gather-row tasks

* hex-cpy: unroll gather-rows loops

* hex-cpy: add fastpath for f16

* hex-cpy-concat: support for colapsing 3/4D dims

* hex-cpy: double-buffer support

* hex-cpy: factor out gather-rows into more of an op by itself

* hex-cpy-concat: dedup kernel-params

* hex-cpy-concat: step-down nr to fit instead of hard fail

* hex-gather: replace div with a mask

* hex-gather-rows: cleanup dma pipeline and remove the stalls

* hex-gather: specialize compute funcs

* hex-gather: reduce scalar reg.spills and func calls

* hex-gather: do not recompute rows-per-thread on the npu

* hex-build: add support for building/installing just hexagon

* hex-cpy-concat: remove redundant barrier in concat and move cpy barrier under fence

* hex-gather: annotations for dma-out

* hex-mdev: make all key vtcm_acquire sync state atomic (fixes random hangs in mdev setups)

---------

Co-authored-by: Yiwei Shao <[email protected]>
Co-authored-by: Ruslan Karymov <[email protected]>
…g#28748)

* metal: fix metal tensor kernel_mul_mm error for large tensor

Assisted-by: Codex

* Update ggml/src/ggml-metal/kernels/mul_mm.metal

Co-authored-by: YiChen Lv <[email protected]>

---------

Co-authored-by: 向锡铭 <[email protected]>
Co-authored-by: YiChen Lv <[email protected]>
…g#30416)

The no-cache path builds a [n_tokens, n_tokens] mask and passes K and V
unpadded, so FLASH_ATTN_EXT sees K->ne[1] == n_tokens. The CUDA kernels
for head size 512 require a multiple of FATTN_KQ_STRIDE, so the op falls
back to the CPU for most lengths, and the -fa auto probe (1 token)
disables flash attention for such models.

Pad the mask like llama_kv_cache::get_n_kv and pad K and V with zeros up
to the KV dimension of the mask. clef builds its own causal mask and
pads it the same way.
* model: fix vllm d3 multi seq case

* add TODO
…org#30245)

* tests: cover weighted scalar broadcasts

Assisted-by: OpenCode

* ggml : support extended scalar DMA binary ops

Assisted-by: OpenCode

* hex-binary: remove all non-dma paths

* hex-binary: add support for non-contig strides and cleanup dma preable a bit

* hex-binary: cleanup the gating and simplify dma retry

* hex-geglu-erf: add a gate for F32 only, we dont support F16 for this op

* tests: cover weighted repeat broadcast

Assisted-by: OpenCode

* hex-binary: update REPEAT and COMPLEX kernels to use dma as well (missed them last time)

* hex-add-id: add dma support for src2 (idx)

---------

Co-authored-by: Max Krasnyansky <[email protected]>
…kernels (ggml-org#30198)

* models: remove redundant ggml_cont calls now supported by CUDA unary kernels

* models: restore cont_2d after sigmoid for broadcast mul, clean dflash cont

* Update src/models/qwen3next.cpp

Co-authored-by: Sigbjørn Skjæret <[email protected]>

* models: restore cont_2d before sigmoid in qwen3next

---------

Co-authored-by: Sigbjørn Skjæret <[email protected]>
* ggml-zdnn: initial prototype of q8_0 matmul

Signed-off-by: Aaron Teo <[email protected]>

* docs: update zdnn docs

Signed-off-by: Aaron Teo <[email protected]>

---------

Signed-off-by: Aaron Teo <[email protected]>
@danielhanchen danielhanchen self-assigned this Oct 13, 2026
# Conflicts:
#	ggml/src/ggml-rpc/ggml-rpc.cpp
#	ggml/src/ggml-rpc/transport.cpp
# Conflicts:
#	.github/workflows/build-cache.yml
#	.github/workflows/build-openvino.yml
#	.github/workflows/release.yml
#	CODEOWNERS
@danielhanchen
danielhanchen changed the base branch from master to base/upstream-af50f2f24 October 13, 2026 20:23
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

run: python3 scripts/unsloth/check_workflow_triggers.py --root .

P2 Badge Allow the existing release-publish workflow before enforcing this check

Whenever a push or PR touches one of this workflow's listed paths, the resolver-tests job deterministically fails here: check_workflow_triggers.py --root . rejects the existing .github/workflows/release-publish.yml because its workflow_run trigger lacks the required waiver comment. The newly added test_check_workflow_triggers.py also asserts that the live repository passes and fails for the same reason, so relevant workflow and tooling changes cannot get a green lint run until that existing trigger is justified or the rule is adjusted.


SIBS="$(printf '%s\n' "$JOBS" | awk -F'\t' -v self="$SELF" -v alert="$ALERT" -v prune="$PRUNE" -v warm="$WARM" \
'NF && $1 != self && $1 != alert && $1 != prune && index($1, warm) == 0')"

P1 Badge Exclude the reclaim job from the matrix waiter

On every build run, the jobs API also reports the top-level Reclaim artifact storage job, which is queued behind needs: [..., assemble]. This filter excludes the current job and Report pipeline health but not reclaim, so PENDING can never reach zero: assemble waits for reclaim while reclaim waits for assemble, and the release eventually fails at the 330-minute waiter deadline instead of publishing. Add reclaim to the excluded housekeeping jobs rather than treating every job record as a build sibling.


if: ${{ needs.assemble.outputs.published != 'true' && inputs.keep_artifacts != true }}

P2 Badge Preserve artifacts until the automatic retry has run

For a scheduled run that fails for one of the infrastructure reasons accepted by unsloth-prebuilt-retry.yml, this cleanup runs before the workflow_run: completed retry is triggered and deletes every source and bundle artifact because published is false. The retry then calls rerun-failed-jobs, which leaves successful build legs untouched, so their now-deleted artifacts are never recreated and the rerun fails during download or coverage verification. Defer deletion for retry-eligible first attempts, or rerun all artifact-producing jobs.


- name: ccache stats
if: ${{ always() }}
shell: bash
run: |
ccache -s -v

P2 Badge Skip cache statistics when the ccache fallback is active

If the best-effort ccache-action fails to install a usable binary, the preceding configuration step deliberately sets CCACHE_LAUNCHER empty so the ARM64 build can continue uncached, but this unconditional always() step subsequently invokes ccache twice without continue-on-error. In exactly the transient missing/broken-ccache scenario the fallback is meant to tolerate, this step exits with command-not-found and still fails the otherwise successful release leg.


AGE_D=$(( ( $(date -u +%s) - $(date -u -d "$PUB" +%s) ) / 86400 ))
echo "newest release ${TAG} published ${PUB} (${AGE_D}d ago); threshold ${STALE_DAYS}d"
if [ "$AGE_D" -le "${STALE_DAYS}" ]; then

P2 Badge Measure release staleness without truncating whole days

When the newest prebuilt is between 48 and 72 hours old, integer division truncates its age to 2 and this <= 2 check still reports success, even though the workflow describes two days of silence as the fault threshold. Consequently the dead-man alert does not fire until the release is almost three days old; compare elapsed seconds directly or treat an integer age of 2 as stale once the exact 48-hour boundary is crossed.

ℹ️ 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".

Bit 0 of the HELLO reply byte is the trace clock sync feature and bit 1 peer
transfers in other branches of this fork. With the no-cache flag on bit 0 a
traced client against a server without -c sent TRACE_SYNC and aborted, and this
client against a traced server with -c skipped hashing and never hit the cache.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 4e2c0d8172

ℹ️ 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".

This branch has not been deployed

No deployments
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.