Documentation
¶
Overview ¶
Copyright 2025 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Package utilization implements a reactive saturation detector and scheduling filter for LLM routing. It evaluates endpoint telemetry (queue depth and KV cache memory utilization) using a roofline model to determine physical system saturation and apply proportional backpressure.
For detailed architectural trade-offs and configuration, see the package README.
Index ¶
Constants ¶
const ( // DefaultQueueDepthThreshold is the default waiting queue size threshold. DefaultQueueDepthThreshold int = 5 // DefaultKVCacheUtilThreshold is the default KV cache utilization (0.0 to 1.0) threshold. DefaultKVCacheUtilThreshold float64 = 0.8 // DefaultMetricsStalenessThreshold defines how old metrics can be before they are considered // stale. DefaultMetricsStalenessThreshold time.Duration = 200 * time.Millisecond )
Default configuration values
const (
// UtilizationDetectorType is the unique identifier for this plugin.
UtilizationDetectorType = "utilization-detector"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
QueueDepthThreshold int
KVCacheUtilThreshold float64
MetricsStalenessThreshold time.Duration
Headroom float64
}
Config is the internal, fully-validated configuration used by the detector.
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
Detector determines system saturation based on metrics of the given candidate pods.
func NewDetector ¶
NewDetector creates a new instance of the Utilization Detector. The config provides the thresholds for determining saturation.
func (*Detector) Filter ¶
func (d *Detector) Filter( _ context.Context, _ *fwksched.InferenceRequest, endpoints []fwksched.Endpoint, ) []fwksched.Endpoint
Filter blocks traffic to specific pods that are physically saturated or exceeding their safety limits.
It applies a relaxed limit (Threshold * (1 + Headroom)) to allow for scheduling flexibility and burst tolerance.
func (*Detector) Saturation ¶
Saturation calculates the saturation level of the pool.
It returns an aggregate saturation signal where:
Saturation = Average(PodSaturationScore)
For each pod, the score is determined by the most constrained resource (Compute or Memory):
PodScore = Max(WaitingQueue / QueueThreshold, KVCacheUsage / KVCacheThreshold)