Repository navigation
kernels: allow dotted versions in variants, add Python ABI - #985
Merged
Merged
Conversation
Versions in variant notation were inspired by Torch, which used e.g. cu128 for CUDA 12.8. However, this is fragile (e.g. 714 is parsed as 71.4) and inconsistent (e.g. 215 in torch215 is parsed as 2.15). This PR allows using a dotted version of variants to avoid ambiguities, such as. We also add a dash before versions for clarity, e.g.: `torch2.10-cu12.8-x86_64-linux` This change only adds it to the client, we need support to be around for a few iterations before we can roll out kernels dotted versions. Breaking change: `torch-npu` becomes `torch-cann`. But I don't think there are any kernels out there that actually use it, so it should low-impact.
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
danieldk
marked this pull request as draft
November 10, 2026 14:17
Coverage report —
|
| Name | Stmts | Miss | Cover | Missing |
|---|---|---|---|---|
| src/kernels/__init__.py | 14 | 0 | 100% | |
| src/kernels/_system.py | 6 | 1 | 83% | 10 |
| src/kernels/_versions.py | 130 | 14 | 89% | 53, 59-60, 63-64, 102, 165-170, 199, 219 |
| src/kernels/archs.py | 56 | 1 | 98% | 94 |
| src/kernels/backends.py | 242 | 44 | 82% | 95, 138, 147, 156, 190, 199, 270, 286, 290, 294-319, 327, 350-370 |
| src/kernels/compat.py | 9 | 1 | 89% | 5 |
| src/kernels/deps.py | 70 | 1 | 99% | 56 |
| src/kernels/digest.py | 58 | 5 | 91% | 71-73, 136-137 |
| src/kernels/hf_hub.py | 62 | 2 | 97% | 21, 23 |
| src/kernels/importer.py | 74 | 5 | 93% | 158, 162, 165, 179-180 |
| src/kernels/install.py | 21 | 7 | 67% | 76-100 |
| src/kernels/layer/__init__.py | 7 | 0 | 100% | |
| src/kernels/layer/_interval_tree.py | 103 | 4 | 96% | 23, 52, 147, 150 |
| src/kernels/layer/device.py | 48 | 12 | 75% | 42, 47-49, 91, 96-98, 101, 149, 152, 156 |
| src/kernels/layer/func.py | 93 | 5 | 95% | 94, 119, 195, 315, 390 |
| src/kernels/layer/globals.py | 5 | 0 | 100% | |
| src/kernels/layer/inspect.py | 27 | 0 | 100% | |
| src/kernels/layer/kernelize.py | 83 | 7 | 92% | 306, 314-315, 321, 325, 341-343 |
| src/kernels/layer/layer.py | 320 | 14 | 96% | 212, 259, 447, 606-607, 628, 636, 647, 688, 692, 705, 760, 801, 876 |
| src/kernels/layer/mode.py | 14 | 0 | 100% | |
| src/kernels/layer/repos.py | 136 | 36 | 74% | 32, 35-42, 73, 86, 90, 99-100, 103, 106-109, 116-117, 120, 123-126, 133-134, 137, 140-143, 150-151, 154, 157-160, 235 |
| src/kernels/load.py | 71 | 2 | 97% | 338, 378 |
| src/kernels/locking.py | 89 | 64 | 28% | 35-83, 91-98, 102-125, 137, 152-159, 165-175, 179-186 |
| src/kernels/python_deps.py | 58 | 6 | 90% | 59-60, 64-65, 101, 104 |
| src/kernels/resolver.py | 162 | 1 | 99% | 248 |
| src/kernels/status.py | 50 | 2 | 96% | 25, 79 |
| src/kernels/validate.py | 104 | 7 | 93% | 9, 101, 172, 195-196, 232-233 |
| src/kernels/variants.py | 316 | 9 | 97% | 331-332, 374-377, 379, 536-542 |
| src/kernels/verify.py | 102 | 6 | 94% | 44, 176-178, 266-267 |
| TOTAL | 2530 | 256 | 90% |
Updated by the Test kernels workflow on commit 40b5372d7f86f824982564287ec8f6022dc8d54e.
danieldk
marked this pull request as ready for review
November 10, 2026 15:00
sayakpaul
approved these changes
Nov 11, 2026
Comment on lines
+18
to
+20
| Parse a versioned variant string with the regex for the legacy or the new | ||
| variant string format. Both regexes capture the major and minor version. | ||
| """ |
Member
There was a problem hiding this comment.
Maybe also include an example of the legacy and new versions?
Member
Author
There was a problem hiding this comment.
Great idea, added some extra docs.
Comment on lines
+228
to
+240
| _UNVERSIONED_BACKENDS: dict[str, type[CPU] | type[Metal] | type[Neuron] | type[TPU]] = { | ||
| "cpu": CPU, | ||
| "metal": Metal, | ||
| "neuron": Neuron, | ||
| "tpu": TPU, | ||
| } | ||
|
|
||
| _VERSIONED_BACKENDS: dict[str, type[CANN] | type[CUDA] | type[ROCm] | type[XPU]] = { | ||
| "cann": CANN, | ||
| "cuda": CUDA, | ||
| "rocm": ROCm, | ||
| "xpu": XPU, | ||
| } |
| new = parse_variant("torch-2.10-cxx11-cuda-12.8-abi3-x86_64-linux") | ||
| legacy = parse_variant("torch210-cxx11-cu128-x86_64-linux") | ||
| assert new == legacy | ||
| assert hash(new) == hash(legacy) |
drbh
added a commit
that referenced
this pull request
Nov 12, 2026
this pr fixes #995 the legacy backend regexes now use named `major`/`minor` captures and rocm special cases 7.14 (`rocm(?P<major>7(?=14$)|\d+)(?P<minor>\d+)`), so `rocm714` parses as 7.14 and every other version keeps the old split `resolve_local_kernel` also keeps the rejection reasons from every pass, previously the `build/` pass replaced them with an empty trace note: the named captures came out of review so the 7.14 special case reads explicitly. it uses a lookahead since python `re` does not allow the same group name twice in an alternation. this only matters for 7.14 since kernel-builder builds no other two-digit minor, the dotted format from #985 avoids it going forward another note: the trace change is not needed for the parse fix, it only changes the error message. without it the ci error ended in an empty list instead of the rocm version rejection, which is what made this hard to track down new cases in `test_parse_backend_formats` and a regression test for the trace, both fail without the fix --------- Signed-off-by: David Holtz <david.richard.holtz@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Versions in variant notation were inspired by Torch, which used e.g. cu128 for CUDA 12.8. However, this is fragile (e.g. 714 is parsed as 71.4) and inconsistent (e.g. 215 in torch215 is parsed as 2.15).
This PR
torch-2.14androcm-2.7).abi3tsupport (possible tags:abi3andabi3t).cu<major><minor>becomescuda-<major>.<minor>to use the backend name (similar to the noarchtorch-cuda)Full examples of the new variant notation:
torch-2.14-rocm-7.2-abi3-x86_64-linuxtorch-2.14-cuda-13.0-abi3t-x86_64-linuxThis change only adds it to the client, we need support to be around for a few iterations before we can roll out kernels dotted versions.
The legacy notation is still supported, so that all existing kernels load.
Breaking change:
torch-npubecomestorch-cann. But I don't think there are any kernels out there that actually use it, so it should low-impact.