-
Notifications
You must be signed in to change notification settings - Fork 193
feat(benchmark): Add CPU benchmark tool with context length sweep #639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
huangzhenhua111
wants to merge
7
commits into
UbiquitousLearning:main
Choose a base branch
from
huangzhenhua111:pr-627
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fc46527
feat(benchmark): Add CPU benchmark tool with context length sweep
huangzhenhua111 27db797
Update README.md
huangzhenhua111 31fc935
fix: clarify cl vs cache_length, add multi-run warning
huangzhenhua111 dc3525a
add clear()
huangzhenhua111 85c4f88
feat: add kvCache() getter to LlamaForCausalLM
huangzhenhua111 507f7b2
removed only run once limitation
huangzhenhua111 c05fbd4
removed Llama only run once limitation
huangzhenhua111 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,19 +3,27 @@ | |
| #pragma once | ||
|
|
||
| #include <string> | ||
| #include <optional> | ||
| #include <cstdint> | ||
|
|
||
| /** | ||
| * @brief Benchmark result structure | ||
| */ | ||
| struct BenchmarkTemplateResult { | ||
| float ttft; ///< Time To First Token in milliseconds | ||
| float prefill_speed; ///< Prefill phase speed in tokens/s | ||
| float decode_speed; ///< Decode phase speed in tokens/s | ||
| float ttft; ///< Time To First Token in milliseconds | ||
| float prefill_speed; ///< Prefill phase speed in tokens/s | ||
| float decode_speed; ///< Decode phase speed in tokens/s | ||
| }; | ||
|
|
||
| struct KVCacheEstimateInfo { | ||
| int32_t num_layers = 0; | ||
| int32_t num_kv_heads = 0; | ||
| int32_t head_dim = 0; // hidden_size / num_attention_heads | ||
| }; | ||
|
|
||
| /** | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not delete all comments here! |
||
| * @brief Base class for benchmark templates | ||
| * | ||
| * | ||
| * All model benchmark implementations should inherit from this class and implement all virtual functions. | ||
| */ | ||
| class BenchmarkTemplate { | ||
|
|
@@ -32,21 +40,21 @@ class BenchmarkTemplate { | |
|
|
||
| /** | ||
| * @brief Print model information | ||
| * | ||
| * | ||
| * Should output model key parameters such as number of layers, hidden size, attention heads, etc. | ||
| */ | ||
| virtual void printModelInfo() = 0; | ||
|
|
||
| /** | ||
| * @brief Warmup run | ||
| * | ||
| * | ||
| * Run the model once with small-scale input to ensure the model enters a stable state. | ||
| */ | ||
| virtual void warmup() = 0; | ||
|
|
||
| /** | ||
| * @brief Clear cache | ||
| * | ||
| * | ||
| * Clear KV cache and performance counters to prepare for the next test. | ||
| */ | ||
| virtual void clear() = 0; | ||
|
|
@@ -58,4 +66,7 @@ class BenchmarkTemplate { | |
| * @return Test results | ||
| */ | ||
| virtual BenchmarkTemplateResult run(int32_t pp, int32_t tg) = 0; | ||
|
|
||
| // KV cache size estimation; return nullopt if unsupported | ||
| virtual std::optional<KVCacheEstimateInfo> kvEstimateInfo() const { return std::nullopt; } | ||
| }; | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The README is for developer, not a description of your PR. You should add your part on the top of the original README.md