configprofiles

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package configprofiles parses the model.aibrix.ai/config annotation (or ConfigMap) and supports multiple named profiles selectable at runtime via config-profile header. See docs/source/designs/model-config-profiles.rst for the design.

Index

Constants

View Source
const (
	// DefaultProfileName is used when defaultProfile is not set in the JSON.
	DefaultProfileName = "default"
)

Variables

This section is empty.

Functions

func ParseRoutingConfig added in v0.8.0

func ParseRoutingConfig(raw json.RawMessage) *types.RoutingConfig

ParseRoutingConfig parses a profile's routingConfig into its typed form. It returns nil when the raw config is empty or unparsable, which leaves every knob at its process default; a value the matching AIBRIX_* variable would reject is dropped later, when the routing algorithm package resolves the request's overrides (routingalgorithms.ResolveRoutingOverrides).

Types

type ModelConfigProfile

type ModelConfigProfile struct {
	RoutingStrategy string          `json:"routingStrategy"`
	RoutingConfig   json.RawMessage `json:"routingConfig,omitempty"`
	// RequestsPerSecond caps the aggregate request rate for the model across all
	// replicas. Superseded by RequestsPerSecondPerReplica when both are set.
	RequestsPerSecond int64 `json:"requestsPerSecond,omitempty"`
	// RequestsPerSecondPerReplica sets a per-replica request-per-second limit; the gateway
	// multiplies it by the model's current routable replica count to derive the effective
	// aggregate rate, so throughput scales automatically with replica count. Takes
	// precedence over RequestsPerSecond when both are set. Supports fractional values
	// (e.g. 0.5) for sub-1 rps limits, expressed as "1 request every N seconds".
	RequestsPerSecondPerReplica float64 `json:"requestsPerSecondPerReplica,omitempty"`
	// RequestsInflight caps the number of concurrent (in-flight) requests allowed on a
	// single replica. Unlike RequestsPerSecond this is enforced per pod, not as an
	// aggregate, so it needs no replica-count scaling.
	RequestsInflight int64 `json:"requestsInflight,omitempty"`
	// TTFTThresholdS overrides AIBRIX_TTFT_THRESHOLD_S for requests routed with this
	// profile: the time-to-first-token threshold, in seconds, above which the gateway
	// classifies the first token as delayed. Zero or unset keeps the env default.
	TTFTThresholdS int64 `json:"ttftThresholdS,omitempty"`
}

ModelConfigProfile holds gateway options for a single profile.

func ResolveConfig added in v0.8.0

func ResolveConfig(pods []*v1.Pod, headerProfile string) (*ModelConfigProfile, string)

ResolveConfig resolves the model config from the first pod carrying a model.aibrix.ai/config annotation. It returns the profile selected by headerProfile (nil when no selectable profile exists) together with the model-wide locked routing strategy ("" when unset). The locked strategy applies even when no profile resolves.

func ResolveConfigForRequest added in v0.8.0

func ResolveConfigForRequest(pods []*v1.Pod, headerProfile string, features RequestFeatures) (*ModelConfigProfile, string, string)

ResolveConfigForRequest resolves the model config from the first pod carrying a model.aibrix.ai/config annotation. If headerProfile is "auto", request-local hints in each profile's routingConfig are evaluated and the returned profileName is the concrete profile selected for this request.

func ResolveProfileFromPod

func ResolveProfileFromPod(pod *v1.Pod, headerProfile string) *ModelConfigProfile

ResolveProfileFromPod resolves the model config from a single pod annotation and returns the selected profile. The profile is selected by headerProfile; an empty headerProfile falls back to the default profile. Returns nil when the pod has no config annotation, the config is invalid, or no selectable profile exists.

type ModelConfigProfiles

type ModelConfigProfiles struct {
	// LockedRoutingStrategy, when set, pins the routing strategy model-wide.
	// It takes precedence over the routing-strategy request header, the per-profile
	// routingStrategy and the ROUTING_ALGORITHM environment variable.
	LockedRoutingStrategy string `json:"lockedRoutingStrategy,omitempty"`
	// AuthoritativeRoutingPolicy makes model configuration authoritative for
	// request routing. When true, the gateway ignores application-supplied routing
	// controls and omits routing diagnostics from the client response while
	// preserving its internally generated routing headers.
	AuthoritativeRoutingPolicy bool                          `json:"authoritativeRoutingPolicy,omitempty"`
	DefaultProfile             string                        `json:"defaultProfile"`
	Profiles                   map[string]ModelConfigProfile `json:"profiles"`
}

ModelConfigProfiles is the root JSON structure from model.aibrix.ai/config.

func ParseModelConfig

func ParseModelConfig(jsonStr string) (*ModelConfigProfiles, error)

ParseModelConfig parses the JSON from annotation data. Returns nil if jsonStr is empty or invalid.

func ResolveModelConfig added in v0.8.0

func ResolveModelConfig(pods []*v1.Pod) *ModelConfigProfiles

ResolveModelConfig returns the model config from the first pod carrying a valid model.aibrix.ai/config annotation. It returns nil when no pod has a valid config.

func (*ModelConfigProfiles) DefaultProfileOrName added in v0.8.0

func (c *ModelConfigProfiles) DefaultProfileOrName() string

DefaultProfileOrName returns defaultProfile, or "default" when it is not set.

func (*ModelConfigProfiles) GetProfile

func (c *ModelConfigProfiles) GetProfile(name string) *ModelConfigProfile

GetProfile returns the profile for the given name, or the default profile. Falls back to defaultProfile/"default" when the requested profile does not exist. Returns nil only if no default profile exists.

func (*ModelConfigProfiles) GetProfileExact added in v0.8.0

func (c *ModelConfigProfiles) GetProfileExact(name string) *ModelConfigProfile

GetProfileExact returns the named profile without falling back.

func (*ModelConfigProfiles) ResolveAutoProfileName added in v0.8.0

func (c *ModelConfigProfiles) ResolveAutoProfileName(features RequestFeatures) string

ResolveAutoProfileName resolves config-profile: auto to a concrete profile name.

func (*ModelConfigProfiles) ResolveForRequest added in v0.8.0

func (c *ModelConfigProfiles) ResolveForRequest(headerProfile string, features RequestFeatures) (*ModelConfigProfile, string, string)

ResolveForRequest selects a profile from c for one request. An empty profile name selects defaultProfile (or "default"). The authoritative routing policy is enforced by the caller clearing client routing inputs before calling this method; profile resolution itself retains the standard selection semantics.

type RequestFeatures added in v0.8.0

type RequestFeatures struct {
	PromptTokens *int
	MaxTokens    *int64
}

RequestFeatures are the request attributes used by automatic profile selection.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL