Skip to content

document that only one on-device state can be saved per sequence - #23520

Merged
ggerganov merged 1 commit into
ggml-org:masterfrom
TimNN:push-oqkyzokppvnk
May 25, 2026
Merged

ggerganov merged 1 commit into
ggml-org:masterfrom
TimNN:push-oqkyzokppvnk

Conversation

@TimNN

@TimNN TimNN commented May 22, 2026 •

Copy link
Copy Markdown
Contributor

Overview

When using LLAMA_STATE_SEQ_FLAGS_ON_DEVICE, the on-device state is associated with the original sequence ID. A later call to get_data with that flag overwrites any previously saved state, effectively invalidating all prior states gotten with this flag.

That is not behavior I would have expected, and I only noticed because I was wondering how the lifetime of the on-device buffers is managed.

Since I had to look at the source code to figure out how to use this API properly, I'm sending a PR to improve the documentation as suggested in CONTRIBUTING.md.

(I'm mildly interested in making the API work with user-managed on-device buffer lifetimes. The best idea I had so far is adding LLAMA_STATE_SEQ_FLAGS_ON_DEVICE_ALLOC 6 which allocates new buffers and increments a counter on each get_data call, storing the buffers in mem_storage associated with the counter. That would also need a llama_state_seq_dealloc_on_device_data or something).

Requirements

@ggerganov ggerganov self-assigned this May 23, 2026
@ggerganov
ggerganov merged commit 314e729 into ggml-org:master May 25, 2026
1 check passed
@TimNN
TimNN deleted the push-oqkyzokppvnk branch May 25, 2026 07:36
turbo-tan pushed a commit to turbo-tan/llama.cpp-tq3 that referenced this pull request Jun 2, 2026
zommiommy pushed a commit to zommiommy/llama.cpp that referenced this pull request Aug 18, 2026
zbrad pushed a commit to zbrad/llama.cpp that referenced this pull request Sep 10, 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