Repository navigation
Conversation
|
Maybe this issue affects only me. In my case, I have several chats with GLM 5.3 Flash using a 1M-token context. After several compactions, these chats become unusable: when the model attempts to retrieve content from archived messages, it gets stuck in the _same() function, pinning one CPU core at 100%. Every subsequent prompt in such a chat times out after 1200 seconds. |
|
Reached Codex review convergence at oobabooga#391. |
|
Thanks! This speeds up conversation archiving when tool calls contain large arguments. I found no behavior changes in testing. SpeedSynthetic tool-call histories, using Studio's actual matcher:
Both versions found the same transcript position. Validation
LimitsVery repetitive inputs can still be slow, and some successful matches take a few extra milliseconds. |
…ce (unslothai#14519) (unslothai#14546) ## Summary - Confirms [unslothai#14519](unslothai#14519): on long chats, `archive_turns` blocked the generation worker in a single synchronous `SentenceTransformer.encode` of every pending chunk, and Chat Stop did not interrupt it (distinct from the string-matcher fix in unslothai#14098). - Embed pending archive chunks in batches (`_ARCHIVE_EMBED_BATCH = 64`) and poll an optional `cancel_check` between batches; `_archive_and_recall` forwards `cancel_event` from the chat Stop path. - Cap chunks per `archive_turns` call (default 256, override `RAG_ARCHIVE_EMBED_MAX_CHUNKS`); deferred groups stay unindexed and are picked up on a later request (idempotent by digest). Already-written groups are kept; incomplete groups are not written. - Adds unit coverage for cancel-between-batches and per-call chunk capping. @danielhanchen - this matches the reporter’s py-spy stack (`_archive_and_recall` → `archive_turns` → `encode_with_identity`). Happy to adjust batch/cap defaults if you prefer different numbers. ## Test plan - [ ] `pytest studio/backend/tests/test_conversation_archive.py::test_a_first_compaction_embeds_its_turns_in_one_pass` - [ ] `pytest studio/backend/tests/test_conversation_archive.py::test_archive_embed_honors_cancel_between_batches` - [ ] `pytest studio/backend/tests/test_conversation_archive.py::test_archive_embed_caps_chunks_per_call` - [ ] Manual: long tool-heavy chat with `RAG_CONVERSATION_ARCHIVE=1`, send a short follow-up, press Stop during the pre-inference CPU spike - embed work should stop between batches and inference path should not stay pegged at ~17 cores - [ ] Manual: same chat with archiving enabled - first follow-up should not stall for many minutes before llama.cpp receives work; leftover archive groups appear on later turns ## Follow-up changes - Embedding failures keep every finished batch, and a backend swap mid-pass restarts the pass in the new embedding space. - Stop is honoured before chunking and before automatic recall, and reaches the archive on managed engines (MLX, vLLM, SGLang). - Idle-gap pre-embedding: turns that will be evicted are embedded into an in-memory, content-keyed vector cache only while no inference is running (tool calls, between turns), so a later compaction usually encodes nothing. Every inference entry point pauses it and waits out its batch in flight: chat streams on every engine, image and video generation and loads, training starts, speech to text, the OpenAI-compatible, Messages and Responses API passthroughs and direct llama-server calls. The worker never queues on an embedder lock, and nothing is written to the archive in the background, so edited turns simply miss the cache. Fixes unslothai#14519 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel Han <[email protected]>
Long chats with large tool calls could spend minutes comparing messages
in the conversation archive before GPU inference even started.
The matcher tried every possible word split, rebuilding both halves of
the message each time. Most of those splits could never match.
Use space positions instead and narrow down the possible splits before
checking them. This keeps the existing matching behavior, including
repeated spaces and the alternative JSON representation of tool arguments.
In the reported case, this removed the CPU-only delay before inference.