vllm

package
v2.0.0-beta.11 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 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

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

View Source
const (
	ShortRPC = 2 * time.Minute
	PoolRPC  = 60 * time.Minute
)

RPC timeouts: moving a rank's pool is disk- and SHA-bound.

View Source
const RankHeader = "X-data-parallel-rank"

RankHeader routes a request to one data-parallel engine replica.

View Source
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

func CompareCanary(policy profile.Canary, want, got Canary) (string, error)

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.

func Prompt

func Prompt(n, variant int) []int

Prompt is a token-ID prompt of length n; variant makes the prompts of one batch distinct, so none of them hits another's prefix.

func WithRank

func WithRank(ctx context.Context, rank int) context.Context

WithRank routes the context's requests to one data-parallel replica.

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 Canary

type Canary = manifest.Canary

Canary is a miss and a hit of the same prompt on a fresh prefix cache.

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

func New(socket string, ranks int) *Engine

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

func (e *Engine) Allocations(ctx context.Context) ([]Table, error)

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) Describe

func (e *Engine) Describe(ctx context.Context) ([]Worker, error)

Describe asks every worker who it is.

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

func (e *Engine) FinishRestore(ctx context.Context) error

FinishRestore runs vLLM's checkpoint_restore, then warmctl's, on a restored, still sleeping engine.

func (*Engine) Health

func (e *Engine) Health(ctx context.Context) error

Health is GET /health.

func (*Engine) PrepareCheckpoint

func (e *Engine) PrepareCheckpoint(ctx context.Context) ([]Prepared, error)

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

func (e *Engine) ReplyThrough(host, guest string)

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

func (e *Engine) ResetPrefixCache(ctx context.Context) error

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) Sleep

func (e *Engine) Sleep(ctx context.Context, level int) error

Sleep puts the engine to sleep at level and checks it sleeps.

func (*Engine) Sleeping

func (e *Engine) Sleeping(ctx context.Context) (bool, error)

Sleeping is GET /is_sleeping.

func (*Engine) WaitReady

func (e *Engine) WaitReady(ctx context.Context, timeout time.Duration, alive func() error) error

WaitReady polls /health until it answers 200. alive is checked between polls; its error (the engine died) ends the wait.

func (*Engine) WakeUp

func (e *Engine) WakeUp(ctx context.Context, tags ...string) error

WakeUp maps the given tags back (all when none are given).

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 HTTPError

type HTTPError struct {
	Path   string
	Status int
	Body   string
}

HTTPError is a non-200 answer.

func (*HTTPError) Error

func (e *HTTPError) Error() string

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 Row

type Row = manifest.Row

Row is one choice: generated token IDs and their logprobs.

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.

Jump to

Keyboard shortcuts

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