-
Notifications
You must be signed in to change notification settings - Fork 104
feat: Add initial metrics and update dependencies #414
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
Merged
Merged
Changes from all commits
Commits
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Metrics | ||
|
|
||
| The `llm-d-inference-scheduler` exposes the following Prometheus metrics to monitor its behavior and performance, particularly concerning Prefill/Decode Disaggregation. | ||
|
|
||
| All metrics are in the `llm_d_inference_scheduler` subsystem. | ||
|
|
||
| ## Scrape and see the metric | ||
|
|
||
| Metrics defined in llm-d-scheduler are in addition to Inference Gateway metrics. For more details of seeing metrics, see the [metrics and observability section](https://github.com/kubernetes-sigs/gateway-api-inference-extension/blob/main/site-src/guides/metrics-and-observability.md). | ||
|
|
||
| ## Metrics Details | ||
|
|
||
| ### `pd_decision_total` | ||
|
|
||
| * **Type:** Counter | ||
| * **Labels:** | ||
| * `decision_type`: string ("decode-only" or "prefill-decode") | ||
| * **Release Stage:** ALPHA | ||
| * **Description:** Counts the number of requests processed, broken down by the Prefill/Decode disaggregation decision. | ||
| * `prefill-decode`: The request was split into separate Prefill and Decode stages. | ||
| * `decode-only`: The request used the Decode-only path. | ||
| * **Usage:** Provides a high-level view of how many requests are utilizing the disaggregated path versus the unified path. | ||
| * **Actionability:** | ||
| * Monitor the ratio of "prefill-decode" to "decode-only" to understand the P/D engagement rate. | ||
| * Sudden changes in this ratio might indicate configuration issues, changes in workload patterns, or problems with the decision logic. |
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 |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // Package metrics provides metrics registration for the epp. | ||
| package metrics | ||
|
|
||
| import ( | ||
| "github.com/prometheus/client_golang/prometheus" | ||
| compbasemetrics "k8s.io/component-base/metrics" | ||
| "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/util/metrics" | ||
| ) | ||
|
|
||
| const ( | ||
| // SchedulerSubsystem is the metric prefix of the package. | ||
| SchedulerSubsystem = "llm_d_inference_scheduler" | ||
|
|
||
| // DecisionTypeDecodeOnly is for requests that are routed to decode instance only. | ||
| DecisionTypeDecodeOnly = "decode-only" | ||
| // DecisionTypePrefillDecode is for requests that are gone through P/D. | ||
| DecisionTypePrefillDecode = "prefill-decode" | ||
| ) | ||
|
|
||
| var ( | ||
| // SchedulerPDDecisionCount records request P/D decision. | ||
| SchedulerPDDecisionCount = prometheus.NewCounterVec( | ||
| prometheus.CounterOpts{ | ||
| Subsystem: SchedulerSubsystem, | ||
| Name: "pd_decision_total", | ||
| Help: metrics.HelpMsgWithStability("Total number of P/D disaggregation decisions made", compbasemetrics.ALPHA), | ||
| }, | ||
| []string{"decision_type"}, // "decode-only" or "prefill-decode" | ||
| ) | ||
| ) | ||
|
|
||
| // GetCollectors returns all custom collectors for the llm-d-inference-scheduler. | ||
| func GetCollectors() []prometheus.Collector { | ||
| return []prometheus.Collector{ | ||
| SchedulerPDDecisionCount, | ||
| } | ||
| } | ||
|
|
||
| // RecordPDDecision records the type of P/D disaggregation decision made. | ||
| func RecordPDDecision(decisionType string) { | ||
| SchedulerPDDecisionCount.WithLabelValues(decisionType).Inc() | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package metrics | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/prometheus/client_golang/prometheus/testutil" | ||
| ) | ||
|
|
||
| func TestSchedulerPDDecisionCount(t *testing.T) { | ||
| RecordPDDecision(DecisionTypePrefillDecode) | ||
| RecordPDDecision(DecisionTypeDecodeOnly) | ||
| RecordPDDecision(DecisionTypePrefillDecode) | ||
| if err := testutil.CollectAndCompare(SchedulerPDDecisionCount, strings.NewReader(` | ||
| # HELP llm_d_inference_scheduler_pd_decision_total [ALPHA] Total number of P/D disaggregation decisions made | ||
| # TYPE llm_d_inference_scheduler_pd_decision_total counter | ||
| llm_d_inference_scheduler_pd_decision_total{decision_type="decode-only"} 1 | ||
| llm_d_inference_scheduler_pd_decision_total{decision_type="prefill-decode"} 2 | ||
| `), "decision_type"); err != nil { | ||
| t.Errorf("RecordPDDecision() failed: %v", err) | ||
| } | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.