Problem
When get_kernel (or load_kernel) can't find a build variant compatible with the current system, the error message only reports that no matching variant exists for the resolved revision:
Cannot find a build variant for this system in {repo_id} (revision: {revision})
(raised in kernels/src/kernels/utils.py)
This is misleading when the user is on an older version branch of the kernel. For example, a user pinned to (or resolving to) an older version may conclude the kernel doesn't support their setup — e.g. "this kernel has no Torch 2.13 build" — when in fact a newer version branch does have a compatible variant. There is no hint that upgrading the kernel version would fix the problem.
Proposal
When variant resolution fails (no matching variant for the current environment):
- Enumerate the available version branches for the kernel repo (via
_get_available_versions in kernels/src/kernels/_versions.py, which lists the v<N> refs — newer versions first).
- Check whether any newer version has a variant compatible with the current system (
resolve_variant(s) against that revision).
- If a newer compatible version exists, extend the error message to suggest it, e.g.:
Cannot find a build variant for this system in {repo_id} (revision: v3):
<existing variants trace>
However, version v5 of '{repo_id}' has a build compatible with your system (torch 2.13, cuda 12.8, ...). Consider upgrading to that version.
Considerations
- The check requires resolving variants of newer versions, which may involve extra Hub API calls — acceptable on the error path, but should be best-effort (don't mask the original error if the check itself fails, e.g. offline mode).
- In offline mode (
HF_HUB_OFFLINE), the cached-version path (_get_available_versions_from_cache) could be used, or the check skipped gracefully.
Requested by Daniël de Kok - Slack thread - Agent trace
Problem
When
get_kernel(orload_kernel) can't find a build variant compatible with the current system, the error message only reports that no matching variant exists for the resolved revision:(raised in
kernels/src/kernels/utils.py)This is misleading when the user is on an older version branch of the kernel. For example, a user pinned to (or resolving to) an older version may conclude the kernel doesn't support their setup — e.g. "this kernel has no Torch 2.13 build" — when in fact a newer version branch does have a compatible variant. There is no hint that upgrading the kernel version would fix the problem.
Proposal
When variant resolution fails (no matching variant for the current environment):
_get_available_versionsinkernels/src/kernels/_versions.py, which lists thev<N>refs — newer versions first).resolve_variant(s)against that revision).Considerations
HF_HUB_OFFLINE), the cached-version path (_get_available_versions_from_cache) could be used, or the check skipped gracefully.Requested by Daniël de Kok - Slack thread - Agent trace