transfer

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

View Source
const (
	// ConnectorTypeIdentifier is the pod label that specifies the KV transfer backend.
	ConnectorTypeIdentifier = "model.aibrix.ai/kv-connector-type"

	ConnectorTypeSHFS     = "shfs"
	ConnectorTypeNIXL     = "nixl"
	ConnectorTypeMooncake = "mooncake"
)

Variables

This section is empty.

Functions

func AllControlledFields added in v0.8.0

func AllControlledFields() []string

AllControlledFields returns the sorted, de-duplicated union of ControlledFields over every registered agent. It is used to validate a request before the prefill pod (and therefore the connector) is known.

func Register

func Register(name string, factory func() KVTransferAgent)

Register makes a KVTransferAgent factory available under name. Called from init() in each agent file.

func ResolveConnectorType

func ResolveConnectorType(podLabelValue, globalDefault string) string

ResolveConnectorType resolves the effective connector type from a pod label value, falling back to globalDefault when the label is absent or unrecognized.

func ValidAgentNames

func ValidAgentNames() []string

ValidAgentNames returns a sorted list of registered connector type names.

Types

type KVTransferAgent

type KVTransferAgent interface {
	// Type returns the connector identifier (e.g. "shfs", "nixl", "mooncake").
	Type() string

	// AugmentPrefillRequest returns body with any fields the prefill pod
	// requires before the HTTP request is sent (e.g. kv_transfer_params for
	// SHFS). body is the client request already validated as a JSON object.
	AugmentPrefillRequest(
		routingCtx *types.RoutingContext,
		prefillPod *v1.Pod,
		body []byte,
	) ([]byte, error)

	// MergePrefillResponse injects connector-specific metadata from the raw
	// prefill response into routingCtx.ReqBody before the request is forwarded
	// to the decode pod.
	MergePrefillResponse(
		routingCtx *types.RoutingContext,
		prefillResponse []byte,
		prefillPod *v1.Pod,
	) error

	// ControlledFields returns the top-level keys, in addition to
	// pd.CommonControlledFields, that AugmentPrefillRequest or
	// MergePrefillResponse may write. Client bodies repeating any of them
	// are rejected before routing.
	ControlledFields() []string
}

KVTransferAgent owns connector-specific request and response mutation for one KV transfer backend. Each implementation handles one backend (SHFS, NIXL, Mooncake, …).

Both methods work on raw JSON bytes and must only touch top-level keys (or the gateway-owned kv_transfer_params object); see engine.EngineHandler for why a map[string]any round trip is not acceptable here.

func Resolve

func Resolve(connectorType string) (KVTransferAgent, error)

Resolve returns a new KVTransferAgent for the given connector type. Returns an error for unknown types.

func ResolveAgentForPod

func ResolveAgentForPod(pod *v1.Pod, globalDefault string) (KVTransferAgent, error)

ResolveAgentForPod resolves the KVTransferAgent for a pod. It checks the ConnectorTypeIdentifier pod label first, then falls back to globalDefault.

type MooncakeAgent

type MooncakeAgent struct{}

MooncakeAgent implements KVTransferAgent for the Mooncake KV transfer backend. TODO: implement based on confirmed vLLM MooncakeConnector contract.

func (*MooncakeAgent) AugmentPrefillRequest

func (a *MooncakeAgent) AugmentPrefillRequest(
	_ *types.RoutingContext,
	_ *v1.Pod,
	body []byte,
) ([]byte, error)

AugmentPrefillRequest adds any Mooncake-specific fields to the prefill request. TODO: implement once vLLM MooncakeConnector prefill request contract is confirmed.

func (*MooncakeAgent) ControlledFields added in v0.8.0

func (a *MooncakeAgent) ControlledFields() []string

ControlledFields is empty until the Mooncake contract is implemented.

func (*MooncakeAgent) MergePrefillResponse

func (a *MooncakeAgent) MergePrefillResponse(
	_ *types.RoutingContext,
	_ []byte,
	_ *v1.Pod,
) error

MergePrefillResponse injects Mooncake-specific metadata from the prefill response into routingCtx.ReqBody before the request is forwarded to the decode pod. TODO: implement once vLLM MooncakeConnector response contract is confirmed.

func (*MooncakeAgent) Type

func (a *MooncakeAgent) Type() string

type NIXLAgent

type NIXLAgent struct{}

NIXLAgent implements KVTransferAgent for the NIXL backend (Neuron).

func (*NIXLAgent) AugmentPrefillRequest

func (a *NIXLAgent) AugmentPrefillRequest(
	_ *types.RoutingContext,
	_ *v1.Pod,
	body []byte,
) ([]byte, error)

AugmentPrefillRequest is a no-op for NIXL: the backend manages KV transfer through its own mechanism and does not require a prefill request skeleton.

func (*NIXLAgent) ControlledFields added in v0.8.0

func (a *NIXLAgent) ControlledFields() []string

ControlledFields returns disagg_prefill_resp, written on the decode body.

func (*NIXLAgent) MergePrefillResponse

func (a *NIXLAgent) MergePrefillResponse(
	routingCtx *types.RoutingContext,
	prefillResponse []byte,
	prefillPod *v1.Pod,
) error

MergePrefillResponse wraps the entire prefill response, verbatim, under disagg_prefill_resp so the NixlConnector on the decode side can locate and pull the KV blocks.

func (*NIXLAgent) Type

func (a *NIXLAgent) Type() string

type SHFSAgent

type SHFSAgent struct{}

SHFSAgent implements KVTransferAgent for the AIBrix SHFS/KVCacheManager backend (GPU).

func (*SHFSAgent) AugmentPrefillRequest

func (a *SHFSAgent) AugmentPrefillRequest(
	_ *types.RoutingContext,
	_ *v1.Pod,
	body []byte,
) ([]byte, error)

AugmentPrefillRequest replaces kv_transfer_params with the skeleton the prefill pod expects, in a single top-level edit. Any client-supplied kv_transfer_params is dropped; nothing else in body changes.

func (*SHFSAgent) ControlledFields added in v0.8.0

func (a *SHFSAgent) ControlledFields() []string

ControlledFields returns kv_transfer_params, written on both bodies.

func (*SHFSAgent) MergePrefillResponse

func (a *SHFSAgent) MergePrefillResponse(
	routingCtx *types.RoutingContext,
	prefillResponse []byte,
	prefillPod *v1.Pod,
) error

MergePrefillResponse copies kv_transfer_params verbatim from the prefill response into routingCtx.ReqBody, with remote_host set to the prefill pod IP, so the decode pod can pull the KV cache blocks. A response without kv_transfer_params leaves the decode body unchanged.

func (*SHFSAgent) Type

func (a *SHFSAgent) Type() string

Jump to

Keyboard shortcuts

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