Documentation
¶
Overview ¶
Package vllm drives a vLLM API server through the agent's inference socket: lifecycle (health, sleep, wake), the worker RPC that reaches warmctl's extension, and token-ID completions for warmup and canaries.
Index ¶
- Constants
- func CompareCanary(policy profile.Canary, want, got Canary) (string, error)
- func Prompt(n, variant int) []int
- func WithRank(ctx context.Context, rank int) context.Context
- type Allocation
- type Canary
- type Completion
- type Engine
- func (e *Engine) Allocations(ctx context.Context) ([]Table, error)
- func (e *Engine) Complete(ctx context.Context, model string, promptTokens, batch, maxTokens int) (Completion, error)
- func (e *Engine) Describe(ctx context.Context) ([]Worker, error)
- func (e *Engine) ExportPool(ctx context.Context, directory string, partBytes int64, threads int) ([]Export, error)
- func (e *Engine) FinishRestore(ctx context.Context) error
- func (e *Engine) Health(ctx context.Context) error
- func (e *Engine) PrepareCheckpoint(ctx context.Context) ([]Prepared, error)
- func (e *Engine) RPC(ctx context.Context, method string, kwargs any, timeout time.Duration, out any) error
- func (e *Engine) ReloadPool(ctx context.Context, manifestPath, directory string, threads int, verify bool) ([]Reloaded, error)
- func (e *Engine) ReplyThrough(host, guest string)
- func (e *Engine) ResetPrefixCache(ctx context.Context) error
- func (e *Engine) RunCanary(ctx context.Context, model string, promptTokens, maxTokens int) (Canary, error)
- func (e *Engine) Sleep(ctx context.Context, level int) error
- func (e *Engine) Sleeping(ctx context.Context) (bool, error)
- func (e *Engine) WaitReady(ctx context.Context, timeout time.Duration, alive func() error) error
- func (e *Engine) WakeUp(ctx context.Context, tags ...string) error
- func (e *Engine) Warmup(ctx context.Context, model string, dp int, cases []profile.WarmupCase, ...) error
- type Export
- type HTTPError
- type Prepared
- type Reloaded
- type Row
- type Table
- type Worker
Constants ¶
const ( ShortRPC = 2 * time.Minute PoolRPC = 60 * time.Minute )
RPC timeouts: moving a rank's pool is disk- and SHA-bound.
const RankHeader = "X-data-parallel-rank"
RankHeader routes a request to one data-parallel engine replica.
const Seed = 42
Seed of every warmctl request: greedy, seeded, so two engines with the same weights produce the same tokens.
Variables ¶
This section is empty.
Functions ¶
func CompareCanary ¶
CompareCanary checks a restored canary against the donor's under the profile's policy. It returns a one-line summary; the error is set only when the policy fails the restore.
Types ¶
type Allocation ¶
type Allocation struct {
Ptr string `json:"ptr"`
Bytes int64 `json:"bytes"`
Tag string `json:"tag"`
Asleep bool `json:"asleep"`
}
Allocation is one row of warmctl_allocations.
type Completion ¶
type Completion struct {
Rows []Row `json:"rows"`
PromptTokens int `json:"prompt_tokens"`
CachedTokens int `json:"cached_tokens"`
Seconds float64 `json:"seconds"`
}
Completion is one /v1/completions answer.
type Engine ¶
type Engine struct {
// Ranks is the number of workers (TP x DP) every RPC must answer for.
Ranks int
// contains filtered or unexported fields
}
Engine is one API server, reached over a unix socket.
func New ¶
New connects through socket. Keep-alive is off: an idle connection into the engine would be an established TCP socket in the dumped tree.
func (*Engine) Allocations ¶
Allocations reads every rank's allocator table.
func (*Engine) Complete ¶
func (e *Engine) Complete(ctx context.Context, model string, promptTokens, batch, maxTokens int) (Completion, error)
Complete runs batch prompts of promptTokens, generating maxTokens each.
func (*Engine) ExportPool ¶
func (e *Engine) ExportPool(ctx context.Context, directory string, partBytes int64, threads int) ([]Export, error)
ExportPool fingerprints and writes every rank's weights pool under directory (a path inside the container).
func (*Engine) FinishRestore ¶
FinishRestore runs vLLM's checkpoint_restore, then warmctl's, on a restored, still sleeping engine.
func (*Engine) PrepareCheckpoint ¶
PrepareCheckpoint runs vLLM's checkpoint_prepare, then warmctl's, on a sleeping engine.
func (*Engine) RPC ¶
func (e *Engine) RPC(ctx context.Context, method string, kwargs any, timeout time.Duration, out any) error
RPC calls method on every worker through /collective_rpc and decodes the per-rank results into out (a pointer to a slice), which must hold Ranks rows.
func (*Engine) ReloadPool ¶
func (e *Engine) ReloadPool(ctx context.Context, manifestPath, directory string, threads int, verify bool) ([]Reloaded, error)
ReloadPool copies every rank's pool back from the snapshot mounted at directory, whose manifest is at manifestPath, and checks fingerprints.
func (*Engine) ReplyThrough ¶
ReplyThrough sends every RPC through the adapter's warmctl_rpc, which publishes each rank's result under guest, seen here as host. A data-parallel engine needs it: /collective_rpc runs on every engine core but answers with the first engine's workers only (vLLM's DPLBAsyncMPClient.call_utility_async).
func (*Engine) ResetPrefixCache ¶
ResetPrefixCache empties the prefix cache.
func (*Engine) RunCanary ¶
func (e *Engine) RunCanary(ctx context.Context, model string, promptTokens, maxTokens int) (Canary, error)
RunCanary sends the canary prompt twice. On a restored engine the first must miss (the KV cache came back empty) and the second must hit.
func (*Engine) WaitReady ¶
WaitReady polls /health until it answers 200. alive is checked between polls; its error (the engine died) ends the wait.
func (*Engine) Warmup ¶
func (e *Engine) Warmup(ctx context.Context, model string, dp int, cases []profile.WarmupCase, report func(i int, c profile.WarmupCase, seconds float64)) error
Warmup runs every case after a prefix-cache reset, so each prefill really runs and replays (or captures) its graphs. report is called after each case.
type Export ¶
type Export struct {
Rank int `json:"rank"`
PID int `json:"pid"`
Allocations []manifest.Allocation `json:"allocations"`
Parts []manifest.Part `json:"parts"`
Seconds float64 `json:"seconds"`
}
Export is warmctl_export_pool of one rank.
type Prepared ¶
type Prepared struct {
Rank int `json:"rank"`
Collectives []string `json:"collectives"`
Detached bool `json:"detached"`
NCCLMode string `json:"nccl_mode"`
}
Prepared is warmctl_sleep_prepare of one rank.
type Reloaded ¶
type Reloaded struct {
Rank int `json:"rank"`
Bytes int64 `json:"bytes"`
Allocations int `json:"allocations"`
Seconds float64 `json:"seconds"`
}
Reloaded is warmctl_reload_pool of one rank.
type Table ¶
type Table struct {
Rank int `json:"rank"`
Allocations []Allocation `json:"allocations"`
}
Table is warmctl_allocations of one rank.
type Worker ¶
type Worker struct {
Rank int `json:"rank"`
PID int `json:"pid"`
Device int `json:"device"`
Name string `json:"name"`
Arch string `json:"arch"`
PCIBusID string `json:"pci_bus_id"`
UUID string `json:"uuid"`
VLLM string `json:"vllm"`
Torch string `json:"torch"`
AdapterSHA256 string `json:"adapter_sha256"`
}
Worker is warmctl_describe of one rank.