perf(native): improve inference hot paths and add parity tooling#61
Merged
perf(native): improve inference hot paths and add parity tooling#61
Conversation
Cut prompt/template and stream transport overhead by caching metadata, batching token messages, and reusing prompt prefixes with parity-safe fallbacks. This improves TTFT and throughput while keeping chat session context trimming bounded for long histories.
Add native benchmarking/parity scripts and wire a CI parity job with a deterministic prompt set so prompt-prefix reuse regressions are caught automatically. Document the new workflow and tuning flags for reproducible perf validation.
Bump package/docs versions and add 0.6.2 release notes covering native inference performance improvements, benchmark/parity tooling, and CI parity validation.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #61 +/- ##
==========================================
+ Coverage 76.91% 77.26% +0.35%
==========================================
Files 65 66 +1
Lines 7930 8046 +116
==========================================
+ Hits 6099 6217 +118
+ Misses 1831 1829 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
create(...), batching worker stream chunks, and adding prompt-prefix reuse with deterministic full-replay fallback.ChatSessioncontext trimming with bounded turn-offset search, add configurable stream batching/reuse knobs inGenerationParams, and extend unit coverage for the new behavior.ci.yml, and prepare the0.6.2release notes/version/doc snippets.Validation
dart analyzedart testdart run tool/testing/native_prompt_reuse_parity.dart --model "example/basic_app/models/qwen2.5-0.5b-instruct-q4_k_m.gguf" --prompt-file "tool/testing/prompts/native_prompt_reuse_parity_prompts.txt" --runs 2 --max-tokens 128 --stream-batch-tokens 8 --stream-batch-bytes 512 --fail-on-mismatch