Phase 3: chat mode + kernel unit tests - #4
Merged
Merged
Conversation
Wraps a user turn (with system prompt) in the template the instruct models are trained on, so the model answers rather than completes.
In chat mode the prompt is templated and only the assistant's reply is streamed; completion mode is unchanged. Generation stops on the <|im_end|> turn token.
Covers mat-vec, RMSNorm (unit RMS), RoPE (norm-preserving), SwiGLU, softmax, greedy/RNG sampling, and INT8/INT4 quantization round-trips and memory — all against small hand-checked values.
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.
Polish pass — makes ember usable as an assistant and adds a test suite.
Chat mode
--chatwraps the prompt in Qwen's ChatML template (with--system), streams only the reply, and stops at<|im_end|>. Verified against the NumPy reference:Tests
cargo testcovers every kernel against small hand-checked values: mat-vec, RMSNorm (unit RMS), RoPE (norm-preserving), SwiGLU, softmax, greedy/RNG sampling, and INT8/INT4 quantization round-trips + memory. Constants cross-checked in NumPy.Completes the three-phase plan. Remaining: tokens/sec numbers, which need the binary built on a host without the local Smart App Control toolchain block.