restore

package
v2.0.0-beta.19 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 38 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 restore brings a snapshot back to serving: a receiver container installs the archived trees, CRIU restores the process tree stopped, the agent thaws it and puts its CUDA state on this host's GPUs, the engine reloads its weights pool and checks it, and the host gateway opens.

Index

Constants

View Source
const (
	// ModeAuto decides: in place in the warmctl runtime image, else
	// through Docker.
	ModeAuto = "auto"
	// ModeHost creates a receiver container through the Docker API.
	ModeHost = "host"
	// ModeInPlace restores in this container, which a runtime (Kubernetes)
	// made as a receiver container (docs/kubernetes.md).
	ModeInPlace = "in-place"
)

Where `up` restores.

View Source
const (
	// DefaultRunDir holds a pod restore's agent config, sockets and CRIU
	// work: a volume of the pod's own.
	DefaultRunDir = "/run/warmctl"
	// DefaultPodListen is the gateway in a pod. The restored engine has
	// 127.0.0.1:8000 of the pod's network namespace.
	DefaultPodListen = ":8080"
)

Pod defaults.

Variables

View Source
var ErrStopped = errors.New("engine exited")

ErrStopped is returned when the engine exits while serving.

Functions

func CanRestore

func CanRestore(m manifest.Manifest, inPlace bool, tools dmtcp.Tools) error

CanRestore says whether this host brings back a tree m's backend dumped, in place or through Docker, before anything is pulled. A receiver container gets CRIU's capabilities from Docker; in place, CRIU needs a container that may checkpoint. A DMTCP snapshot restarts only in place, in a container like the one it was taken in, with DMTCP installed.

func CheckHost

func CheckHost(ctx context.Context, h manifest.Hardware, spec, locks string) ([]host.GPU, error)

CheckHost chooses the GPUs a snapshot taken on h restores onto, the ones spec lists or else the first free ones of its model, and checks that it can restore there. It takes no lease, so it can run before a pull.

func Choose

func Choose(ctx context.Context, mode string, p Probe) (bool, string, error)

Choose decides where to restore: an explicit mode wins; the runtime image's marker means in place; else the Docker API, as on any host. Missing Docker alone proves nothing, so without either it fails. The reason is a log line for an in-place restore, empty for a host one.

func Compatible

func Compatible(h manifest.Hardware, gpus []host.GPU, topology string, flags []string) error

Compatible checks this host against the snapshot's: the same GPU model, memory and driver, as many GPUs, the same topology class, and every CPU feature the donor had.

func Concurrent

func Concurrent(mode string, p manifest.Process) bool

Concurrent decides whether the owners without a rank (API servers, engine cores) also restore concurrently, and every owner unlocks at once: in auto whenever the workers do, since no process then maps another's memory. parallel keeps them serial, the order first qualified on GPUs.

func Fits

func Fits(ctx context.Context, h manifest.Hardware) error

Fits checks that this host has GPUs a snapshot taken on h restores onto, whether or not they are busy now: what a pull for later needs.

func KubernetesSigns

func KubernetesSigns() []string

KubernetesSigns are what kubelet leaves in a pod's container.

func ModelDir

func ModelDir(given string, m manifest.Manifest) (string, error)

ModelDir is the model directory to mount in the receiver: the operator's, else, when the dumped processes keep model files open, the donor's if this host has it.

func Parallel

func Parallel(mode string, p manifest.Process) bool

Parallel decides whether the workers' CUDA restores run concurrently: only when no collective keeps peer memory mapped between them, unless the operator forces serial.

func PodGPUs

func PodGPUs(ctx context.Context) (string, error)

PodGPUs is the --gpus list of the GPUs the NVIDIA device plugin gave this pod, from NVIDIA_VISIBLE_DEVICES, or "" when it names none: then the restore takes the first free GPUs of the snapshot's model, as on a host.

func Prefetch

func Prefetch(ctx context.Context, dir string, m manifest.Manifest, st *prefetchStats)

Prefetch reads a snapshot's CRIU images and its weights into the page cache with parallel readers while CRIU and cuda-checkpoint restore, so a cold restore from remote storage overlaps reading with the restore steps and the weights reload reads from memory. It reads at most what the host can cache besides the restored processes. By default every reader starts on the CRIU images, which CRIU needs first; WARMCTL_PREFETCH_ORDER=together starts half of them on the weights at once.

func Run

func Run(ctx context.Context, o Options) error

Run restores and, with Serve, serves until ctx ends.

func Stage

