Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions cuda_bindings_13/cuda/bindings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@

from cuda.bindings import utils
from cuda.bindings._version import __version__

# TEMPORARY: touch cuda_bindings_13 so CI builds the bindings Cython-test artifacts (PR #3659 nightly check). Drop before merge.
27 changes: 15 additions & 12 deletions cuda_core/tests/test_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@

import pytest

from cuda.bindings import driver
from cuda.core import Device, checkpoint
from cuda.core._utils.cuda_utils import CUDAError
from cuda.core._utils.cuda_utils import CUDAError, handle_return

# -- Skip condition -------------------------------------------------------

Expand Down Expand Up @@ -192,14 +193,25 @@ def _run_checkpoint_scenario_or_skip(scenario: str, *, timeout: int = 90) -> Non
)


def _context_device_uuid() -> str:
"""Return the UUID of the GPU behind the current context, queried from the driver.

``Device.uuid`` is cached per device ordinal, so it keeps reporting the
pre-restore GPU after a checkpoint restore migrates the context.
"""
device = handle_return(driver.cuCtxGetDevice())
uuid_hex = bytes(handle_return(driver.cuDeviceGetUuid(device)).bytes).hex()
return f"{uuid_hex[:8]}-{uuid_hex[8:12]}-{uuid_hex[12:16]}-{uuid_hex[16:20]}-{uuid_hex[20:]}"


def _target_main(device_index: int) -> None:
Device(device_index).set_current()
print(f"READY:{Device().uuid}", flush=True)
print(f"READY:{_context_device_uuid()}", flush=True)

for line in sys.stdin:
command = line.strip()
if command == "uuid":
print(f"UUID:{Device().uuid}", flush=True)
print(f"UUID:{_context_device_uuid()}", flush=True)
elif command == "exit":
break

Expand Down Expand Up @@ -291,17 +303,13 @@ def _scenario_rotation_migrates_context() -> None:

gpu_mapping = _build_rotation_mapping(devices)
target, uuid_origin = _start_target(0)
current_uuid = uuid_origin
proc = checkpoint.Process(target.pid)
try:
for step in range(len(devices)):
expected_uuid = devices[(step + 1) % len(devices)].uuid
_checkpoint_restore(proc, gpu_mapping=gpu_mapping)
observed_uuid = _target_uuid(target)
if observed_uuid == current_uuid:
_scenario_skip("Driver accepted GPU rotation but migration is a no-op on this hardware/driver version")
assert observed_uuid == expected_uuid, f"Step {step}: expected UUID {expected_uuid}, got {observed_uuid}"
current_uuid = observed_uuid

assert _target_uuid(target) == uuid_origin
finally:
Expand Down Expand Up @@ -331,9 +339,6 @@ def _scenario_swap_identical_gpus() -> None:

_checkpoint_restore(proc, gpu_mapping=gpu_mapping)
uuid_after = _target_uuid(target)

if uuid_after == devices[i].uuid:
_scenario_skip("Driver accepted GPU swap but migration is a no-op on this hardware/driver version")
assert uuid_after == devices[j].uuid
finally:
_stop_target(target)
Expand Down Expand Up @@ -579,7 +584,6 @@ class TestCheckpointGpuMigration:
NVBug 5437334).
"""

# This test is not currently run in any CI job
def test_rotation_migrates_context(self):
"""Rotate context through all GPUs and back to the origin.

Expand All @@ -590,7 +594,6 @@ def test_rotation_migrates_context(self):
"""
_run_checkpoint_scenario_or_skip("rotation_migrates_context", timeout=180)

# This test is not currently run in any CI job
def test_swap_identical_gpus(self):
"""Swap context between two GPUs of the same chip type.

Expand Down
Loading