feat: interactive chat mode for olmoe (multi-turn conversations)#542
Open
opxyc wants to merge 1 commit into
Open
feat: interactive chat mode for olmoe (multi-turn conversations)#542opxyc wants to merge 1 commit into
opxyc wants to merge 1 commit into
Conversation
olmoe.c was benchmark-harness-only (ref.json prompt/full ids in, token ids out) β no tokenizer wiring, no way to actually converse with it. Adds: - CHAT=1 env var on main(), bypassing the ref.json harness entirely - tok.h/sample.h wiring (tokenizer load, temperature/top-p sampling, the tokenizer's own special-token set arms the stop condition automatically) - run_chat(): allocates the KV cache once for CTX tokens (default 4096, capped there since attention()'s per-head score buffer is fixed-size) and never reallocates it -- each turn after the first reuses the previous turns' cached keys/values instead of re-processing them, so this is real multi-turn context, not a fresh generate() call per message - OLMoE-Instruct's actual chat template (<|user|>/<|assistant|>, with bos_token/eos_token both being the tokenizer's "|||IP_ADDRESS|||" token -- a genuine artifact of its tokenizer, not a bug here) - /reset to clear context without restarting the process - chat_olmoe.sh: a memory-safe launcher (systemd-run --scope with MemoryMax + MemorySwapMax=0) so a misbehaving run degrades to a clean self-kill instead of taking the whole machine down Validated with a real multi-turn conversation (two follow-up coding questions) -- second turn correctly used context from the first without re-explaining itself, confirming the KV-cache carry-over works.
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
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.
Summary
olmoe.cwas benchmark-harness-only (ref.json prompt/full ids in, token ids out) β no way to actually converse with it. Adds aCHAT=1interactive mode: tokenizer wiring (tok.h/sample.h), a KV cache allocated once for the context window and reused across turns (real multi-turn context, not a freshgenerate()per message), OLMoE-Instruct's actual<|user|>/<|assistant|>chat template, and/reset. Also addschat_olmoe.sh, a launcher wrapping the process in asystemd-runcgroup (MemoryMax+MemorySwapMax=0) so a misbehaving run degrades to a clean self-kill instead of taking the whole machine down β learned that the hard way on a 21GB-RAM box before adding it.Validation
make -C c checkβ same result as the sibling AVX2 PR: portable build + C unit tests pass; one pre-existing, unrelated Python test fails on this dev machine from local disk-quota pressure, not from this change.make -C c cuda-test(if applicable) β N/A.Validated with a real multi-turn conversation (two follow-up coding questions in one session) β the second turn correctly used context from the first without re-explaining itself, confirming the KV-cache carry-over actually works rather than silently starting fresh each turn.
Compatibility