Skip to content

rpc : keep backend tensor extras on the server - #341

Merged
gianni-cor merged 5 commits into
temp-11018from
rpc-backend-tensor-extras-11018
Oct 6, 2026
Merged

gianni-cor merged 5 commits into
temp-11018from
rpc-backend-tensor-extras-11018

Conversation

@iancris

@iancris iancris commented Oct 5, 2026

Copy link
Copy Markdown

Overview

The RPC server deserializes a new tensor for every command, so backends that keep state in tensor->extra (OpenCL) lose it and abort in set_tensor. This keeps the extras on the server, keyed by buffer, data, type and shape.

  • Attach the stored extra on deserialization, store the new one after each write, and drop them when the buffer is freed.
  • Views share their parent's extra, but only if they match their view_src.
  • Short writes to quantized tensors with extras are zero-padded, since OpenCL reads ggml_nbytes.
  • OpenCL tracks SoA-converted tensors by extra rather than by tensor pointer.

Backends without extras (CPU, Metal, Vulkan) are unaffected. This is #339 ported to temp-11018.

Testing

  • The new test-rpc-extras fails without this change and passes with it. test-rpc-* pass.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES. Claude Code wrote the patch and tests; I reviewed the change.

🤖 Generated with Claude Code

gianni-cor and others added 5 commits October 5, 2026 15:41
Backends like OpenCL keep per-tensor state in tensor->extra. init_tensor
creates it and set_tensor can replace it (re-laid-out quantized weights).
The RPC server deserializes a new tensor for each command, so this state
was lost and OpenCL asserted in set_tensor (GGML_ASSERT(extra)).

Keep the extras on the server, keyed by buffer, data, type and shape.
Attach them on deserialization, store the new extra after writes, use the
parent extra for graph views, and drop them when the buffer is freed.
Backends whose init_tensor does not set an extra are not affected.

Add test-rpc-extras: a CPU-backed device with OpenCL-style extras behind
an in-process RPC server. It fails without this change.

Assisted-by: Claude Opus 5.5
Fixes the GGML_BACKEND_DL link failure on windows / x64-openblas.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An RPC server creates a new ggml_tensor per command; the extra is what persists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s extra

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OpenCL reads the whole tensor from the source when re-laying it out,
which over-read the received payload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@iancris
iancris requested review from a team as code owners October 5, 2026 13:46
@gianni-cor
gianni-cor merged commit 053520f into temp-11018 Oct 6, 2026
51 of 54 checks passed
@gianni-cor
gianni-cor deleted the rpc-backend-tensor-extras-11018 branch October 27, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants