-
Notifications
You must be signed in to change notification settings - Fork 12.3k
simple-chat : fix context-exceeded condition #14494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
slaren
reviewed
Jul 2, 2025
examples/simple-chat/simple-chat.cpp
Outdated
@@ -114,14 +114,15 @@ int main(int argc, char ** argv) { | |||
// check if we have enough space in the context to evaluate this batch | |||
int n_ctx = llama_n_ctx(ctx); | |||
int n_ctx_used = llama_memory_seq_pos_max(llama_get_memory(ctx), 0); | |||
if (n_ctx_used + batch.n_tokens > n_ctx) { | |||
if (n_ctx_used + batch.n_tokens >= n_ctx) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be more precise, I think it would be better to add 1 to the value returned by llama_memory_seq_pos_max
.
int n_ctx_used = llama_memory_seq_pos_max(llama_get_memory(ctx), 0) + 1;
slaren
approved these changes
Jul 2, 2025
gabe-l-hart
added a commit
to gabe-l-hart/llama.cpp
that referenced
this pull request
Jul 2, 2025
* origin/master: llama : initial Mamba-2 support (ggml-org#9126) sync : ggml ggml : add version function to get lib version (ggml/1286) Set RPATH to "@loader_path" / "$ORIGIN" to ensure executables and dynamic libraries search for dependencies in their origin directory. (ggml-org#14309) CUDA: add softmax broadcast (ggml-org#14475) CUDA: broadcasting for FlashAttention mask (ggml-org#14500) vulkan: support softmax/FA batch and broadcast (ggml-org#14449) ggml : support bcast ggml_soft_max_ext, ggml_flash_attn_ext (ggml-org#14435) opencl : fix possible buffer overflow in dump_tensor (ggml-org#14490) simple-chat : fix context-exceeded condition (ggml-org#14494) opencl : skip empty nodes on cgraph compute (ggml-org#14491) opencl : update upscale to support align corners (ggml-org#14488) ci : add OpenCL to labeler workflow (ggml-org#14496) github : add OpenCL backend to issue templates (ggml-org#14492) ggml : Callback before abort (ggml-org#14481) ci : disable fast-math for Metal GHA CI (ggml-org#14478)
Minh141120
pushed a commit
to menloresearch/llama.cpp
that referenced
this pull request
Jul 5, 2025
* simple-chat : fix context-exceeded condition ggml-ci * cont : fix n_ctx_used computation ggml-ci
qnixsynapse
pushed a commit
to menloresearch/llama.cpp
that referenced
this pull request
Jul 6, 2025
* simple-chat : fix context-exceeded condition ggml-ci * cont : fix n_ctx_used computation ggml-ci
qnixsynapse
pushed a commit
to menloresearch/llama.cpp
that referenced
this pull request
Jul 6, 2025
* simple-chat : fix context-exceeded condition ggml-ci * cont : fix n_ctx_used computation ggml-ci
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix #14487
Fix off-by-one error. New behavior after the fix: