Repository navigation
[Bug] Fix per-model metrics cross-talk on multi-model pods - #2331
varungup90 merged 5 commits into
Conversation
Signed-off-by: Varshith <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request refactors the metrics fetcher to properly parse model-scoped metrics on multi-model pods by introducing parseModelMetricsFromFamily to parse and map distinct metric values per model_name. A unit test was also added to verify this behavior. Feedback highlights a critical issue where multiple metric instances sharing the same model_name but differing in other labels will overwrite each other in the map, leading to data loss. It is recommended to aggregate these values for counters and histograms to ensure accurate metric reporting.
Signed-off-by: Varshith <[email protected]>
|
Thanks for putting this together! This is a really solid fix for the metrics cross-talk issue on multi-model pods, and splitting out I noticed a few edge cases and potential robustness improvements while reviewing the implementation: 🛑 Potential Issues / Architectural Concerns
// TODO: confirm whether vLLM/SGLang uses the same label_key.
modelName, err := GetLabelValueForKey(familyMetric, "model_name")Carried over from
existingVal.Value += incomingVal.Value // modifies the pointer stored in modelMetrics
existingVal.Labels = map[string]string{"model_name": modelName}
return existingValThis works correctly because
value, err := ef.parseMetricInstance(...)
if err != nil {
return nil, err // entire metric family is dropped
}If a single malformed instance causes a parse error, the entire metric family is dropped for all models. While fine for pod-scoped metrics, for model-scoped metrics it might be more robust to log the error/continue rather than completely aborting.
🎨 Code Quality & Refactoring
|
Signed-off-by: Varshith <[email protected]>
|
Hi, I pushed af9bcac addressing all of these.
Also trimmed both docstrings. go test ./pkg/metrics/ -run TestEngineMetricsFetcher_FetchAllTypedMetrics -v === RUN TestEngineMetricsFetcher_FetchAllTypedMetrics |
Pull Request Description
FetchAllTypedMetricsparses a model-scoped metric family once throughparseMetricFromFamily, which reads onlymetricFamily.Metric[0], then assigns that singleMetricValueto everymodel_namefound in the family. On a pod that exposes the same metric under more than onemodel_name, every model ends up pointing at the first instance's value. The pointer is shared, sosanitizeMetricValueLabelsrewrites one labels map on behalf of all of them, which makes themodel_namelabel wrong too.This change parses model-scoped metrics per
model_name.parseModelMetricsFromFamilyiterates every instance in the family, matchesmodel_name, and parses each one throughparseMetricInstance, the per-instance type switch extracted fromparseMetricFromFamily. Each model therefore gets its own value and its own labels map.parseMetricFromFamilykeeps theMetric[0]path for pod-scoped metrics, which are not differentiated bymodel_name.extractModelNamesFromMetricsis removed because it only returned names and the new name-to-value helper supersedes it.TestEngineMetricsFetcher_FetchAllTypedMetrics/FetchMultiModelMetricsscrapesvllm_num_requests_runningandvllm_num_requests_waitingunder twomodel_names and asserts eachmodel/metrickey holds its own value andmodel_namelabel. It fails on the current code, wheremodel-breadsmodel-a's value3and labelmodel-a, and passes with this change. The existing single-model and pod-scoped tests are unchanged.Related Issues
Resolves: #2229
Important: Before submitting, please complete the description above and review the checklist below.
Contribution Guidelines (Expand for Details)
We appreciate your contribution to aibrix! To ensure a smooth review process and maintain high code quality, please adhere to the following guidelines:
Pull Request Title Format
Your PR title should start with one of these prefixes to indicate the nature of the change:
[Bug]: Corrections to existing functionality[CI]: Changes to build process or CI pipeline[Docs]: Updates or additions to documentation[API]: Modifications to aibrix's API or interface[CLI]: Changes or additions to the Command Line Interface[Misc]: For changes not covered above (use sparingly)Note: For changes spanning multiple categories, use multiple prefixes in order of importance.
Submission Checklist
By submitting this PR, you confirm that you've read these guidelines and your changes align with the project's contribution standards.