vllm.snapshot.attachments
¶
Carry the generated files a snapshot image reopens by path.
Classes:
-
GeneratedFile–A file considered for snapshot capture and its content fingerprint.
-
SnapshotAttachmentError–An attachment could not be captured or reproduced faithfully.
Functions:
-
attachment_limits–Per-file and total attachment size limits, from the environment.
-
cache_fingerprint–Digest a cache file, or mark the ones capture cannot read.
-
capture_attachments–Copy files into the snapshot and record their paths, sizes, and digests.
-
collect_generated_files–Collect files to include as snapshot attachments.
-
fd_targets–Return the symlink targets of entries in /proc/
/fd. -
materialize_attachments–Prepare snapshot attachments at their original paths for restore.
-
rollback_attachments–Remove only what this restore wrote.
GeneratedFile
dataclass
¶
A file considered for snapshot capture and its content fingerprint.
fingerprint is a SHA-256 hex digest for content verification, or
None when restore never verifies the content. required marks a
file the restore reopens by path, so capture must fail when it cannot
carry it instead of skipping it.
Source code in vllm/snapshot/attachments.py
SnapshotAttachmentError
¶
Bases: RuntimeError
An attachment could not be captured or reproduced faithfully.
_blob_path(artifact, path)
¶
Where the artifact carries a captured file: its own path mirrored under the attachment root, so each cache root keeps its tree and no two files can collide.
Source code in vllm/snapshot/attachments.py
_cache_root_directories(prefixes)
¶
Expand cache path prefixes into directories to scan for attachments.
Paths ending in "/" are used directly. Other paths are matched against directory names in the parent directory: "/tmp/torchinductor_" matches all directories named "torchinductor_*" under "/tmp".
Source code in vllm/snapshot/attachments.py
_check_target(path)
¶
Validate that the attachment target has a trusted path chain.
Paths under known machine-state roots are exempt from this check.
Source code in vllm/snapshot/attachments.py
_enforce_size_limits(ordered, limits)
¶
Enforce per-file and total size limits for snapshot attachments.
Raise SnapshotAttachmentError if any file or the combined total exceeds the corresponding limit in bytes. The check runs on the assembled inventory, so a cache that does not fit fails create before CRIU runs.
Source code in vllm/snapshot/attachments.py
_install(source, target, *, fsync)
¶
Copy source onto target through a same-directory temporary.
fsync publishes the bytes durably; a transient restore target skips
it, because a restore that dies mid-copy rolls the file back anyway.
Source code in vllm/snapshot/attachments.py
_is_machine_state(path)
¶
Whether path names a machine-state root or something inside it.
_mapping_targets(pid)
¶
Read file-backed mapping paths from /proc/
File mappings can outlive their file descriptors, so scanning
/proc/
Source code in vllm/snapshot/attachments.py
_path_references(pid)
¶
Collect descriptor targets and mapped file paths for snapshot capture.
Each entry is a (target, kind) pair, where kind is "descriptor" or "mapping", identifying how the process references the target.
Source code in vllm/snapshot/attachments.py
_payload_matches(attachment, path)
¶
Whether the artifact's own copy is intact.
A cache attachment carries no digest, so its size is the only signal.
Source code in vllm/snapshot/attachments.py
_referenced_generated_files(process_tree, artifact_prefix, prefixes)
¶
Collect cache and machine-state files referenced by the process tree.
Inspect open file descriptors and file-backed mappings to identify files to include in the snapshot. Skip deleted files and paths inside the snapshot artifact.
Source code in vllm/snapshot/attachments.py
_stage(source, blob)
¶
_walked_cache_files(references, artifact_prefix, prefixes)
¶
Collect unreferenced cache files for reuse after restore.
Scan cache directories, skipping files already in references and
paths inside the snapshot artifact; an in-place checkpoint keeps every
unreferenced cache file on the host instead. Record these files without
fingerprints so restore can reuse existing cache files without content
verification; one that is not a readable regular file stays out.
Source code in vllm/snapshot/attachments.py
attachment_limits()
¶
Per-file and total attachment size limits, from the environment.
Source code in vllm/snapshot/attachments.py
cache_fingerprint(path)
¶
Digest a cache file, or mark the ones capture cannot read.
Source code in vllm/snapshot/attachments.py
capture_attachments(artifact, generated_files)
¶
Copy files into the snapshot and record their paths, sizes, and digests.
Abort when a copied file differs from its recorded SHA-256 digest. A required file — one the restore reopens by path — also fails capture on an I/O or security error: skipping it would leave an artifact the restore cannot bring back. An optional cache file is skipped with the reason on stderr instead.
Return metadata for the files successfully captured.
Source code in vllm/snapshot/attachments.py
collect_generated_files(process_tree, artifact, work_dir, cache_prefixes, limits=None)
¶
Collect files to include as snapshot attachments.
Include cache files opened or mapped by the process tree, plus additional cache files to avoid recompilation after restore. Referenced cache files are fingerprinted when readable; additional cache files are included without content verification.
Also include the child log and files under known machine-state roots. Only paths under a cache prefix are in scope, so model weights and files some unrelated helper holds stay out; files inside the artifact belong to the snapshot itself, and a deleted target is already covered by CRIU's link remap. Deduplicate paths and enforce per-file and total size limits.
Source code in vllm/snapshot/attachments.py
fd_targets(pid)
¶
Return the symlink targets of entries in /proc/
Source code in vllm/snapshot/attachments.py
materialize_attachments(artifact, attachments)
¶
Prepare snapshot attachments at their original paths for restore.
Copy files from the artifact only when the target is missing. For existing
files, skip content verification for cache attachments and require
all other attachments to match their recorded SHA-256 digests.
Return the newly created file paths. On failure, attempt to remove those files and report any cleanup failures.
Source code in vllm/snapshot/attachments.py
rollback_attachments(created)
¶
Remove only what this restore wrote.