rocm

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: 14 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 rocm is warmctl on AMD Instinct GPUs: what an AMD host must offer, how a profile runs there, when a snapshot restores on it, and the GPU state an AMD engine moves itself.

There is no cuda-checkpoint for AMD. The engine's processes preload libkfdreplay (internal/kfdreplay), which records every GPU object the ROCm runtime creates; asked through the engine (warmctl_gpu_checkpoint), each worker dumps its GPU memory, parks the runtime's threads and releases the devices, so that DMTCP snapshots a CPU-only process tree. After the restart each worker replays its objects at the same addresses (warmctl_gpu_restore) before the engine wakes. Every other step of a snapshot, its files and its distribution are the NVIDIA path's.

Index

Constants

View Source
const (
	// CheckpointSignal and RestoreSignal are SIGRTMIN+6 and SIGRTMIN+7 of
	// glibc (DMTCP keeps SIGUSR2 and its own real-time signals below).
	CheckpointSignal = syscall.Signal(40)
	RestoreSignal    = syscall.Signal(41)
	// StatusEnv names the status directory in the engine's environment; the
	// plugin does nothing without it, so engines other than AMD ones never
	// install the handlers.
	StatusEnv = "WARMCTL_KFDR_STATUS"
	// StatusDir is where the plugin writes "checkpointed", "restored",
	// "skipped" (a process the signal did not checkpoint, as a worker), or
	// "error: <reason>".
	StatusDir = "/workspace/.warmctl-kfdr"
)

