prefill

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: 15 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PreparePayload

func PreparePayload(routingCtx *types.RoutingContext, pod *v1.Pod, llmEngine string, handler engine.EngineHandler) ([]byte, error)

PreparePayload transforms routingCtx.ReqBody into a prefill-specific payload ready to be POSTed to the prefill pod.

The client body is validated as a JSON object, passed to handler.AugmentPrefillRequest for engine-specific field injection, and the common prefill constraints (max_tokens=1, max_completion_tokens=1, stream=false, no stream_options, no min_tokens) are applied on top with top-level sjson edits. Nested fields (messages, tools, …) are never re-serialised, so their byte ordering is identical in the original, prefill and decode bodies and prompt_token_ids stay stable across requests.

routingCtx.ReqBody is only changed by handlers that need a modified decode body (SGLang bootstrap fields); for every other engine the decode pod receives the client body untouched.

This function is exported so pdRouter can expose a thin backward-compat wrapper for tests that call preparePrefillPayload directly.

Types

type DefaultExecutor

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

DefaultExecutor is the standard PrefillExecutor. It owns the HTTP client and the prefill-request tracker so that prefill logic can be tested in isolation from the routing/scoring concerns in pdRouter.

func (*DefaultExecutor) Execute

func (e *DefaultExecutor) Execute(routingCtx *types.RoutingContext, prefillPod *v1.Pod, handler engine.EngineHandler, logCtx LogContext) error

Execute implements PrefillExecutor. handler is the one the router already resolved for this request, so validation and dispatch cannot drift onto different handlers for the same engine.

type ExecutorOption added in v0.8.0

type ExecutorOption func(*DefaultExecutor)

ExecutorOption customizes a DefaultExecutor.

func WithTokenLoadTracker added in v0.8.0

func WithTokenLoadTracker(tokenLoad *pd.TokenLoadTracker) ExecutorOption

WithTokenLoadTracker makes the executor release a request's active token-load charge (TokenLoadTracker.ReleaseTokens) at the same point where it removes the request from the PrefillRequestTracker: when the prefill HTTP call returns, on both the sync and the async path.

type LogContext

type LogContext struct {
	PrefillScorePolicy string
	DecodeScorePolicy  string
}

LogContext carries router-resolved metadata included in prefill structured logs.

type PrefillExecutor

type PrefillExecutor interface {
	Execute(routingCtx *types.RoutingContext, prefillPod *v1.Pod, handler engine.EngineHandler, logCtx LogContext) error
}

PrefillExecutor executes the prefill phase of a disaggregated-inference request. Implementations are responsible for payload preparation and HTTP dispatch (async or sync depending on the engine). PrefillRequestTracker registration happens at pod selection time; the executor removes the entry when prefill completes.

Execute takes the EngineHandler the router already resolved for this request, so validation (Route) and dispatch (Execute) cannot end up using different handlers for the same engine.

func NewDefaultExecutor

func NewDefaultExecutor(httpClient *http.Client, tracker *pd.PrefillRequestTracker, opts ...ExecutorOption) PrefillExecutor

NewDefaultExecutor constructs a DefaultExecutor. httpClient and tracker are shared with the router.

Jump to

Keyboard shortcuts

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