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
- Variables
- func Catches(pid int, sig syscall.Signal) bool
- func CheckLaunch(l profile.Launch) error
- func Compatible(h manifest.Hardware, gpus []host.GPU) error
- func Hardware(h *manifest.Hardware, gpus []host.GPU, w vllm.Worker, lib manifest.MappedFile)
- func Holders(pids []int) ([]int, error)
- func Owners(pids []int) ([]int, error)
- func PluginStatusDir() (string, error)
- func RenderNodes(h manifest.Hardware, gpus []host.GPU, visible int) error
- func SameFiles(files []manifest.MappedFile) error
- func Signal(ctx context.Context, procs []Process, sig syscall.Signal, dir, want string, ...) error
- func Supported(gpus []host.GPU) (note string, err error)
- func VerifyPreloaded(pids []int, lib string) error
- func VerifyReleased(pids []int, lib string) ([]int, error)
- type Coverage
- type Process
- type Result
- type State
- type Support
Constants ¶
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.
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 ¶
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.
var Proc = "/proc"
Proc is where processes are read; tests point it at a fixture.
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.
var SignalTimeout = 2 * time.Minute
SignalTimeout bounds one process's checkpoint or restore.
Functions ¶
func Catches ¶
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 ¶
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 ¶
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 ¶
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 PluginStatusDir ¶
PluginStatusDir selects the location saved in the engine's launch environment. Older snapshots can contain the original receiver path.
func RenderNodes ¶
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 ¶
Supported refuses GPUs no row of Matrix covers and warns (the returned note) when the driver is not one a row names.
func VerifyPreloaded ¶
VerifyPreloaded checks that every restored process that runs ROCm maps lib: they replay their GPU state through it next.
func VerifyReleased ¶
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.
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 State ¶
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 ¶
Checkpoint runs after sleep and checkpoint_prepare, before the agent's steps: afterwards no worker holds a GPU device and DMTCP may dump.