[Refactor] Phaseout execution_backend ctypes#1510
Conversation
… of supported backends across multiple files. Update related documentation and tests to reflect this change, ensuring consistency in the autotuning and JIT compilation processes.
|
👋 Hi! Thank you for contributing to the TileLang project. Please remember to run We appreciate you taking this step! Our team will review your contribution, and we look forward to your awesome work! 🚀 |
WalkthroughRemoved the "ctypes" execution backend across the codebase: type hints and public API signatures were updated to exclude "ctypes", the CtypesKernelAdapter implementation and exports were deleted, tests and docs updated to use other backends, and related kernel/cache/autotuner/JIT wiring adjusted. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tilelang/jit/__init__.py (1)
183-184: Unreachable code detected.Line 184 (
return results) is dead code. The function always returns at line 183 inside thewithblock, making this statement unreachable.🔎 Suggested fix
else: results[idx] = future.result() return results - return results
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (13)
docs/programming_guides/autotuning.mdtesting/python/cpu/test_tilelang_cpu_gemm.pytesting/python/jit/test_tilelang_jit_gemm_cython.pytilelang/autotuner/param.pytilelang/autotuner/tuner.pytilelang/cache/__init__.pytilelang/cache/kernel_cache.pytilelang/jit/__init__.pytilelang/jit/adapter/__init__.pytilelang/jit/adapter/ctypes/__init__.pytilelang/jit/adapter/ctypes/adapter.pytilelang/jit/execution_backend.pytilelang/jit/kernel.py
💤 Files with no reviewable changes (4)
- tilelang/jit/adapter/init.py
- testing/python/jit/test_tilelang_jit_gemm_cython.py
- tilelang/jit/adapter/ctypes/init.py
- tilelang/jit/adapter/ctypes/adapter.py
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-11-14T07:56:11.098Z
Learnt from: lucifer1004
Repo: tile-ai/tilelang PR: 1256
File: testing/python/jit/test_tilelang_jit_gemm_nvrtc.py:55-115
Timestamp: 2025-11-14T07:56:11.098Z
Learning: In `testing/python/jit/test_tilelang_jit_gemm_nvrtc.py`, the global function `tilelang_callback_cuda_postproc` registered via `tvm.register_global_func(..., override=True)` is intentionally not restored after the test completes, as the persistent behavior is expected.
Applied to files:
testing/python/cpu/test_tilelang_cpu_gemm.pytilelang/jit/execution_backend.py
📚 Learning: 2025-12-18T04:50:00.512Z
Learnt from: silentCoder-dev
Repo: tile-ai/tilelang PR: 1464
File: testing/python/language/test_tilelang_language_rand.py:14-14
Timestamp: 2025-12-18T04:50:00.512Z
Learning: In `testing/python/language/test_tilelang_language_rand.py`, the TileLang kernel uses `blk_M = M` (single block) and calls `rng_rand()` four times per element to align results with the Triton implementation, which uses `blk_M = 128` (multiple blocks) and calls the RNG once per element. These differences compensate for internal RNG behavior differences between TileLang and Triton.
Applied to files:
testing/python/cpu/test_tilelang_cpu_gemm.py
🧬 Code graph analysis (2)
testing/python/cpu/test_tilelang_cpu_gemm.py (1)
tilelang/jit/__init__.py (2)
compile(49-115)compile(347-373)
tilelang/jit/kernel.py (6)
tilelang/jit/adapter/nvrtc/adapter.py (1)
get_kernel_source(179-190)tilelang/jit/adapter/cutedsl/adapter.py (1)
get_kernel_source(206-214)tilelang/jit/adapter/tvm_ffi.py (2)
get_kernel_source(304-309)get_host_source(292-296)tilelang/jit/adapter/base.py (1)
get_kernel_source(89-93)tilelang/jit/adapter/cython/adapter.py (1)
get_kernel_source(380-387)tilelang/jit/param.py (1)
get_kernel_source(27-28)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test for Python 3.12 with Metal (on macos-latest)
- GitHub Check: Test for Python 3.12 with Nightly-ROCm-7.1 (on self-hosted-amd)
🔇 Additional comments (15)
tilelang/autotuner/tuner.py (1)
147-147: LGTM! Execution backend type narrowed consistently.The removal of "ctypes" from the execution_backend Literal type in both the method signature (line 147) and the docstring (line 728) is consistent with the PR objective to phase out the ctypes backend.
Also applies to: 728-728
docs/programming_guides/autotuning.md (1)
296-296: LGTM! Documentation updated correctly.The documentation correctly reflects the removal of the ctypes backend option from the execution_backend choices.
tilelang/jit/execution_backend.py (1)
38-47: LGTM! Backend lists updated consistently.The removal of "ctypes" from all allowed backend lists (CUDA, HIP, CPU, and fallback) is complete and consistent. The NVRTC availability check logic remains unchanged, preserving the same runtime filtering behavior.
tilelang/cache/__init__.py (1)
22-22: LGTM! Cache interface updated correctly.The execution_backend type annotation correctly excludes "ctypes", aligning with the broader removal across the codebase.
tilelang/autotuner/param.py (1)
52-52: LGTM! Autotuner parameter types updated correctly.Both
CompileArgs.execution_backendand_load_kernel_from_diskparameter types have been correctly updated to exclude "ctypes" while maintaining valid default values.Also applies to: 268-268
tilelang/jit/kernel.py (1)
66-66: LGTM! JITKernel backend types and checks updated thoroughly.All execution_backend type annotations and backend checks have been correctly updated to exclude "ctypes":
- Constructor and
from_databasesignatures updated (lines 66, 159)- Documentation updated (line 83)
- Source retrieval methods updated (lines 447, 455)
The changes are comprehensive and consistent with the removal of the ctypes adapter.
Also applies to: 83-83, 159-159, 447-447, 455-455
tilelang/cache/kernel_cache.py (1)
51-51: LGTM! Kernel cache backend types updated consistently.All execution_backend type annotations in
KernelCachehave been correctly updated to exclude "ctypes":
- Class attribute (line 51)
_generate_keyparameter (line 80)cachedparameter (line 126)_load_kernel_from_diskparameter (line 392)The changes maintain valid default values and are consistent throughout the class.
Also applies to: 80-80, 126-126, 392-392
testing/python/cpu/test_tilelang_cpu_gemm.py (1)
104-104: Cython backend is correctly configured for CPU target.The change to use
execution_backend="cython"is valid. The execution_backend.py module explicitly allows ["cython", "tvm_ffi"] for the "c" (CPU) target at lines 43-44, and cython is widely used throughout the codebase for CPU compilation.tilelang/jit/__init__.py (7)
49-58: LGTM!The
execution_backendparameter correctly removesctypesfrom the allowed backends. The remaining options are consistent with the PR objectives.
67-69: LGTM!Docstring accurately reflects the updated
execution_backendoptions.
118-129: LGTM!The
execution_backendparameter and docstring correctly updated to removectypes.
258-259: LGTM!The
execution_backendfield type correctly updated to removectypes.
427-427: LGTM!The
ExecutionBackendtype alias correctly updated. All decorator overloads that reference this alias will automatically reflect the change.
476-478: LGTM!Docstring accurately reflects the updated
execution_backendoptions.
519-567: LGTM!The
lazy_jitdecorator correctly uses theExecutionBackendtype alias, which already reflects thectypesremoval.
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
as title, because execution_backend
cythonshared same functionality forctypesbackend.Summary by CodeRabbit
Refactor
Tests
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.