Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions benchmarks/cuda_custom_storage/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
Comment thread
hhzhang16 marked this conversation as resolved.
Resolved

CUDA_HOME ?= /usr/local/cuda
CXX ?= g++
CXXFLAGS ?= -O2 -g

TARGET := cuda-custom-storage-roundtrip
SHARED_DIR := ../../deploy/snapshot/cmd/cuda-checkpoint-helper
SOURCES := roundtrip.cpp $(SHARED_DIR)/custom_storage_operation.cpp

.PHONY: all clean

all: $(TARGET)

$(TARGET): $(SOURCES) $(SHARED_DIR)/custom_storage_operation.h $(SHARED_DIR)/cuda_checkpoint_compat.h
$(CXX) -std=c++20 $(CXXFLAGS) -Wall -Wextra -Werror \
-I$(CUDA_HOME)/include \
-I$(SHARED_DIR) \
-L$(CUDA_HOME)/lib64/stubs \
-Wl,-rpath,$(CUDA_HOME)/lib64 \
-o $@ $(SOURCES) -lcuda

clean:
$(RM) $(TARGET)
115 changes: 115 additions & 0 deletions benchmarks/cuda_custom_storage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<!--
SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: Apache-2.0
-->

# CUDA CustomStorage standalone round-trip

This single-GPU harness validates the CUDA 13.4 CustomStorage checkpoint contract without
Snapshot, CRIU, GMS, HVBM, NIXL, or Kubernetes.

The target-PID CustomStorage operation and capability handling live in
`deploy/snapshot/cmd/cuda-checkpoint-helper/custom_storage_operation.*`. The harness is
their smallest consumer. It deliberately supplies its own single-buffer POSIX transfer
instead of depending on Snapshot's daemon, NIXL engine, or artifact format.

It forks a standalone CUDA workload that allocates a deterministic local device
buffer. The controller process then:

1. locks the workload;
2. requests a CustomStorage checkpoint;
3. requires one driver-provided device extent and reports its requested device ordinal,
UUID, pointer, size, and stream;
4. copies that extent to one POSIX file through one bounded pinned buffer;
5. completes the checkpoint operation;
6. validates the file size before mutating restore state;
7. restores the extent and unlocks the workload;
8. asserts the documented RUNNING → LOCKED → CHECKPOINTED → LOCKED → RUNNING states; and
9. asks the workload to verify its original bytes and execute another CUDA operation.

An internal 120-second watchdog kills the child workload and exits the controller if a
driver call, pipe operation, or workload exit hangs. Multi-GPU restore is an explicit
non-goal of this proof.

The driver-provided CustomStorage pointer is checkpoint storage, not necessarily an
application allocation address. Correctness is therefore established by application
byte verification after a complete checkpoint/restore cycle, not by matching the
application pointer against the returned extent pointer.

## Requirements

- Linux on x86-64
- CUDA driver exposing the CUDA 13.4 CustomStorage API
- CUDA toolkit headers and driver stubs under `CUDA_HOME`
- Permission to checkpoint the child process

The compatibility header temporarily permits a build image with pre-13.4 headers when
the runtime driver already exposes the 13.4 symbol. Prefer the released CUDA 13.4
headers as soon as they are available.

## Build

```bash
make -C benchmarks/cuda_custom_storage
```

## Verify a normal round-trip

The artifact directory must not already exist:

```bash
artifact_dir="$(mktemp -d)/artifact"
timeout 130s benchmarks/cuda_custom_storage/cuda-custom-storage-roundtrip \
--artifact-dir "${artifact_dir}" \
--bytes 67108864
```

Expected output reports the CUDA-provided extent and ends with `roundtrip=passed`.
The output directory contains one `checkpoint.bin` file. Its metadata remains in
memory for the duration of the test; the harness does not define a persistent artifact
format.

## Verify truncated-artifact rejection

Use a new artifact directory:

```bash
artifact_dir="$(mktemp -d)/artifact"
timeout 130s benchmarks/cuda_custom_storage/cuda-custom-storage-roundtrip \
--artifact-dir "${artifact_dir}" \
--bytes 67108864 \
--truncate-before-restore
```

The harness intentionally truncates the checkpoint file, rejects it before invoking CUDA
restore, terminates the now-checkpointed test workload, and reports
`corruption_check=passed`.

## Verify that restored state depends on artifact bytes

Use another new artifact directory:

```bash
artifact_dir="$(mktemp -d)/artifact"
timeout 130s benchmarks/cuda_custom_storage/cuda-custom-storage-roundtrip \
--artifact-dir "${artifact_dir}" \
--bytes 67108864 \
--corrupt-before-restore
```

This preserves the extent's declared size but overwrites its contents. The test passes
only if CUDA restore/completion rejects the bytes or the workload explicitly rejects
the restored application state.

## Explicit non-goals

- Snapshot or CRIU orchestration
- GMS/HVBM allocation ownership or metadata
- NIXL and transfer-performance optimization
- daemonization or multi-tenant policy
- portable GPU remapping
- multi-GPU checkpoint or restore
- production artifact compatibility

Those layers should consume or extend the verified CUDA contract only after this
standalone behavior is reproduced on the target CUDA 13.4 environment.
Loading
Loading