Repository navigation
Conversation
|
Hi @Qubitium, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/huggingface/kernels/blob/main/CONTRIBUTING.md for more details. |
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.
Summary
Adds an opt-in CPU JIT fallback to
get_kernel. Fresh JIT cache entries are now loaded before any prebuilt/Hub resolution, with a one-hour default TTL. On a cache miss or expiry, normal resolution runs and a compatible prebuilt variant is still preferred when one exists. If no prebuilt exists,jit=Trueresolves the kernel's source repository and pinned commit from build metadata, builds it against the installed Torch, caches the result, and loads it through the existing local-kernel path.JITOptionssupports an explicit local source tree or GitHub URL for kernels whose metadata predates source recording.JITOptions(cache_ttl=...)controls cache-first reuse: the default is 3600 seconds,Nonedisables expiry, and0disables the fast path.Design
jit.jsonsidecar recording the requested version/revision, resolved revision, source, source commit/subdir, cache key, andvalidated_at.kernels-community/*repositories without asourcefield map to their directory inhuggingface/kernels-community.kernel-builder, CMake, Ninja, or compiler produces an actionable error.Validation
On this host (AMD EPYC 9V33X, torch
2.16.0.dev20261020+cpu, Python 3.14.4):get_kernel("kernels-community/quantization-gptq", version=1, backend="cpu")rejects every prebuilt variant.jit=Truebuildstorch216-cpu-x86_64-linuxfrom pinned source and exposesgemm_int4_forward.0.25,0.25, and0.125for three representative shapes.jit=Trueuses the existing prebuilttorch214-cxx11-cpu-x86_64-linuxvariant and creates no JIT cache entry.18 passedintests/test_jit.py; Ruff passes withruff==0.15.10.Limitations
kernel-builder, CMake >= 3.26, Ninja, and a C++17 compiler.cache_ttl=0to force revalidation on every load.Validation update
Validated
jit=Trueagainst all 55 kernel repositories advertising a CPU build at validation time, using Python 3.14.4 and torch2.16.0.dev20261020+cpu.kernels-community/*SZLHOLDINGS/*phanerozoic/*thyn-ai/*JIT-built successfully:
activation,flash-attn2,megablocks,quantization-bitsandbytes,quantization-gptq,relu,rmsnorm, androtary.In the full sweep, cold builds took approximately 22–26 seconds. Cache hits now take 0.171 seconds after imports or 1.41 seconds fresh-process wall time, down from approximately 3.0–3.4 seconds.
einopsandgpt-oss-triton-kernelsused compatible prebuilt variants and created no JIT cache entries.Source discovery now considers CPU variants only, avoiding metadata downloads for CUDA/XPU/Metal variants.
18 passedintests/test_jit.py; Ruff passes withruff==0.15.10.JIT requires a reproducible source revision. Kernels publishing only build artifacts cannot be compiled automatically unless source is supplied through
JITOptions(source=...). Runtime Python dependencies are not installed automatically; for example,megablocksrequirestritonat import time (triton==3.8.0was installed for validation).Current fork branch:
Qubitium/kernels:feat/cpu-jit-fallbackat3e93f57. GitHub's closed PR head remains pinned to the originalb67e885, so the follow-up commits are visible on the fork branch rather than in this PR's commit list.Follow-up commits:
e611d5d(CPU-only source discovery),1d7830d(reproducible-source documentation), and3e93f57(TTL cache-first JIT reloads). Relevant paths:kernels/src/kernels/jit.py:53,:84,:147,:389,:591;kernels/tests/test_jit.py:224;kernels/README.md:66.