Skip to content

feat: interactive chat mode for olmoe (multi-turn conversations)#542

Open
opxyc wants to merge 1 commit into
JustVugg:devfrom
opxyc:feat/olmoe-chat-mode
Open

feat: interactive chat mode for olmoe (multi-turn conversations)#542
opxyc wants to merge 1 commit into
JustVugg:devfrom
opxyc:feat/olmoe-chat-mode

Conversation

@opxyc

@opxyc opxyc commented Jul 23, 2026

Copy link
Copy Markdown

Summary

olmoe.c was benchmark-harness-only (ref.json prompt/full ids in, token ids out) β€” no way to actually converse with it. Adds a CHAT=1 interactive 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 fresh generate() per message), OLMoE-Instruct's actual <|user|>/<|assistant|> chat template, and /reset. Also adds chat_olmoe.sh, a launcher wrapping the process in a systemd-run cgroup (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.
  • CUDA changes were tested with make -C c cuda-test (if applicable) β€” N/A.
  • Performance claims include hardware, commands, and repeatable measurements β€” no performance claim made here; this is a feature addition, not an optimization.

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

  • The default CPU build remains dependency-free
  • No model files, generated binaries, or benchmark artifacts are included

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.
@opxyc opxyc changed the title olmoe: interactive CHAT=1 mode with a growing multi-turn KV cache feat: interactive chat mode for olmoe (multi-turn conversations) Jul 23, 2026
@JustVugg JustVugg mentioned this pull request Jul 23, 2026
5 tasks
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