code: def matmul_kernel(
      a_ptr,
      b_ptr,
      w_ptr,
      bias_ptr,
      z_ptr,  #
      M,
      N,
      K,  #
      stride_am,
      stride_ak,  #
      stride_bk,
      stride_bn,  #
      stride_wm,
      stride_wn,  #
      stride_zm,
      stride_zn,  #
      BLOCK_M: tl.constexpr,
      BLOCK_N: tl.constexpr,
      BLOCK_K: tl.constexpr,
      GROUP_SIZE_M: tl.constexpr,  #
      out_dtype: tl.constexpr,
      USE_TMA_STORE: tl.constexpr,  #
      ADD_MATRIX: tl.constexpr,
      ADD_ROWS: tl.constexpr,
      ADD_COLS: tl.constexpr,  #
      DO_SOFTMAX: tl.constexpr,
      CHAIN_DOT: tl.constexpr,  #
      A_ORDER_0: tl.constexpr,
      A_ORDER_1: tl.constexpr,  #
      B_ORDER_0: tl.constexpr,
      B_ORDER_1: tl.constexpr,  #
      W_ORDER_0: tl.constexpr,
      W_ORDER_1: tl.constexpr,  #
      Z_ORDER_0: tl.constexpr,
      Z_ORDER_1: tl.constexpr,  #
  ):
      pid = tl.program_id(axis=0)
      num_pid_n = tl.cdiv(N, BLOCK_N)
      num_pid_m = tl.cdiv(M, BLOCK_M)
      num_pid_in_group = GROUP_SIZE_M * num_pid_n
      group_id = pid // num_pid_in_group
      first_pid_m = group_id * GROUP_SIZE_M
      group_size_m = min(num_pid_m - first_pid_m, GROUP_SIZE_M)
      pid_m = first_pid_m + (pid % group_size_m)
      pid_n = (pid % num_pid_in_group) // group_size_m
      block_offset_m = pid_m * BLOCK_M
      block_offset_n = pid_n * BLOCK_N
  
      a_tile_ptr = tl.make_block_ptr(
          base=a_ptr,
          shape=(M, K),
          strides=(stride_am, stride_ak),
          offsets=(block_offset_m, 0),
          block_shape=(BLOCK_M, BLOCK_K),
          order=(A_ORDER_0, A_ORDER_1),
      )
      b_tile_ptr = tl.make_block_ptr(
          base=b_ptr,
          shape=(K, N),
          strides=(stride_bk, stride_bn),
          offsets=(0, block_offset_n),
          block_shape=(BLOCK_K, BLOCK_N),
          order=(B_ORDER_0, B_ORDER_1),
      )
      # for chain-dot, BLOCK_N must always be equal to N, and each program loads the whole W matrix
      w_tile_ptr = tl.make_block_ptr(
          base=w_ptr,
          shape=(N, N),
          strides=(stride_wm, stride_wn),
          offsets=(0, 0),
          block_shape=(BLOCK_N, BLOCK_N),
          order=(W_ORDER_0, W_ORDER_1),
      )
      z = tl.zeros((BLOCK_M, BLOCK_N), dtype=tl.float32)
  
      offs_m = block_offset_m + tl.arange(0, BLOCK_M)
      offs_n = block_offset_n + tl.arange(0, BLOCK_N)
      z_ptrs = (
          z_ptr
          + offs_m[:, None] * stride_zm
          + offs_n[None, :] * stride_zn
      )
      bias_ptrs = (
          bias_ptr
          + offs_m[:, None] * stride_zm
          + offs_n[None, :] * stride_zn
      )
      mask = (offs_m < M)[:, None] & (offs_n < N)[None, :]
  
      for k in range(0, K, BLOCK_K):
          a = tl.load(a_tile_ptr, boundary_check=(0, 1))
          b = tl.load(b_tile_ptr, boundary_check=(0, 1))
          z += tl.dot(a, b)
          a_tile_ptr = tl.advance(a_tile_ptr, [0, BLOCK_K])
          b_tile_ptr = tl.advance(b_tile_ptr, [BLOCK_K, 0])
  
      z = z.to(out_dtype)
  
      if ADD_MATRIX:
          z += tl.load(bias_ptrs, mask=mask)
      if ADD_ROWS:
          ZRs = bias_ptr + offs_m * stride_zm
          z += tl.load(ZRs)[:, None]
      if ADD_COLS:
          ZCs = bias_ptr + offs_n * stride_zn
          z += tl.load(ZCs)[None, :]
      if DO_SOFTMAX:
          max = tl.max(z, 1)
          z = z - max[:, None]
          num = tl.exp(z.to(tl.float32)).to(max.dtype)
          den = tl.sum(num, 1)
          z = num / den[:, None]
      if CHAIN_DOT:
          w = tl.load(w_tile_ptr)
          z = tl.dot(z.to(w.dtype), w)
          z = z.to(out_dtype)
  
      if USE_TMA_STORE:
          z_block_ptr = tl.make_block_ptr(
              base=z_ptr,
              shape=(M, N),
              strides=(stride_zm, stride_zn),
              offsets=(block_offset_m, block_offset_n),
              block_shape=(BLOCK_M, BLOCK_N),
              order=(Z_ORDER_0, Z_ORDER_1),
          )
          tl.store(z_block_ptr, z, boundary_check=(0, 1))
      else:
          tl.store(z_ptrs, z, mask=mask)
  
file_path: triton/python/test/unit/hopper/test_gemm.py
imports: import itertools
  import os
  import re
  import pytest
  import torch
  from torch.testing import assert_close
  import triton
  import triton.language
label_desc: Use image node_id 3 for calling a global function with example usage: matmul_kernel(a_ptr, b_ptr, w_ptr, bias_ptr, z_ptr, M, N, K, stride_am, stride_ak, stride_bk, stride_bn, stride_wm, stride_wn, stride_zm, stride_zn, BLOCK_M, BLOCK_N, BLOCK_K, GROUP_SIZE_M, out_dtype, USE_TMA_STORE, ADD_MATRIX, ADD_ROWS, ADD_COLS, DO_SOFTMAX, CHAIN_DOT, A_ORDER_0, A_ORDER_1, B_ORDER_0, B_ORDER_1, W_ORDER_0, W_ORDER_1, Z_ORDER_0, Z_ORDER_1) without return types