func Stage(ctx context.Context, dir, dst string, m manifest.Manifest, done func(path string)) (int64, error)

Stage copies the snapshot in dir to dst, every file of m and its manifest.json, many ranges in flight, and returns how many bytes it read from dir. A file stored as zstd frames is decoded frame by frame on the workers, so dst always holds the files as they are. It is for a snapshot directory on a FUSE file system (an S3 bucket behind geesefs, as a RunPod Global Volume, or MooseFS, as its network volumes): FUSE keeps no page cache the prefetch could fill for later readers, and the restore's readers (CRIU or dmtcp_restart, the weights reload) read one stream each. The files go lane by lane, those the receiver starts with, those the process restore reads, the weights, and done, when set, hears of each file once it is complete: the restore runs while the weights still come. A copy whose manifest.json matches is complete and is reused: manifest.json is written last. An encoded snapshot is staged wherever it is.

func VisibleGPUs

func VisibleGPUs(listed []string, inventory []host.GPU) (string, error)

VisibleGPUs turns device plugin names (UUIDs or indices) into indices.

Types

type Arrival

type Arrival interface {
	Manifest() manifest.Manifest
	// ManifestJSON is the bytes manifest.json will hold.
	ManifestJSON() []byte
	// Wait returns once every file of paths is in place, or with the error
	// that ended the pull.
	Wait(ctx context.Context, paths []string) error
}

Arrival is a snapshot still being pulled: its manifest is known, and its files appear in its directory as they are checked, manifest.json last.

type Gate

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

Gate is a pod restore's gateway, open before the snapshot is pulled so that the pod's probes get an answer from the start: /health is 503 and every inference route refused until the restore admits.

func OpenGate

func OpenGate(listen string, t *gateway.TLS, runDir string, p *run.Progress) (*Gate, error)

OpenGate listens on listen, with TLS from the first probe when t is set, and will forward to the agent's inference socket under runDir.

func (*Gate) Addr

func (g *Gate) Addr() net.Addr

Addr is where the gate listens.

func (*Gate) Close

func (g *Gate) Close() error

Close drains the admitted requests and stops listening.

type Instance

type Instance struct {
	ID        string    `json:"id"`
	Container string    `json:"container"`
	PID       int       `json:"pid"`
	Snapshot  string    `json:"snapshot"`
	Listen    string    `json:"listen"`
	Started   time.Time `json:"started"`
}

Instance is <state>/restores/<id>/instance.json: what `warmctl stop` needs to find a running restore.

type Options

type Options struct {
	Snapshot       string
	ID             string
	GPUs           string
	Listen         string
	StateDir       string
	DockerSocket   string
	CUDAExecution  string
	Canary         string
	ModelDir       string
	CRIU           string
	CUDACheckpoint string
	// CUDABackend is the agent's cuda.Select mode: auto, driver or cli.
	CUDABackend   string
	NoVerify      bool
	VerifyWeights bool
	// SyncWeights reloads the weights with synchronous copies instead of
	// the pipelined ones.
	SyncWeights bool
	Threads     int
	CPUTest     bool
	// Serve keeps the engine serving until ctx ends; otherwise Run returns
	// once serving started and leaves the receiver running.
	Serve bool
	// InPlace restores in this container, which Kubernetes made as the
	// receiver (docs/kubernetes.md): the agent runs as this process's
	// child instead of in a Docker container.
	InPlace bool
	// RunDir, in place, holds the agent's config, sockets and CRIU work.
	RunDir string
	// DMTCP restarts a snapshot the dmtcp backend took.
	DMTCP dmtcp.Tools
	// Gate, in place, is the gateway, opened before the pull.
	Gate *Gate
	// Arrival, when set, is the pull still filling Snapshot: the restore
	// starts on the files it reads first and waits for the weights before
	// the engine wakes, not for the pull to end.
	Arrival  Arrival
	Progress *run.Progress
	// TLSCert and TLSKey are --tls-cert and --tls-key; TLS is the pair
	// loaded from them, nil for plain HTTP.
	TLSCert string
	TLSKey  string
	TLS     *gateway.TLS
}

Options of one restore.

type Probe

type Probe struct {
	// Runtime reads the runtime image's marker.
	Runtime func() (run.Runtime, bool, error)
	// Docker is nil when the Docker API answers.
	Docker func(context.Context) error
	// Kubernetes lists the signs of a Kubernetes pod, for the log line
	// only: a Kubernetes node may run Docker too.
	Kubernetes func() []string
}

Probe is what the choice of mode looks at.

Jump to

Keyboard shortcuts

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