Skip to content

Commit

Permalink
[inductor][Autotune] Add matrix_instr_nonkdim to triton_meta (pytorch…
Browse files Browse the repository at this point in the history
…#122852)

Summary: Previous work `pytorch#120742 to enable `matrix_instr_nonkdim` only dealt with the autotuner benchmarking, but failed to enable the parameter in Triton meta for real runs. `matrix_instr_nonkdim` needs to be visible to the compiler driver to set up the optimization pipeline, so it's unlike other kernel parameters such as `BLOCK_N` that can be just set inside the kernel itself.

Test Plan:
P1201466917

  triton_heuristics.template(
    num_stages=1,
    num_warps=4,
    triton_meta={'signature': {0: '*fp32', 1: '*fp32', 2: '*fp32'}, 'device': 0, 'device_type': 'cuda', 'constants': {}, 'configs': [instance_descriptor(divisible_by_16=(0, 1, 2), equal_to_1=(), ids_of_folded_args=(), divisible_by_8=())], 'matrix_instr_nonkdim': 16},
    inductor_meta={'kernel_name': 'triton_tem_fused_mm_0', 'backend_hash': None},
  )

Perf :
Before: 1.693ms    0.134GB    79.28GB/s
After:    1.577ms    0.134GB    85.12GB/s

Differential Revision: D55456401

Pull Request resolved: pytorch#122852
Approved by: https://github.com/xw285cornell
  • Loading branch information
htyu authored and Sanket Jayant Purandare committed Apr 22, 2024
1 parent 65893fd commit e99b239
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions torch/_inductor/select_algorithm.py
Expand Up @@ -157,6 +157,10 @@ def jit_lines(self):
triton_meta["configs"] = [config_of(signature)]
for arg_num in triton_meta["configs"][0].equal_to_1: # type: ignore[index]
triton_meta["constants"][arg_num] = 1 # type: ignore[index]
matrix_instr_nonkdim = self.meta.get("matrix_instr_nonkdim", 0)
if matrix_instr_nonkdim != 0:
triton_meta["matrix_instr_nonkdim"] = matrix_instr_nonkdim

self.triton_meta = triton_meta

inductor_meta = {
Expand Down

0 comments on commit e99b239

Please sign in to comment.