Repository navigation
Do not crash on a short GPU UUID in the CuPy backend - #431
kjwierenga wants to merge 1 commit into
Conversation
CuPy returns `props["uuid"]` as `bytes` that stops at the first zero byte (cupy/cupy#10522). For a UUID with a zero byte, the value has less than 16 bytes. `uuid.UUID(bytes=...)` then raises `ValueError: bytes is not a 16-char string`, and the backend cannot start. An A100 with the UUID `1eed7047-720e-7d2e-4561-4205587600d0` shows this. Use `None` for a value of the wrong length, as KernelTuner#427 does for HIP. Padding with zeros would give a wrong UUID. The code that reads `env["uuid"]` accepts `None`. The test uses a fake `cupy` module, so it runs without a GPU. It fails without the fix. Co-authored with Claude Code. I've reviewed the result and take full responsibility.
|
|
Thanks @kjwierenga! I agree that the default behavior should not be to crash when we cannot determine the uuid. The uuids are there to match the target GPU with the GPU used by the observers. This is in case an observer, such as NVML, maintains a different numbering of the GPUs present in the system. This has been known to happen and in multi-gpu systems. It is therefore needed to check whether the uuid of the GPU matches that of the device used by the observer. However, if for some reason we cannot determine the uuid, I think a crash (or preferably a nicer formatted error) should only be raised to the user when using such observers. |



Fixes #430.
CuPy returns the GPU UUID as
bytesthat stops at the first zero byte (cupy/cupy#10522). For a UUID with a zero byte, the value has less than 16 bytes. Thenuuid.UUID(bytes=...)raisesValueError: bytes is not a 16-char string, and the backend cannot start. I found this on an A100 in MIG mode, where the UUID is1eed7047-720e-7d2e-4561-4205587600d0.I set the UUID to
Nonefor a value that is not 16 bytes long, as #427 does for HIP. No point in padding the value with zeros, that would be wrong. The code that readsenv["uuid"]already acceptsNone.The CuPy fix is in cupy/cupy#10523. Until a CuPy release has it, this change is needed.
The new test uses a fake
cupymodule, so it runs without a GPU. It fails without this change. I did not run the full CuPy tuning tests on a GPU with this branch. I did not checknvcuda.py, which has the same code pattern.Although this PR was co-authored with Claude Code, I have carefully steered and checked the result, and I take full responsibility for any issues.