Skip to content

api : mark llama_context_params.ctx_other as const - #28316

Open
madsmtm wants to merge 1 commit into
ggml-org:masterfrom
nobodywho-ooo:other-context-const
Open

madsmtm wants to merge 1 commit into
ggml-org:masterfrom
nobodywho-ooo:other-context-const

Conversation

@madsmtm

@madsmtm madsmtm commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Overview

This allows consumers to rely on the llama_context not being mutated while inside another llama_context, which is useful for ensuring thread-safety and correctness.

CC @ngxson, dunno who else it'd make sense to ping about this?

Additional information

Similar to #28307.

Would be useful in utilityai/llama-cpp-rs#1122.

Requirements

This allows consumers to rely on the context not being mutated while
inside another context, which is useful for ensuring thread-safety and
correctness.
@madsmtm
madsmtm requested a review from ggerganov as a code owner September 3, 2026 11:38
@madsmtm

madsmtm commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

Ping @ngxson?

Comment thread include/llama.h
Comment on lines 417 to +418
// can be utilized in various ways, for example by sharing results or llama_memory between 2 contexts
struct llama_context * ctx_other;
const struct llama_context * ctx_other;

@ngxson ngxson Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm not the code owner of this, so not quite sure. But judging by the code comment above, this should not be const. For example, if llama_memory is shared, one context can edit the memory other another. While it's not implemented for now, it could be in the future, idk

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.

Makes sense. Let's keep it non-const.

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.

3 participants