Skip to content

Commit 3261c10

Browse files
committed
Restore checkpoint CUuuid compatibility
1 parent 083e411 commit 3261c10

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

‎cuda_core/cuda/core/checkpoint.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,12 @@ def _make_restore_args(driver, gpu_mapping: _Mapping[_Any, _Any] | None):
235235
def _as_cuuuid(driver, value, buffers):
236236
"""Convert *value* to a ``CUuuid``.
237237
238-
Accepts a UUID string in the ``"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"``
239-
format returned by :attr:`Device.uuid`.
238+
Accepts a ``CUuuid`` instance (returned as-is) or a UUID string in
239+
the ``"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`` format returned by
240+
:attr:`Device.uuid`.
240241
"""
242+
if isinstance(value, driver.CUuuid):
243+
return value
241244
if isinstance(value, str):
242245
try:
243246
raw = bytes.fromhex(value.replace("-", ""))
@@ -250,7 +253,7 @@ def _as_cuuuid(driver, value, buffers):
250253
buf = _ctypes.create_string_buffer(raw, 16)
251254
buffers.append(buf)
252255
return driver.CUuuid(_ctypes.addressof(buf))
253-
raise TypeError("GPU UUID values must be UUID strings")
256+
raise TypeError("GPU UUID values must be CUDA UUID objects or UUID strings")
254257

255258

256259
__all__ = [

‎cuda_core/docs/source/api.rst‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,10 @@ should be used during restore. For migration workflows, provide mappings for
241241
every GPU visible to the NVIDIA kernel-mode driver at checkpoint time.
242242
User-space masking such as ``CUDA_VISIBLE_DEVICES`` does not reduce this
243243
mapping requirement, so applications that rely on user-space GPU masking may
244-
not be valid migration targets. The mapping should use the UUID strings
245-
returned by :attr:`Device.uuid`. A successful restore returns the process to
246-
the locked state; call ``Process.unlock`` after restore to allow CUDA API
247-
calls to resume.
244+
not be valid migration targets. The mapping may use ``CUuuid`` objects or the
245+
UUID strings returned by :attr:`Device.uuid`. A successful restore returns the
246+
process to the locked state; call ``Process.unlock`` after restore to allow
247+
CUDA API calls to resume.
248248

249249
The CUDA driver requires restore to run from the process restore thread.
250250
Use ``Process.restore_thread_id`` to discover that thread before calling

0 commit comments

Comments
 (0)