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 ¶
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.