mirror of
https://github.com/tile-ai/tilelang.git
synced 2026-10-20 06:30:07 +08:00
Merge upstream main (85fd8fc2) into the Ascend comparison snapshot. This brings
in #3177, #3181, #3182, #3185 (AutoSchedule -> AutoWarpSpecialization) and
#3186 (target-neutral T.Kernel with dialect-owned launch annotations).
Conflict resolution:
- AutoSchedule -> AutoWarpSpecialization (#3185) supersedes the snapshot's own
disambiguation rename to `tl.cuda_auto_schedule`; upstream's name is already
distinct from Ascend's boolean `tl.enable_auto_schedule`, so the CUDA rename is
taken wholesale and `TL_ENABLE_AUTO_SCHEDULE` (Ascend-only) is kept.
`testing/python/backend/test_tilelang_backend_auto_schedule.py` follows.
- `tilelang/language/kernel.py` is now upstream's target-neutral implementation,
unchanged. The Ascend additions it used to carry (`check_ascend_availability`,
`_current_target_is_ascend`, the `is_cpu`/`is_ascend` branches in `Kernel`, the
annotation-sniffing grid/thread split in `KernelLaunchFrame.__enter__`, and the
SimtVF hooks in the thread accessors) are relocated, not adapted: see below.
- `tilelang/language/__init__.py` keeps the fork's Ascend facade and gains
upstream's typed `Kernel` re-export.
Ascend now owns its launch surface, so the shared launch path carries no backend
branches and no runtime hardware probe:
- `tilelang/ascend/language/kernel.py` defines the dialect's `Kernel(*blocks,
prelude=)`: the NPU 1-D core grid, with no `threads=`/`cluster_dims=` to be
rejected at runtime because Python rejects the keywords. It also owns the
SimtVF thread-scope state and the `get_thread_binding(s)`/`get_thread_extent(s)`
accessors that resolve against an active `T.SimtVF` scope.
- `MaterializeKernelLaunch` splits "how a launch dimension is lowered" from
"whether SIMT threads exist", which the old single `lower_thread_binding` flag
conflated: Ascend needs the grid materialized as a real block-level
thread_extent while having no threadIdx at kernel scope. `lower_grid_binding`
defaults to None and follows `lower_thread_binding`, so every existing caller
and test keeps its meaning. `launch_dim_tags` lets a backend name extra launch
dimensions; Ascend passes `cthread` for `T.MixedKernel`'s sub-block-id.
- `MixedKernelLaunch` populates the frame's new grid_vars/thread_vars fields and
emits the thread placeholders like `KernelLaunch` does, so a body referencing a
thread index gets the actionable diagnostic instead of an out-of-range lookup.
- `tilelang.is_cpu_kernel_frame` / `tilelang.is_npu_kernel_frame` are dropped from
`src/transform/common/attr.h`: the explicit grid_vars/thread_vars fields replaced
every reader the snapshot had added for them.
Combining them also removes the cross-backend landmine where, on any host with
torch_npu available, the shared `T.Kernel(N, threads=...)` raised even for CUDA
targets.