Skip to content

rpc: include nb in the get_alloc_size cache key and floor the result at ggml_nbytes - #29283

Merged
ggerganov merged 3 commits into
ggml-org:masterfrom
Jesssullivan:jess-patch-b
Sep 25, 2026
Merged

ggerganov merged 3 commits into
ggml-org:masterfrom
Jesssullivan:jess-patch-b

Conversation

@Jesssullivan

@Jesssullivan Jesssullivan commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Hey there!

Overview

I am fairly new to this codebase, so please do let me know if I am barking up the wrong tree here; I encountered allocation issues with my local RPC setup and think I've chased this down to this nb include issue.

error occurs at ggml-alloc.c:607, GGML_ASSERT(parent_size >= node_size), exit 134. R

I've added nb to the cache key and never return less than ggml_nbytes.

Additional information

Currently, the memo added in #18626 keys RPC_CMD_GET_ALLOC_SIZE results on {device, type, op, op_params, ne} and leaves nb out.

Two tensors with identical ne but different strides therefore share one entry, and the second caller receives the first tensor's size. When that size is smaller than ggml_nbytes, the buffer-type contract documented in #27960 and #28038 is violated and allocation fails downstream.

I've reproduced against a local ggml-rpc-server -d CPU: a packed tensor reports 16384/16384 and a strided view with the same ne reports nbytes 32512, alloc_size 16384, then aborts; with this change the second call reports 32512 and the run completes. The regression is folded into tests/test-rpc-multi-server.

ref: #28360
ref: #18626
ref: #27960

Requirements

  • I have read and agree with the contributing guidelines Yes
  • AI usage disclosure: Yes; explored codebase with a bespoke local model based on GLM 5.3. Code written by hand. Formatting aided by general linting and suggestions provided by CLion IDE, which I think is to some degree AI powered.

Warmly,
-Jess

@github-actions github-actions Bot added testing Everything test related ggml changes relating to the ggml tensor library for machine learning labels Sep 22, 2026
@ggml-gh-bot

ggml-gh-bot Bot commented Sep 22, 2026

Copy link
Copy Markdown

Hi @Jesssullivan, thanks for your contribution!

Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:

  • AI-generated content: While code is allowed to be generated by AI, please write the PR description and commit messages on your own without the help of AI.

Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below.

@ggerganov ggerganov self-assigned this Sep 22, 2026
@Jesssullivan

Copy link
Copy Markdown
Contributor Author

Hi @Jesssullivan, thanks for your contribution!

Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:

  • AI-generated content: While code is allowed to be generated by AI, please write the PR description and commit messages on your own without the help of AI.

Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below.

err, the description, body, PR title, etc etc was indeed written by me 👀

Cheers,
-Jess

@Jesssullivan
Jesssullivan marked this pull request as ready for review September 22, 2026 19:18
@Jesssullivan
Jesssullivan requested review from a team and ggerganov as code owners September 22, 2026 19:18

@rgerganov rgerganov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this looks fine but now I wonder if we should change rpc_tensor.nb to uint64_t to prevent other issues with strides bigger than 4G

@ggerganov ggerganov added the merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. label Sep 24, 2026
Comment thread ggml/src/ggml-rpc/ggml-rpc.cpp Outdated
Comment thread ggml/src/ggml-rpc/ggml-rpc.cpp
@ggerganov
ggerganov merged commit 66963a8 into ggml-org:master Sep 25, 2026
1 check passed
feal87 added a commit to feal87/myllama.cpp that referenced this pull request Sep 25, 2026
Merge upstream commits:
  - llama: add llama_prec_policy + model-driven W4A4 path (ggml-org#24364)
  - llama: fix tensor split for fused qkv with uneven K/V head sizes (ggml-org#29294)
  - metal: split fa kernels into per-dtype libraries (ggml-org#29329)
  - metal: FWHT kernels for block widths above 512 (ggml-org#29095)
  - CUDA: fuse RMS_NORM + SCALE into one kernel (ggml-org#29393)
  - common: extract shared unicode path/string helpers (ggml-org#29415)
  - common,rpc: simplify fs_create_directory_with_parents() (ggml-org#29432)
  - rpc: include nb in the get_alloc_size cache key (ggml-org#29283)
  - [SYCL] support sparse FA (ggml-org#28796)
  - musa: fix PH1 operator failures and build issues (ggml-org#29193)
  - HIP: bump HIP_VERSION required for fp8 (ggml-org#29231)
  - opencl: add q5_k bin kernel (ggml-org#29401)
  - hexagon: add q5_k quant type support (ggml-org#29123)
  - hexagon: use DMA for contiguous dim1 CONCAT (ggml-org#29404)
  - mtmd: fix mel preprocessor in LFM2 audio (ggml-org#29403)
  - vulkan: fix legacy GLSLC without cooperativeMatrix (ggml-org#29409)
  - gguf-py: ByteLevel processing defaults bos/eos to False (ggml-org#29422)
  - gguf-py: TemplateProcessing has final word on add_special_token (ggml-org#29417)

Assisted-by: Pi
sky-mighty pushed a commit to sky-mighty/llama.cpp that referenced this pull request Sep 26, 2026
…at ggml_nbytes (ggml-org#29283)

* rpc : include nb in the get_alloc_size cache key and floor the result at ggml_nbytes

* cont : remove redundant comment

* cont : add TODO

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
frostyautumnleaf pushed a commit to frostyautumnleaf/llama.cpp that referenced this pull request Oct 5, 2026
…at ggml_nbytes (ggml-org#29283)

* rpc : include nb in the get_alloc_size cache key and floor the result at ggml_nbytes

* cont : remove redundant comment

* cont : add TODO

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
@Jesssullivan
Jesssullivan deleted the jess-patch-b branch October 6, 2026 07:53
edwardyoon pushed a commit to edwardyoon/focus-llama that referenced this pull request Oct 7, 2026
…at ggml_nbytes (ggml-org#29283)

* rpc : include nb in the get_alloc_size cache key and floor the result at ggml_nbytes

* cont : remove redundant comment

* cont : add TODO

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
(cherry picked from commit 66963a8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants