Skip to content

docs: explain shared Llama instance concurrency - #2394

Draft
karthiksenv wants to merge 1 commit into
abetlen:mainfrom
karthiksenv:codex/docs-shared-model-concurrency
Draft

karthiksenv wants to merge 1 commit into
abetlen:mainfrom
karthiksenv:codex/docs-shared-model-concurrency

Conversation

@karthiksenv

Copy link
Copy Markdown

Concurrent inference on one Llama instance shares mutable batch/context state and can abort in native code, as reported in #2392. The README currently does not explain this limitation.

Add a shared-instance locking example for embeddings and a streaming example that holds the lock through iteration and closes the generator before releasing it. Link the section from Embeddings and note the synchronous-worker constraint. This addresses the documentation part of #2392; it does not add internal locking or parallel inference.

Validation:

  • Ruff check and format checks passed for llama_cpp and tests (29 files formatted).
  • Both new Python examples passed AST parsing; git diff --check passed.
  • python -m mkdocs build --clean passed, and the generated heading/navigation/embeddings links were checked. Existing relative-link, docstring and theme-deprecation warnings remain.
  • Local docs environment used pymdown-extensions 11.0.2 because 12.3 caused a mkdocstrings Highlighter API mismatch. No dependency declarations changed.

Native model tests and independent reproduction of the reported crash were not run. Source inspection confirms shared _batch/context mutation and the generator returned by create_completion(stream=True). Keeping this draft for review of the documentation scope and remaining validation.

AI-assisted: Codex prepared the change and ran the checks above; the contributor authorized publication of this draft.

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.

1 participant