Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:InternLM Lmdeploy Gemm TiledMma

From Leeroopedia
Revision as of 15:14, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/InternLM_Lmdeploy_Gemm_TiledMma.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains GPU_Kernels, GEMM
Last Updated 2026-02-07 15:00 GMT

Overview

Wraps MMA atom operations and thread group maps into a unified Tiled_MMA_v2 abstraction that tiles MMA operations across a CTA's output matrix dimensions.

Description

Tiled_MMA_v2 composes an MMA_Atom (the hardware MMA instruction abstraction) with an MMA_Map (the warp-to-tile mapping) to define the complete tiled MMA computation:

  • Atom: The primitive MMA instruction (e.g., 16x8x16 for HMMA, 8x8x4 for Volta, or SIMT)
  • Map: How warp groups are assigned to sub-tiles of the CTA output
  • Iteration: kMmaIterM x kMmaIterN x kMmaIterK total MMA iterations per warp
  • Thread count: kGroupCount * Atom::kThreadCount threads total

The mma_k_iter method performs one K-iteration of MMA across all M and N tiles, with an optimization for column-major order that alternates M traversal direction on even/odd N iterations to improve register reuse.

Also provides Tiled_MMA_v3 and related helpers for shared memory copy integration.

Usage

Used by the GEMM mainloop implementations to execute the core tiled MMA computation.

Code Reference

Source Location

Signature

template<class MMA_Atom_, class MMA_Map_, Order order_ = kColMajor>
struct Tiled_MMA_v2 {
    using Atom = MMA_Atom_;
    using Map  = MMA_Map_;

    static constexpr int kMmaIterM, kMmaIterN, kMmaIterK;
    static constexpr int kThreadCount;

    __device__ static int3 get_offset(int thread_idx);

    template<class FragD, class FragA, class FragB, class FragC>
    __device__ static void mma_k_iter(FragD& frag_D, const FragA& frag_A,
                                       const FragB& frag_B, const FragC& frag_C);
};

Import

#include "src/turbomind/kernels/gemm/tiled_mma.h"

I/O Contract

Inputs

Name Type Required Description
frag_A register array Yes A operand fragments loaded from shared memory
frag_B register array Yes B operand fragments loaded from shared memory
frag_C register array Yes Accumulator input (for FMA: D = A*B + C)

Outputs

Name Type Description
frag_D register array MMA result accumulator

Usage Examples

using MMA = Tiled_MMA_v2<MMA_Atom_16816, MMA_Map, kColMajor>;
MMA::mma_k_iter(frag_D, frag_A, frag_B, frag_C);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment