Add criu memory testcase - #63
Conversation
| # (materialized on first use so either test still runs standalone) and the on-disk image is reused | ||
| # by the restore test. NOTE: not xdist-safe -- with -n the tests may split across workers, each | ||
| # re-dumping; run these single-process. | ||
| _CHECKPOINT: dict = {} |
There was a problem hiding this comment.
Add @pytest.mark.xdist_group("criu_cuda_memtest_serial") to both test functions, or add a pytest.ini_options addopts entry scoped to this directory. CI runs may use parallel
There was a problem hiding this comment.
Done. Both test functions now carry @pytest.mark.xdist_group("criu_cuda_memtest_serial"), so under -n they land on the same worker and run serially — no cross-worker re-dump. The "not xdist-safe" note was removed.
| _log("Install CRIU build prerequisites manually, then re-run.") | ||
|
|
||
|
|
||
| def build_and_install(version: str) -> None: |
There was a problem hiding this comment.
external_build.clone_repo()
There was a problem hiding this comment.
Done. installer.build_and_install(version, src_dir=…) no longer clones inline — the fixture clones CRIU via external_build.clone_repo() and passes the checkout through --src-dir; the installer builds/installs from it (falling back to a tagged clone only if no src-dir is given).
| def test_criu_check_point_cuda_memtest( | ||
| target_executor, ld_path, cuda_memtest_build, criu_runtime, gpu_arch, rock_dir, request | ||
| ): | ||
| """Checkpoint a running cuda_memtest process with ``criu dump``.""" | ||
| _skip_if_unsupported_arch(gpu_arch) | ||
| executor, ld = target_executor, ld_path["LD_LIBRARY_PATH"] | ||
| full_log = request.config.getoption("capture") == "no" | ||
| _ensure_checkpoint(executor, criu_runtime, cuda_memtest_build, ld, rock_dir, full_log) | ||
|
|
||
|
|
||
| @pytest.mark.runtime.medium | ||
| def test_criu_restore_cuda_memtest( | ||
| target_executor, ld_path, cuda_memtest_build, criu_runtime, gpu_arch, rock_dir, request |
There was a problem hiding this comment.
See If the same GPU slots to be enforced for both the tests.
for single-GPU node this may work as the later restore test acquires the same GPU, but when run on multi GPU node restore may be attempted on different GPU slot altogether.
does it makes sense to merge both test : launch → dump → restore → verify
There was a problem hiding this comment.
Merged into a single launch → dump → restore → verify test under one target_executor, so the restore always uses the checkpoint's GPU — no multi-GPU slot mismatch, and the _CHECKPOINT global is gone. Kept the criu_cuda_memtest_serial xdist_group so it stays serialized with the zip/unzip test (shared build workdir); honored under --dist loadgroup.
| vram_mb = _total_vram_mb(executor, ld, rock_dir) | ||
| if not vram_mb: | ||
| pytest.skip("Could not determine total GPU VRAM to size cuda_memtest.") | ||
| blocks = round(vram_mb / 1024) * 1000 |
There was a problem hiding this comment.
pls recheck If this round-off is required.
may reduce the memory foot print
There was a problem hiding this comment.
Done — removed entirely. The VRAM probe and round(vram_mb/1024)*1000 sizing are gone; the workload now uses a fixed _MAX_NUM_BLOCKS = 2000 (~2 GB), which both drops the round-off and keeps the footprint small (CRIU's amdgpu_plugin drains each buffer via sDMA within a fence timeout, so a large allocation would time out the dump).
| poll = ( | ||
| f"for i in $(seq 1 {int(timeout // 2)}); do " | ||
| f"if sudo -n grep -q '{_RESTORE_MARKER}' {workdir}/{log} 2>/dev/null; then echo RESTORE_OK; break; fi; " | ||
| "sleep 2; done" |
There was a problem hiding this comment.
What if the poll fails w/ value != RESTORE_OK ?
There was a problem hiding this comment.
Handled. The poll now emits an explicit sentinel either way: RESTORE_OK when the marker appears, else RESTORE_FAIL (including on timeout). _restore asserts RESTORE_OK in stdout, so a failed or timed-out restore fails the test with the restore.log tail attached to Allure — never a silent/false pass.
| _CRIU_VERSION_RE = re.compile(r"^[A-Za-z0-9._/\-]+$") | ||
|
|
||
| # Path the installer module is transferred to inside a remote/target environment. | ||
| _REMOTE_INSTALLER = "/tmp/rocm_test_criu_installer.py" |
There was a problem hiding this comment.
pls use persistent path supporting both baremetal (local, remote) and container(")
| # Third-Party Notices — CRIU | ||
|
|
||
| The shared CRIU machinery under `tests/common/criu/` **fetches, builds, and installs** the | ||
| third-party CRIU project **on the test node at test time**. CRIU's source and binaries are not |
There was a problem hiding this comment.
| third-party CRIU project **on the test node at test time**. CRIU's source and binaries are not | |
| third-party CRIU project **on the test node at test run time**. CRIU's source and binaries are not |
Motivation
CRIU (Checkpoint/Restore In Userspace) freezes a running process and checkpoints its full state to disk so it can later be restored and resume where it left off. On AMD GPUs this relies on the ROCm KFD checkpoint/restore hooks plus AMD's amdgpu_plugin.so, which serialize per-process GPU state (VRAM BOs, user-mode queues, events). That surface had no e2e coverage. This PR automates the CRIU cuda_memtest checkpoint/restore path — a correctness check, not a benchmark: "good" means a running HIP workload can be criu dumped and criu restored and resumes correctly on the GPU, including when the image is archived and restored from a different directory.
Technical Details
New test area tests/e2e/recovery/criu/: test_criu_cuda_memtest.py, test_criu_zip_unzip.py, plus conftest.py, _criu_steps.py,
scripts/install_criu.py, NOTICES.md, init.py.
Test Plan
Required: --rock-dir (or ROCK_DIR/rocm-test.toml); Linux AMD GPU node with passwordless sudo; supported GFX (gfx90a/908/942/950, gfx110x/gfx120x).
Optional env: ROCM_TEST_CUDA_MEMTEST_URL/_REF, ROCM_TEST_CRIU_AUTO_INSTALL (default 1), ROCM_TEST_CRIU_VERSION (default v4.1).
Optional flags: -s (full logs inline), --remote-node, --pre-install pkg=…. Run single-process (no -n) — the shared checkpoint isn't xdist-safe.
Test Result
Run on an AMD gfx90a node →