Skip to content

fix(utils): don't crash check_os_kernel on non-standard kernel release strings#4077

Open
eldar702 wants to merge 1 commit into
huggingface:mainfrom
eldar702:fix-check-os-kernel-nonstandard-release
Open

fix(utils): don't crash check_os_kernel on non-standard kernel release strings#4077
eldar702 wants to merge 1 commit into
huggingface:mainfrom
eldar702:fix-check-os-kernel-nonstandard-release

Conversation

@eldar702

Copy link
Copy Markdown

Summary

check_os_kernel() aborts Accelerator initialization with an opaque ValueError: not enough values to unpack on Linux hosts whose kernel release string doesn't contain a full X.Y.Z version — e.g. custom kernels, some containers/WSL reporting "5.15", "6.1-arch1", or "unknown". The cause is _, version, *_ = re.split(r"(\d+\.\d+\.\d+)", info.release), which yields too few parts when there's no X.Y.Z match.

Fix

Use re.search for the X.Y.Z pattern and return early (skip the version warning) when no standard version is present. On standard release strings the extracted version is identical to before — no behavior change.

Tests

Regression test covering non-standard release strings (RED before / GREEN after). tests/test_utils.py: 46 passed; ruff clean.

AI-assisted contribution.

…e strings

check_os_kernel() unpacked re.split(r"(\d+\.\d+\.\d+)", info.release) with
`_, version, *_ = ...`, which raises ValueError when the kernel release string
does not contain a full X.Y.Z version (e.g. custom builds, some containers/WSL
report "5.15", "6.1-arch1", or "unknown"). Because this function runs during
Accelerator.__init__, an unparseable release aborts initialization with an
opaque error, even though the function is only meant to emit a best-effort
warning.

Use re.search to extract the version and skip the check gracefully when no
X.Y.Z pattern is present. Adds a regression test covering non-standard release
strings.

AI-assisted contribution.
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.

1 participant