Skip to content

Do not crash on a short GPU UUID in the CuPy backend - #431

Open
kjwierenga wants to merge 1 commit into
KernelTuner:masterfrom
kjwierenga:fix-cupy-uuid-short
Open

kjwierenga wants to merge 1 commit into
KernelTuner:masterfrom
kjwierenga:fix-cupy-uuid-short

Conversation

@kjwierenga

@kjwierenga kjwierenga commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #430.

CuPy returns the GPU 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. Then uuid.UUID(bytes=...) raises ValueError: bytes is not a 16-char string, and the backend cannot start. I found this on an A100 in MIG mode, where the UUID is 1eed7047-720e-7d2e-4561-4205587600d0.

I set the UUID to None for 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 reads env["uuid"] already accepts None.

The CuPy fix is in cupy/cupy#10523. Until a CuPy release has it, this change is needed.

The new test uses a fake cupy module, 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 check nvcuda.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.

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.
@sonarqubecloud

sonarqubecloud Bot commented Dec 2, 2026

Copy link
Copy Markdown

@kjwierenga
kjwierenga marked this pull request as ready for review December 2, 2026 15:04

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cupy backend crashes when the GPU UUID has a zero byte (bytes is not a 16-char string)

1 participant