tokenload

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

README

Token Load Scorer Plugin

Type: token-load-scorer

This plugin scores candidate endpoints based on the estimated number of in-flight tokens currently being processed by each model server.

What it does

For each scheduling cycle, the plugin reads the InFlightLoad attribute from each endpoint and computes a normalized score based on the total estimated tokens in flight:

$$ \text{score(endpoint)} = 1.0 - \min\left(1.0, \frac{\text{tokens(endpoint)}}{\text{queueThresholdTokens}}\right) $$

So:

  • 0 tokens in flight → score 1.0
  • queueThresholdTokens or more tokens → score 0.0
  • others are linearly scaled between them

This scoring mechanism provides a more granular signal than simple request concurrency by accounting for the size of the prompts being processed.

Scheduling intent

The scorer returns category Distribution, helping spread requests away from endpoints that are processing a high volume of tokens, which often correlates with higher latency and resource utilization.

Inputs consumed

The plugin consumes:

  • attrconcurrency.InFlightLoadDataKey (*attrconcurrency.InFlightLoad)

Configuration

The scorer supports the following runtime parameters:

  • queueThresholdTokens (integer, default: 4194304): The maximum number of in-flight tokens used for score normalization. Endpoints exceeding this threshold will receive a score of 0.0. The default (4Mi tokens) is equivalent to 128 requests with an average size of 32K tokens.

Configuration Example:

plugins:
  - type: token-load-scorer
    name: token-load
    parameters:
      queueThresholdTokens: 4194304
schedulingProfiles:
  - name: default
    plugins:
      - pluginRef: token-load
        weight: 1

Documentation

Index

Constants

View Source
const (
	TokenLoadScorerType = "token-load-scorer"
)

Variables

This section is empty.

Functions

func TokenLoadScorerFactory

func TokenLoadScorerFactory(name string, params *json.Decoder, _ fwkplugin.Handle) (fwkplugin.Plugin, error)

Types

type Config

type Config struct {
	// QueueThresholdTokens defines the maximum number of in-flight tokens used for scoring normalization.
	// Defaults to 4194304 if unset.
	QueueThresholdTokens     int64  `json:"queueThresholdTokens"`
	InFlightLoadProducerName string `json:"inFlightLoadProducerName,omitempty"`
}

Config holds the configuration for the TokenLoadScorer.

type TokenLoadScorer

type TokenLoadScorer struct {
	// contains filtered or unexported fields
}

func (*TokenLoadScorer) Category

func (s *TokenLoadScorer) Category() fwksched.ScorerCategory

func (*TokenLoadScorer) Consumes

func (*TokenLoadScorer) Score

func (*TokenLoadScorer) TypedName

func (s *TokenLoadScorer) TypedName() fwkplugin.TypedName

Jump to

Keyboard shortcuts

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