Skip to content

Reductions: column-wise, whole-tile, and a generic reduce #6

Closed

Description

@feitreim

ThunderKittens has, on register and shared tiles: row_max row_min row_sum row_prod row_reduce, the col_* mirrors, and whole-tile max min sum prod, plus generic row_reduce / col_reduce taking an op.

What we have. quad_max and quad_sum on RegVec / RegTile — row-wise max and sum only, via quad shuffle — plus online_rescale and scale_rows for the flash softmax pattern.

Missing: every column-wise reduction, prod, min, generic row_reduce / col_reduce, whole-tile reductions, and all shared-tile reductions.

The hard part is columns. The fragment map replicates a row's statistic across the 4 lanes of a quad, which is exactly what makes quad_max / quad_sum cheap. A column reduction has the opposite access pattern: values for one logical column are spread across lanes at stride 4 and across the two row blocks a thread owns. It needs a different shuffle (butterfly across the quad's stride-4 neighbours, then across row blocks), not a reparameterization of the existing one. Worth writing once as a generic col_reduce and deriving col_max / col_sum / col_min / col_prod from it.

Depends on #1 for coordinates, #5 for the op traits, #4 to check the shuffle patterns against a reference.

Activity

  1. added
    enhancement
    area:compute
    on Jul 26, 2026
  2. feitreim commented on Jul 27, 2026

    @feitreim
    OwnerAuthor

    Acceptance: update examples/ as part of closing this.

    softmax and layernorm want row_max/row_sum/col_sum and a whole-tile sum; flash_forward wants the row forms. Note the examples' observation that quad_max/quad_sum are only the second half of a row reduction — the fold across a thread's own VALUES registers is open-coded in every kernel today.

    The examples crate (#18) exists so that "done" is checkable in the terms a kernel author cares about, rather than as a claim about a primitive nobody has tried to hold. Concretely, on closing this:

    • Delete any workaround or GAP fence in examples/src/ that this issue removes the need for, and replace it with the real API.
    • If a kernel becomes fully unblocked, move it from aspirational to compiles: flip its header, take it out of its feature gate, and confirm modal run modal_app.py::build builds it for sm_100a.
    • Update the status table and the blocked-on lists in examples/README.md.

    If the example still does not compile afterwards, that is a finding worth writing down — say what is still missing rather than leaving the README stale.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:computeenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions