Skip to content

Add missing kv_cache related metrics #592

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
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ const std::vector<std::string> CustomMetricsReporter::runtime_memory_keys_{
const std::vector<std::string> CustomMetricsReporter::runtime_memory_labels_{"cpu", "gpu", "pinned"};

const std::vector<std::string> CustomMetricsReporter::kv_cache_keys_{
"Max KV cache blocks", "Free KV cache blocks", "Used KV cache blocks", "Tokens per KV cache block"};
const std::vector<std::string> CustomMetricsReporter::kv_cache_labels_{"max", "free", "used", "tokens_per"};
"Max KV cache blocks", "Free KV cache blocks", "Used KV cache blocks", "Tokens per KV cache block",
"Alloc Total KV cache blocks", "Alloc New KV cache blocks", "Reused KV cache blocks"};
const std::vector<std::string> CustomMetricsReporter::kv_cache_labels_{
"max", "free", "used", "tokens_per",
"alloc_total", "alloc_new", "reused"};

const std::vector<std::string> CustomMetricsReporter::v1_specific_keys_{
"Total Context Tokens", "Total Generation Tokens", "Empty Generation Slots"};
Expand Down
2 changes: 2 additions & 0 deletions inflight_batcher_llm/src/model_instance_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,8 @@ void ModelInstanceState::WaitForStats()
statJson.append("\"Max KV cache blocks\":" + std::to_string(kvStats.maxNumBlocks) + ",");
statJson.append("\"Tokens per KV cache block\":" + std::to_string(kvStats.tokensPerBlock) + ",");
statJson.append("\"Used KV cache blocks\":" + std::to_string(kvStats.usedNumBlocks) + ",");
statJson.append("\"Alloc Total KV cache blocks\":" + std::to_string(kvStats.allocTotalBlocks) + ",");
statJson.append("\"Alloc New KV cache blocks\":" + std::to_string(kvStats.allocNewBlocks) + ",");
statJson.append("\"Reused KV cache blocks\":" + std::to_string(kvStats.reusedBlocks) + ",");
}

Expand Down