TileLang Simplification
Turn a broad request to "simplify TileLang" into a small set of
evidence-backed changes that reduce maintained concepts, contracts, or code
paths. Fewer lines are not sufficient: preserve correctness, useful
diagnostics, supported targets, public compatibility, compile behavior, and
kernel performance unless the user explicitly accepts a tradeoff.
Choose The Working Mode
- Survey: inspect broadly and report ranked candidates. Do not modify code,
add TODOs, or create issues unless requested.
- Implement: prove the selected candidate first, then make the smallest
complete change, including tests, documentation, exports, registration, and
build metadata affected by the removal.
- Review: determine whether a proposed simplification is a net reduction
and whether its evidence and validation cover all affected targets.
For a broad survey, continue past the first plausible candidate. Prefer a few
high-confidence reductions over a long list of speculative cleanups.
Establish Repository Context
Read README.md and CONTRIBUTING.md, inspect the worktree, and identify the
requested base revision before judging current code. Exclude 3rdparty/,
build/, docs/_build/, caches, generated files, and vendored target stubs by
default; include them only when the request specifically concerns generated,
vendored, or packaging surface.
Load the relevant domain skill before judging a candidate in that area:
Do not load every domain skill for a narrow audit.
What Counts As A Strong Candidate
A strong candidate removes or folds a real maintenance burden and has direct
evidence that the current surface costs more than it protects. Typical
candidates include:
- an internal API, option, pass, callback, registry entry, helper, or package
with no production consumer;
- a Python wrapper, C++ entry point, or FFI binding that duplicates another
representation without owning validation, compatibility, or policy;
- target selection or execution dispatch repeated outside
BackendContext or
a backend-owned pipeline;
- backend-local implementations with genuinely identical semantics that can
move behind an existing common boundary;
- pass configuration, annotations, analyses, or state that are produced and
propagated but never observed;
- adjacent passes or lifecycle mechanisms that preserve the same fact and can
be represented once;
- obsolete compatibility facades, aliases, or migrations whose supported
callers and documented transition window are gone;
- tests, snapshots, examples, or generated expectations that exist only to pin
an unused implementation detail;
- hand-rolled utilities already provided by the Python/C++ standard library,
TVM, or an existing dependency, when replacement deletes the implementation
and its special-case tests without hiding equivalent complexity in glue;
- build, packaging, or toolchain branches for artifacts that are no longer
produced or consumed.
Weak candidates include style-only churn, a single typo, an abstraction that
merely looks complicated, or a target-specific path that appears unused only
because the current machine cannot exercise it. Moving the same complexity
behind a new wrapper is not simplification.
Survey By Ownership Area
For repository-wide work, divide the survey into these areas, in parallel when
practical:
- language APIs, Python exports, IR objects, FFI registrations, and
compatibility aliases;
- shared transforms, pass configuration, analyses, annotations, and pipeline
ordering;
- target backends, execution backends, codegen, runtime, cache, and toolchain
integration;
- layouts, intrinsics, MMA/TMA paths, vectorization, and architecture-specific
lowering;
- autotuning, profiler, carver, diagnostics, instrumentation, and developer
tooling;
- CMake, packaging, tests, examples, benchmarks, maintenance scripts, and
documentation.
Start with large or repeated production-code surfaces, not only symbols found
by an unused-code tool.
Prove Consumers And Reachability
Use rg first, then read every relevant call site. Search the exact C++ or
Python symbol, its exported alias, registered string, pass-config key, target
name, annotation key, and generated symbol. Classify references as:
- production:
tilelang/, src/, cmake/, CMakeLists.txt, packaging
metadata, runtime templates, and loader or registration paths;
- coverage and usage evidence:
testing/, examples/, benchmark/, and
maint/; examples and maintenance programs may be supported smoke paths,
so inspect them before dismissing them;
- documentation only:
README.md and docs/;
- excluded/generated/vendor: the excluded trees listed above.
Static text search is not sufficient for TileLang. Before declaring code dead,
check all applicable indirect-use mechanisms:
TVM_FFI_STATIC_INIT_BLOCK, TVM_REGISTER_*,
TIR_REGISTER_TL_TILE_OP, reflected object fields, and global function
names;
- Python
tvm_ffi.register_object, _ffi_api bindings, __init__.py
re-exports, __all__, decorators, and compatibility facades;
BackendModule manifests, target predicates, execution compatibility,
callback maps, and backend package import side effects;
- pass factories referenced by registered names, backend pipeline lists, and
PassContext configuration strings;
- CMake source lists and object files retained for static initialization;
- generated runtime-template symbol names, cache keys, serialized artifacts,
and codegen-emitted calls.
Useful discovery searches include:
rg -n "ExactSymbol|registered.string|config_key" tilelang src cmake \
CMakeLists.txt testing examples benchmark maint docs
rg -n "TVM_FFI_STATIC_INIT_BLOCK|TVM_REGISTER_|TIR_REGISTER_TL_TILE_OP|register_object|register_backend|__all__" \
tilelang src
Treat static analyzers as inventory aids, not proof; dynamic FFI, registration,
and target dispatch routinely hide valid consumers.
Absence of an in-tree caller proves only in-tree reachability. Treat exported
Python APIs, FFI and reflection names, pass-config and annotation strings,
target names, runtime ABI, and cache or serialized formats as externally
consumed until documentation, release history, and deprecation policy provide
evidence otherwise. Tests describe important cases but are not the sole source
of the contract.
Trace The Compiler Contract
For a compiler or language candidate, trace one representative construct from
the source API through its TIR/TileOp representation, annotations, selected
backend pipeline, lowering passes, host/device split, codegen, and runtime
consumption. Name the first stage that requires the surface being considered.
Before merging or deleting passes, determine:
- which backend pipelines include each pass and in what order;
- the preconditions, annotations, and analyses each pass consumes and emits;
- whether a pass is a no-op only for the inspected example or architecture;
- whether diagnostics or source spans become less useful after moving it;
- whether generated source, launch metadata, cache identity, or runtime ABI
changes even when final numerical results do not.
Do not replace a semantic check with an optimizer assumption, or delete a
fallback merely because the optimized path handles common examples.
When a new dependency would replace hand-rolled code, prefer the standard
library, TVM, or an existing dependency first. Otherwise check supported
Python versions and platforms, wheel or native-build availability, license,
maintenance, transitive footprint, and net code deletion. A dependency that
moves equivalent complexity into adapters, CMake, or wheel packaging is not a
simplification.
Respect Backend And Hardware Boundaries
Target backends and execution backends are intentionally separate. Do not
collapse CUDA, CuTeDSL, ROCm, CPU, Metal, WebGPU, or their execution adapters
solely because implementations currently resemble one another. A shared
helper is justified only when ownership is target-neutral and the supported
capability differences remain explicit.
Absence of a runnable device is not evidence that a path is dead. For every
backend-facing candidate, record:
- target kinds and architecture predicates that can reach it;
- source-only or hardware-independent checks available locally;
- hardware and toolchain coverage that would still be required;
- intentional unsupported cases and fallback behavior.
Protect Performance-Sensitive Semantics
A simpler compiler implementation can produce slower kernels or slower
compilation while remaining numerically correct. Scale evidence to the risk:
- for cold Python helpers, imports and focused unit tests may be enough;
- for transforms and codegen, compare relevant IR and generated source;
- for layout, vectorization, memory movement, synchronization, MMA/TMA,
pipeline, or autotuning changes, run the subsystem harness and representative
hardware benchmarks when available;
- for build, cache, JIT, or runtime changes, verify Build, load, launch, cache
hit behavior, and artifact portability that the path claims to support.
If hardware validation is unavailable, report the gap. Do not convert missing
performance evidence into a claim of equivalence.
Decide The Candidate
Classify each investigated item:
- safe deletion: internal, unreachable through direct or indirect paths,
and not part of a supported compatibility or artifact contract;
- consolidation: multiple paths implement the same contract and an existing
owner can absorb them with less total branching and state;
- behavior or API tradeoff: simplification changes a public API, FFI name,
IR/annotation contract, target capability, generated source, cache format, or
performance characteristic; require explicit acceptance;
- unproven or intentional: keep it and record why the apparent duplication
is load-bearing.
Use history to understand intent when current code is ambiguous, but judge
reachability and contracts from the current tree. Reject a candidate when the
proposal forces broad unrelated churn without reducing concepts, ownership
boundaries, or supported behavior.
Report Or Implement
For a survey, report each retained candidate with:
- affected files, symbols, or registered names;
- current responsibility and production consumers;
- exact removal or consolidation proposed;
- compatibility, target, correctness, and performance tradeoffs;
- validation required and any unavailable hardware;
- confidence level.
Also mention representative rejected candidates when they explain intentional
architecture or prevent repeated false positives.
For implementation, remove the whole obsolete surface: definitions,
declarations, exports, registrations, configuration, CMake/package entries,
tests that only pin deleted behavior, and stale documentation. Preserve tests
that express the surviving contract, and add a regression test when the new
boundary would otherwise be ambiguous. Use the repository formatter on touched
files, follow ../tilelang-build/SKILL.md for
build and test commands, and always run git diff --check.
In the final report, state the conceptual surface removed, the supported
behavior retained or intentionally given up, the checks run, and hardware or
toolchain validation not performed.
1---2name: tilelang-simplification3description: Find, evaluate, propose, implement, or review non-obvious simplifications in TileLang. Use for broad simplification audits; dead or duplicated compiler, runtime, backend, layout, build, test, or API surface; collapsing unnecessary abstractions or pass machinery; removing stale compatibility paths; or replacing hand-rolled infrastructure. Do not use for a routine localized refactor whose desired change is already known.4---56# TileLang Simplification78Turn a broad request to "simplify TileLang" into a small set of9evidence-backed changes that reduce maintained concepts, contracts, or code10paths. Fewer lines are not sufficient: preserve correctness, useful11diagnostics, supported targets, public compatibility, compile behavior, and12kernel performance unless the user explicitly accepts a tradeoff.1314## Choose The Working Mode1516- **Survey**: inspect broadly and report ranked candidates. Do not modify code,17 add TODOs, or create issues unless requested.18- **Implement**: prove the selected candidate first, then make the smallest19 complete change, including tests, documentation, exports, registration, and20 build metadata affected by the removal.21- **Review**: determine whether a proposed simplification is a net reduction22 and whether its evidence and validation cover all affected targets.2324For a broad survey, continue past the first plausible candidate. Prefer a few25high-confidence reductions over a long list of speculative cleanups.2627## Establish Repository Context2829Read `README.md` and `CONTRIBUTING.md`, inspect the worktree, and identify the30requested base revision before judging current code. Exclude `3rdparty/`,31`build/`, `docs/_build/`, caches, generated files, and vendored target stubs by32default; include them only when the request specifically concerns generated,33vendored, or packaging surface.3435Load the relevant domain skill before judging a candidate in that area:3637- target or execution backends: [`../tilelang-backend/SKILL.md`](../tilelang-backend/SKILL.md)38 and `tilelang/backend/README.md`;39- layouts, fragments, inference, or CuTe conversion:40 [`../tilelang-layout/SKILL.md`](../tilelang-layout/SKILL.md);41- legality checks, safety checks, or diagnostics:42 [`../tilelang-semantic/SKILL.md`](../tilelang-semantic/SKILL.md);43- C++ TIR/ObjectRef ownership:44 [`../tilelang-tvm-ir/SKILL.md`](../tilelang-tvm-ir/SKILL.md);45- broad C++ cleanup: [`../tilelang-cpp-style/SKILL.md`](../tilelang-cpp-style/SKILL.md);46- builds and tests: [`../tilelang-build/SKILL.md`](../tilelang-build/SKILL.md).4748Do not load every domain skill for a narrow audit.4950## What Counts As A Strong Candidate5152A strong candidate removes or folds a real maintenance burden and has direct53evidence that the current surface costs more than it protects. Typical54candidates include:5556- an internal API, option, pass, callback, registry entry, helper, or package57 with no production consumer;58- a Python wrapper, C++ entry point, or FFI binding that duplicates another59 representation without owning validation, compatibility, or policy;60- target selection or execution dispatch repeated outside `BackendContext` or61 a backend-owned pipeline;62- backend-local implementations with genuinely identical semantics that can63 move behind an existing common boundary;64- pass configuration, annotations, analyses, or state that are produced and65 propagated but never observed;66- adjacent passes or lifecycle mechanisms that preserve the same fact and can67 be represented once;68- obsolete compatibility facades, aliases, or migrations whose supported69 callers and documented transition window are gone;70- tests, snapshots, examples, or generated expectations that exist only to pin71 an unused implementation detail;72- hand-rolled utilities already provided by the Python/C++ standard library,73 TVM, or an existing dependency, when replacement deletes the implementation74 and its special-case tests without hiding equivalent complexity in glue;75- build, packaging, or toolchain branches for artifacts that are no longer76 produced or consumed.7778Weak candidates include style-only churn, a single typo, an abstraction that79merely looks complicated, or a target-specific path that appears unused only80because the current machine cannot exercise it. Moving the same complexity81behind a new wrapper is not simplification.8283## Survey By Ownership Area8485For repository-wide work, divide the survey into these areas, in parallel when86practical:87881. language APIs, Python exports, IR objects, FFI registrations, and89 compatibility aliases;902. shared transforms, pass configuration, analyses, annotations, and pipeline91 ordering;923. target backends, execution backends, codegen, runtime, cache, and toolchain93 integration;944. layouts, intrinsics, MMA/TMA paths, vectorization, and architecture-specific95 lowering;965. autotuning, profiler, carver, diagnostics, instrumentation, and developer97 tooling;986. CMake, packaging, tests, examples, benchmarks, maintenance scripts, and99 documentation.100101Start with large or repeated production-code surfaces, not only symbols found102by an unused-code tool.103104## Prove Consumers And Reachability105106Use `rg` first, then read every relevant call site. Search the exact C++ or107Python symbol, its exported alias, registered string, pass-config key, target108name, annotation key, and generated symbol. Classify references as:109110- **production**: `tilelang/`, `src/`, `cmake/`, `CMakeLists.txt`, packaging111 metadata, runtime templates, and loader or registration paths;112- **coverage and usage evidence**: `testing/`, `examples/`, `benchmark/`, and113 `maint/`; examples and maintenance programs may be supported smoke paths,114 so inspect them before dismissing them;115- **documentation only**: `README.md` and `docs/`;116- **excluded/generated/vendor**: the excluded trees listed above.117118Static text search is not sufficient for TileLang. Before declaring code dead,119check all applicable indirect-use mechanisms:120121- `TVM_FFI_STATIC_INIT_BLOCK`, `TVM_REGISTER_*`,122 `TIR_REGISTER_TL_TILE_OP`, reflected object fields, and global function123 names;124- Python `tvm_ffi.register_object`, `_ffi_api` bindings, `__init__.py`125 re-exports, `__all__`, decorators, and compatibility facades;126- `BackendModule` manifests, target predicates, execution compatibility,127 callback maps, and backend package import side effects;128- pass factories referenced by registered names, backend pipeline lists, and129 `PassContext` configuration strings;130- CMake source lists and object files retained for static initialization;131- generated runtime-template symbol names, cache keys, serialized artifacts,132 and codegen-emitted calls.133134Useful discovery searches include:135136```bash137rg -n "ExactSymbol|registered.string|config_key" tilelang src cmake \138 CMakeLists.txt testing examples benchmark maint docs139rg -n "TVM_FFI_STATIC_INIT_BLOCK|TVM_REGISTER_|TIR_REGISTER_TL_TILE_OP|register_object|register_backend|__all__" \140 tilelang src141```142143Treat static analyzers as inventory aids, not proof; dynamic FFI, registration,144and target dispatch routinely hide valid consumers.145146Absence of an in-tree caller proves only in-tree reachability. Treat exported147Python APIs, FFI and reflection names, pass-config and annotation strings,148target names, runtime ABI, and cache or serialized formats as externally149consumed until documentation, release history, and deprecation policy provide150evidence otherwise. Tests describe important cases but are not the sole source151of the contract.152153## Trace The Compiler Contract154155For a compiler or language candidate, trace one representative construct from156the source API through its TIR/TileOp representation, annotations, selected157backend pipeline, lowering passes, host/device split, codegen, and runtime158consumption. Name the first stage that requires the surface being considered.159160Before merging or deleting passes, determine:161162- which backend pipelines include each pass and in what order;163- the preconditions, annotations, and analyses each pass consumes and emits;164- whether a pass is a no-op only for the inspected example or architecture;165- whether diagnostics or source spans become less useful after moving it;166- whether generated source, launch metadata, cache identity, or runtime ABI167 changes even when final numerical results do not.168169Do not replace a semantic check with an optimizer assumption, or delete a170fallback merely because the optimized path handles common examples.171172When a new dependency would replace hand-rolled code, prefer the standard173library, TVM, or an existing dependency first. Otherwise check supported174Python versions and platforms, wheel or native-build availability, license,175maintenance, transitive footprint, and net code deletion. A dependency that176moves equivalent complexity into adapters, CMake, or wheel packaging is not a177simplification.178179## Respect Backend And Hardware Boundaries180181Target backends and execution backends are intentionally separate. Do not182collapse CUDA, CuTeDSL, ROCm, CPU, Metal, WebGPU, or their execution adapters183solely because implementations currently resemble one another. A shared184helper is justified only when ownership is target-neutral and the supported185capability differences remain explicit.186187Absence of a runnable device is not evidence that a path is dead. For every188backend-facing candidate, record:189190- target kinds and architecture predicates that can reach it;191- source-only or hardware-independent checks available locally;192- hardware and toolchain coverage that would still be required;193- intentional unsupported cases and fallback behavior.194195## Protect Performance-Sensitive Semantics196197A simpler compiler implementation can produce slower kernels or slower198compilation while remaining numerically correct. Scale evidence to the risk:199200- for cold Python helpers, imports and focused unit tests may be enough;201- for transforms and codegen, compare relevant IR and generated source;202- for layout, vectorization, memory movement, synchronization, MMA/TMA,203 pipeline, or autotuning changes, run the subsystem harness and representative204 hardware benchmarks when available;205- for build, cache, JIT, or runtime changes, verify Build, load, launch, cache206 hit behavior, and artifact portability that the path claims to support.207208If hardware validation is unavailable, report the gap. Do not convert missing209performance evidence into a claim of equivalence.210211## Decide The Candidate212213Classify each investigated item:214215- **safe deletion**: internal, unreachable through direct or indirect paths,216 and not part of a supported compatibility or artifact contract;217- **consolidation**: multiple paths implement the same contract and an existing218 owner can absorb them with less total branching and state;219- **behavior or API tradeoff**: simplification changes a public API, FFI name,220 IR/annotation contract, target capability, generated source, cache format, or221 performance characteristic; require explicit acceptance;222- **unproven or intentional**: keep it and record why the apparent duplication223 is load-bearing.224225Use history to understand intent when current code is ambiguous, but judge226reachability and contracts from the current tree. Reject a candidate when the227proposal forces broad unrelated churn without reducing concepts, ownership228boundaries, or supported behavior.229230## Report Or Implement231232For a survey, report each retained candidate with:2332341. affected files, symbols, or registered names;2352. current responsibility and production consumers;2363. exact removal or consolidation proposed;2374. compatibility, target, correctness, and performance tradeoffs;2385. validation required and any unavailable hardware;2396. confidence level.240241Also mention representative rejected candidates when they explain intentional242architecture or prevent repeated false positives.243244For implementation, remove the whole obsolete surface: definitions,245declarations, exports, registrations, configuration, CMake/package entries,246tests that only pin deleted behavior, and stale documentation. Preserve tests247that express the surviving contract, and add a regression test when the new248boundary would otherwise be ambiguous. Use the repository formatter on touched249files, follow [`../tilelang-build/SKILL.md`](../tilelang-build/SKILL.md) for250build and test commands, and always run `git diff --check`.251252In the final report, state the conceptual surface removed, the supported253behavior retained or intentionally given up, the checks run, and hardware or254toolchain validation not performed.