Skip to content

For adding TDM in separate PRs, deleted TDM related code that is inaccurate, incomplete, or incorrect#3377

Open
glen-amd wants to merge 1 commit into
release/2.11from
rel2.11_gfx1250_fixes
Open

For adding TDM in separate PRs, deleted TDM related code that is inaccurate, incomplete, or incorrect#3377
glen-amd wants to merge 1 commit into
release/2.11from
rel2.11_gfx1250_fixes

Conversation

@glen-amd

Copy link
Copy Markdown

Remove non-functional gfx1250 TDM (Tensor Data Mover) autotuning path

Summary

Removes the Inductor "TDM" code added in 8f31771df8d ("Temp 2.11 1250 tdm"). That change was built on an incorrect premise and never actually produced TDM instructions; this PR deletes it cleanly along with its now-dead arch helper, and reverts the one pre-existing method it had modified.

Background / motivation

The removed code assumed:

When num_stages > 1, Triton's AMD backend automatically converts tl.load into TDM instructions.

This is not how the AMD Triton backend (gfx1250) works. TDM is emitted only from tensor-descriptor ops (tl.make_tensor_descriptor / Gluon tdm.*), which lower to llvm.amdgcn.tensor.load.to.lds / tensor.store.from.lds and synchronize via s_wait_tensorcnt. A plain tl.load + num_stages > 1 lowers to the generic async-copy-to-LDS path (global_load_async_to_lds_*, s_wait_asynccnt) — a different hardware mechanism with a different counter (asynccnt vs tensorcnt). It is never TDM.

Consequently use_triton_tdm_template() only selected the stock persistent_mm_template (raw pointer loads) — the same template the ROCm TMA path already falls back to — and emitted no descriptors and no TDM. The gate also only log.debug'd on misaligned/non-unit strides instead of rejecting them. The feature is off by default (TORCHINDUCTOR_ENABLE_TDM_CONFIGS=0) and additionally gated on gfx1250 + Triton ≥ 3.6, so in practice the path was dead. The original commit message ("Temp") reflects its provisional nature.

A correct, descriptor-based implementation is being pursued separately; this PR clears the misleading stopgap so it doesn't ship or mislead readers.

Changes

  • config.py — remove enable_tdm_configs flag and class tdm constants.
  • utils.py — remove use_triton_tdm_template() and the is_gfx1250_arch() helper (introduced solely to support the TDM gate; no remaining callers).
  • template_heuristics/triton.py — remove _is_gfx1250_device(), _filter_tdm_block_k_configs(), tdm_persistent_mm_configs, uses_tdm_configs, the preprocess_mm_configs override, and the gfx1250 branch in PersistentMMTemplateConfigHeuristic.__init__. Revert ROCmConfigHeuristic._filter_configs to its pre-TDM body (this method pre-existed and was only modified by the TDM commit).
  • kernel/mm.py — remove the "tdm" dispatch branch in _append_persistent_mm_template and its import.
  • kernel/flex/common.py — remove apply_tdm_num_stages() and revert the config import.
  • kernel/flex/flex_attention.py, flex_decoding.py — remove the TDM call sites and imports (can_use_tma retained).
  • Tests — remove the four TDM-specific tests in test_max_autotune.py and TestFlexAttentionTDMOptions in test_flex_attention.py.

Scope / what is intentionally kept

The "Temp" commit also bundled non-TDM gfx1250 work that this PR deliberately leaves intact:

  • the _append_persistent_mm_template refactor (Blackwell-TMA branch, ROCm TMA→persistent fallback);
  • test_shared_memory_estimation_counts_num_stages_once (exercises the pre-existing get_shared_memory_estimation, not TDM);
  • the general gfx1250 CI workflow and build.sh arch handling.

Risk

Low. The removed path was disabled by default and functionally inert. Net +5 / −454 across 9 files. A repo-wide grep confirms no remaining references to any removed symbol; _filter_configs is restored to its original behavior so non-gfx1250 ROCm autotuning is unchanged.

Test plan

  • python -m pytest test/inductor/test_max_autotune.py
  • python -m pytest test/inductor/test_flex_attention.py
  • Inductor import / smoke check (python -c "import torch._inductor.kernel.mm, torch._inductor.template_heuristics.triton")
  • ROCm GEMM + FlexAttention max-autotune sanity on a non-gfx1250 ROCm device (behavior should be unchanged)

@rocm-repo-management-api

rocm-repo-management-api Bot commented Jun 29, 2026

Copy link
Copy Markdown

Jenkins build for 709d7a87a6a0eeceeccfec75d2d81f14e8b3df09 commit finished as FAILURE
Links: Pipeline Overview / Build artifacts / Test Results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant