restore

package
v2.0.0-beta.10 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 31 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.

View Source
const RuntimeFile = "/opt/warmctl/RUNTIME"

RuntimeFile marks the warmctl runtime image (deploy/kubernetes/Dockerfile): the warmctl it carries and the image it was built FROM.

Variables

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

ErrStopped is returned when the engine exits while serving.

Functions

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 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 VisibleGPUs

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

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

Types

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, runDir string, p *run.Progress) (*Gate, error)

OpenGate listens on listen 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
	NoVerify       bool
	VerifyWeights  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
	// Gate, in place, is the gateway, opened before the pull.
	Gate     *Gate
	Progress *run.Progress
}

Options of one restore.

type Probe

type Probe struct {
	// Runtime reads the runtime image's marker.
	Runtime func() (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.

type Runtime

type Runtime struct {
	// Warmctl is the version built into the image.
	Warmctl string
	// Base is the image it was built FROM, the one a snapshot's engine
	// must have run in.
	Base string
}

Runtime is RuntimeFile: `key=value` lines.

func ParseRuntime

func ParseRuntime(text string) (Runtime, error)

ParseRuntime reads RuntimeFile's text.

func ReadRuntime

func ReadRuntime(name string) (Runtime, bool, error)

ReadRuntime reads the marker; false when this is not the runtime image.

Jump to

Keyboard shortcuts

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