Skip to main content

muon_ns_step

Function muon_ns_step 

Source
pub fn muon_ns_step<T: Triton, const TRANSPOSE: bool, const BLOCK_M: i32, const BLOCK_N: i32, const BLOCK_K: i32, const GROUP_M: i32>(
    t_ptr: T::Pointer<f32>,
    x_ptr: T::Pointer<f32>,
    M: i32,
    N: i32,
    stride_tm: i32,
    stride_xm: i32,
    a: f32,
    b: f32,
)
Expand description

One Newton-Schulz step (in-place): X ← a·X + b·(T·X) or X ← a·X + b·(X·T).

Both cases are expressed as A @ B (no explicit transpose on B) with unit inner strides so TMA descriptors remain valid:

  • !TRANSPOSE (T·X): A = T [M, K], B = X [K, N], K = M.
  • TRANSPOSE (X·T): A = X [M, K], B = T [K, N], K = N.

The GEMM result is fused with the elementwise update in one store.

  • stride_tm: row stride of T (= M for !TRANSPOSE, = N for TRANSPOSE).
  • stride_xm = N (row-major X, always [M, N]).

Grid: [ceil(M/BLOCK_M) × ceil(N/BLOCK_N) grouped by GROUP_M, 1, 1].