Processes of the engine other than vLLM's workers can initialize ROCm too: vLLM 0.33's API server and engine core import kernels that probe the GPU (aiter, Triton's AMD target, flash-linear-attention). They hold no GPU memory of their own, but their runtime holds the devices. warmctl's vLLM plugin (python/warmctl_vllm/plugin.py) lets such a process checkpoint and restore its own GPU state through libkfdreplay on a signal, and reports the outcome in a file named by its PID (the one the process sees: under DMTCP, the snapshot PID) in StatusDir.

View Source
const MaxWptrWarn = 10_000_000

MaxWptrWarn is how many queue packets make a restore's replay take seconds (~1 µs each): the snapshot should be of a freshly warmed engine.

Variables

View Source
var Matrix = []Support{
	{Arch: "gfx950", Driver: "7.1.3", KFDReplay: "0.1.1"},
}

Matrix is what has been verified; a GPU of another ISA is refused, since libkfdreplay mirrors what the runtime does on the GPUs it was tested on.

View Source
var Proc = "/proc"

Proc is where processes are read; tests point it at a fixture.

View Source
var RequiredEnv = map[string]string{
	"HSA_ENABLE_SDMA":                  "0",
	"HSA_ENABLE_SCRATCH_ASYNC_RECLAIM": "0",
	"HSA_NO_SCRATCH_RECLAIM":           "1",
	"PYTORCH_HIP_ALLOC_CONF":           "expandable_segments:False",
	"USE_LIBUV":                        "0",
}

RequiredEnv is what every AMD engine runs with (profiles/_defaults-rocm.yaml); a profile that changes one of them cannot be checkpointed.

View Source
var SignalTimeout = 2 * time.Minute

SignalTimeout bounds one process's checkpoint or restore.

Functions

func Catches

func Catches(pid int, sig syscall.Signal) bool

Catches reports whether pid has a handler for sig: only those are sent it, as the default action of a real-time signal ends the process.

func CheckLaunch

func CheckLaunch(l profile.Launch) error

CheckLaunch refuses what an AMD engine cannot checkpoint: more than one GPU (no cross-process GPU memory restores yet), cuInterpose, and an environment without RequiredEnv.

func Compatible

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

Compatible checks this host's GPUs against an AMD snapshot's: the same model, memory and ISA, and the very same driver: libkfdreplay replays the donor's driver calls, and a restore across driver releases is unverified. Another GPU of the same model is fine: libkfdreplay translates its gpu_id.

func Hardware

func Hardware(h *manifest.Hardware, gpus []host.GPU, w vllm.Worker, lib manifest.MappedFile)

Hardware is what an AMD snapshot records of the donor's GPUs beyond the common fields: ISA, the kernel's gpu_id and the render node per GPU, and the runtime the workers reported.

func Holders

func Holders(pids []int) ([]int, error)

Holders are the processes among pids that hold or map an AMD GPU device.

func Owners

func Owners(pids []int) ([]int, error)

Owners are the processes among pids that run ROCm.

func PluginStatusDir

func PluginStatusDir() (string, error)

PluginStatusDir selects the location saved in the engine's launch environment. Older snapshots can contain the original receiver path.

func RenderNodes

func RenderNodes(h manifest.Hardware, gpus []host.GPU, visible int) error

RenderNodes checks that libkfdreplay can find the GPU a restore runs on: it reopens the donor's render node, and on another GPU translates the gpu_id only when the container sees exactly one GPU.

func SameFiles

func SameFiles(files []manifest.MappedFile) error

SameFiles checks recorded files before a restart: same size and mtime.

func Signal

func Signal(ctx context.Context, procs []Process, sig syscall.Signal, dir, want string, skip bool) error

Signal sends sig to each process and waits for its status: one of want, or "skipped" when skip is true. A process reporting an error, or none in time, fails the step with its reason.

func Supported

func Supported(gpus []host.GPU) (note string, err error)

Supported refuses GPUs no row of Matrix covers and warns (the returned note) when the driver is not one a row names.

func VerifyPreloaded

func VerifyPreloaded(pids []int, lib string) error

VerifyPreloaded checks that every restored process that runs ROCm maps lib: they replay their GPU state through it next.

func VerifyReleased

func VerifyReleased(pids []int, lib string) ([]int, error)

VerifyReleased checks a tree after every worker's GPU checkpoint, before DMTCP dumps it, and returns the processes that run ROCm. A process that still holds or maps an AMD device kept GPU state no checkpoint took (one warmctl did not ask, as an API server that initialized ROCm): the dump is refused rather than taken without it. A process that runs ROCm without lib cannot be restored.

Types

type Coverage

type Coverage struct {
	Uncovered []string
	Mapped    []manifest.MappedFile
}

Coverage describes the dependencies outside the archived trees. Mapped entries must be present at restart. Uncovered entries could not be tracked.

func Cover

func Cover(pids []int, trees []string, modelDir, lib string, started time.Time) (Coverage, error)

Cover checks the files of pids against the archived trees, the model directory and the mounts visible to each process.

type Process

type Process struct {
	Host, Snapshot int
}

Process is one process of the tree: its PID on the host and the one it sees.

type Result

type Result struct {
	Ranks   []vllm.GPUState
	Seconds float64
}

Result is what one checkpoint or restore of every rank took.

func (Result) MaxWptr

func (r Result) MaxWptr() uint64

MaxWptr is the most packets any rank's queue has taken.

type State

type State struct {
	Version string
	Logf    func(string, ...any)
}

State moves an AMD engine's GPU state through the engine: every worker calls libkfdreplay itself. Version is the libkfdreplay release the workers must run, "" for a research build.

func (State) Checkpoint

func (s State) Checkpoint(ctx context.Context, e *vllm.Engine) (Result, error)

Checkpoint runs after sleep and checkpoint_prepare, before the agent's steps: afterwards no worker holds a GPU device and DMTCP may dump.

func (State) Restore

func (s State) Restore(ctx context.Context, e *vllm.Engine) (Result, error)

Restore runs after the process restore, before the engine wakes.

type Support

type Support struct {
	Arch      string
	Driver    string // a prefix of /sys/module/amdgpu/version
	KFDReplay string
}

Support is one platform an AMD snapshot is known to restore on: the GPU ISA, the amdgpu driver releases and the libkfdreplay release it was verified with (docs/amd.md).

Jump to

Keyboard shortcuts

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