Skip to content

[cutedsl] Seed 16-byte feature vectors for 32-bit resident rows - #4820

Merged
choijon5 merged 1 commit into
mainfrom
choijon5/cute-norm-bwd/10
Nov 29, 2026
Merged

choijon5 merged 1 commit into
mainfrom
choijon5/cute-norm-bwd/10

Conversation

@choijon5

@choijon5 choijon5 commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Stacked PRs:


[cutedsl] Seed 16-byte feature vectors for 32-bit resident rows

For the norm backward kernels (layer_norm_bwd in examples/layer_norm.py and
rms_norm_bwd in examples/rms_norm.py, which TritonBench runs as
layer_norm-bwd and rms_norm-bwd): part of their hillclimb on the CuTe
backend.

Kernels: resident reduction kernels whose rows are 32-bit:
examples/layer_norm.py::layer_norm_bwd and
examples/rms_norm.py::rms_norm_bwd with fp32 inputs. TritonBench on a B200,
one cold full autotune per input, the time the search measured for its
winner, origin/main (f615a9b) -> this commit:

  • layer_norm-bwd (4096, 4096): 56.9 us -> 49.8 us
  • layer_norm-bwd (4096, 1024): 24.8 us -> 24.7 us
  • rms_norm-bwd (2048, 1024), (2048, 2048), (2048, 4096) and (2048,
    16384): 14.8, 19.5, 30.0 and 93.2 us -> 14.6, 19.1, 29.6 and 93.2 us
  • rms_norm-bwd (2048, 32768): a search ends in one of two kinds of layout
    at either commit. origin/main, four searches (the nightly's search seed
    at f615a9b, seeds 1 and 2, and the nightly's seed again at 57009cb):
    365.4, 321.6, 324.6 and 807.4 us. This commit, three searches (the
    nightly's seed, then seeds 1 and 2): 809.4, 242.8 and 802.5 us. The next
    commit seeds a layout that reloads this row, and its search ends at
    201.8 us

Regression check for attention, which was hillclimbed before this stack:
the 12 pull requests of this stack together (#4811 to #4822) against plain
main (74ac871), on a B200.

  • Generated code, rendered on CPU for the B200 target: all 1,298 configs
    that main renders for 145 attention cases generate the same source with
    the stack, and no seed list changes. The cases are the kernels of
    examples/attention.py (forward and backward), flex_attention.py,
    blackwell_attention.py and fp8_attention.py, and of
    benchmarks/cute/attnbwd_kernels.py and attngym_kernels.py; the configs
    are each case's default and every compiler seed.
  • The same with the attention stack ([testing] Time the long-kernel probe test against the traced call itself #4797 to [cutedsl] Run the plain causal flash pair in the persistent work-item loop #4810) under both sides: 759
    forward and 626 backward and attention-gym configs (defaults, seeds,
    pinned configs), 7,493 more configs that the search reaches on 12
    forward cases (one knob changed at a time, random draws) and 3,861 with
    random draws on the backward and attention-gym kernels generate the same
    source with and without this stack, and the 11 kernels compiled on the
    GPU (the eight forward shapes below and three fp8 attention inputs) have
    the same MLIR bytecode.
  • Time: the eight forward shapes of examples/attention.py (dense and
    causal, B2 H32 S1024 D64 fp16 to B8 H32 S8192 D128 bf16) at pinned
    configs, with and without this stack, interleaved, a new process for
    every reading, 4 to 8 rounds a shape. The best readings with the stack
    are 0.994 to 1.007 times those without. On this power-capped GPU every
    implementation, cuDNN SDPA included, reads one of two levels 3 to 5%
    apart from process to process; both sides read the same two levels.

The five other inputs up to 16384 features end where they did, within 0.4
us: the vector width is a knob, which the search moves from the 8-wide
seeds by itself. Pinned, the seeds take 21% to 29% less kernel time 4-wide
than 8-wide (4096 rows of layer_norm_bwd): 13.9 -> 9.9 us at 1024
features, 25.6 -> 20.1 us at 2048, 45.5 -> 34.3 us at 4096 and 88.0 ->
64.9 us at 8192. Kernels with 16-bit rows keep their seeds.

At 32768 features of rms_norm_bwd no seed holds the row in its threads'
registers, at origin/main or here: the search starts from seeds that spill
(the 256-thread one runs 2267 us) and ends where its random path takes it:
in a layout of 240 to 365 us, or in one of about 805 us, which is where
one of origin/main's four searches and two of this commit's three ended.
The twin that this commit adds at that width spills as well. The layout
that origin/main's first search found renders the same kernel at this
commit and runs 365 us pinned, as the search times it (the call with its
host sum; the kernel alone takes 319.6 us of it). The commit above seeds a
reloading layout for this row (195.7 us of kernel time), which a search
cannot end behind, so the two are best landed together.

The resident seed lattice's 256- and 512-thread entries and the vector rows
carry 8-wide feature vectors: 16 bytes of a 16-bit row, which is one async
copy or one vector load. Of a 32-bit row 16 bytes are 4 features, and an
8-wide vector is two copies. The 4-wide layout took 21% to 29% less time on
fp32 rows (B200, examples/layer_norm.py::layer_norm_bwd, 4096 rows, staged,
kernel time in us):

features threads row group 8-wide 4-wide
1024 128 4 13.9 9.9
2048 256 2 25.6 20.1
4096 256 2 45.5 34.3
4096 512 2 47.4 35.7
8192 256 1 88.0 64.9
8192 512 1 86.0 65.1

For a kernel whose rows are all 32-bit (_packet_vector: the features in 16
bytes of the tensors the kernel loads whose last dim is the row's length),
the family repeats its 8-wide entries 4-wide. The twins follow the
existing seeds, which keep their rank, and a layout the list already holds
is not repeated. A kernel of 16-bit rows keeps its seeds, and so does one
whose rows' element sizes differ or are unknown.

A 32-bit row is twice the bytes of a 16-bit one, so a staged twin takes the
largest row group, of its entry's halved down to one, whose two slots the
shared memory holds (_staged_rows), and no staged twin is seeded when not
even one row's slots fit. Of 4096 fp32 features the stage holds seven
rows: the four-row group of 512 threads becomes two. Of 8192 it holds
three: every staged twin is one row. Those are the layouts of the table,
which all render. Of 16384 features the twins are the unstaged ones.

Compatibility: CuTe only, autotuner seeds only. The compiler seed list of
a resident reduction kernel with 32-bit rows grows, and with it the
fingerprint of its autotune cache entry changes.

Tests (test/test_cute_resident_packet_seeds.py, new, CPU): the packet of
fp32, bf16 and fp16 rows; for fp32 rows of 1024, 2048, 4096, 8192 and 16384
features the seeds are the previous ones followed by the listed 4-wide
twins, in order; at 8192 features the one-row staged twin renders, and its
two-row form, which the lowering refuses, renders with the shared memory
doubled; a bf16 row's seeds are unchanged. The module holds no GPU test,
so test/shard_durations.json has no entry for it.

Testing: B200, CUDA 13.2, torch 2.15.0+cu132, on origin/main 74ac871. At
this commit: scripts/run_tests.py --backend cute --lane cpu, 27386 passed,
684 skipped, 1 failed
(test/test_cute_fragment_assertion.py::test_assertions_in_binary_cross_entropy_decomposition,
which needs the nightly's decomposition: it fails on torch 2.15.0 at
origin/main as well); the new module and the four resident row modules
beside it (test_cute_resident_row_widths.py,
test_cute_resident_reductions.py, test_cute_resident_reduction_runtime.py,
test_cute_resident_reductions_codegen.py) on both lanes with GPU 4, GPU lane
10 passed, CPU lane 1304 passed. The commit changes seeds only; the tests
that read them on a device ran at the tip of the stack, which holds this
commit: scripts/run_tests.py --backend cute --gpus 4,5,6,7, GPU lane 16010
passed, 2374 skipped; CPU lane 27408 passed, 684 skipped and the same 1
failed. The cold autotunes of the lead: origin/main at f615a9b and at
57009cb (seeds 1 and 2, and the nightly's seed again for the widest
rms_norm-bwd input), this commit on each; #4763 to #4767, which landed in
between and since, leave the seeds and the code of these kernels as they
were (at the tip of the stack, the compiler seeds, the default config and 40
random configs of each of the 15 TritonBench inputs (1023 configs) render
the same code, or are refused alike, before and after the rebase onto #4766
and the one onto #4767). The lanes ran before the last review of the stack's
bottom commit changed two of that commit's tests
(test_cute_smem_footprint.py, test_cute_resident_reductions_codegen.py); the
two modules ran again at this commit, 63 passed. ./lint.sh check passes.

autoreview passed: claude, codex

For the norm backward kernels (layer_norm_bwd in examples/layer_norm.py and
rms_norm_bwd in examples/rms_norm.py, which TritonBench runs as
layer_norm-bwd and rms_norm-bwd): part of their hillclimb on the CuTe
backend.

Kernels: resident reduction kernels whose rows are 32-bit:
examples/layer_norm.py::layer_norm_bwd and
examples/rms_norm.py::rms_norm_bwd with fp32 inputs. TritonBench on a B200,
one cold full autotune per input, the time the search measured for its
winner, origin/main (f615a9b) -> this commit:
- layer_norm-bwd (4096, 4096): 56.9 us -> 49.8 us
- layer_norm-bwd (4096, 1024): 24.8 us -> 24.7 us
- rms_norm-bwd (2048, 1024), (2048, 2048), (2048, 4096) and (2048,
  16384): 14.8, 19.5, 30.0 and 93.2 us -> 14.6, 19.1, 29.6 and 93.2 us
- rms_norm-bwd (2048, 32768): a search ends in one of two kinds of layout
  at either commit. origin/main, four searches (the nightly's search seed
  at f615a9b, seeds 1 and 2, and the nightly's seed again at 57009cb):
  365.4, 321.6, 324.6 and 807.4 us. This commit, three searches (the
  nightly's seed, then seeds 1 and 2): 809.4, 242.8 and 802.5 us. The next
  commit seeds a layout that reloads this row, and its search ends at
  201.8 us

Regression check for attention, which was hillclimbed before this stack:
the 12 pull requests of this stack together (#4811 to #4822) against plain
main (74ac871), on a B200.
- Generated code, rendered on CPU for the B200 target: all 1,298 configs
  that main renders for 145 attention cases generate the same source with
  the stack, and no seed list changes. The cases are the kernels of
  examples/attention.py (forward and backward), flex_attention.py,
  blackwell_attention.py and fp8_attention.py, and of
  benchmarks/cute/attnbwd_kernels.py and attngym_kernels.py; the configs
  are each case's default and every compiler seed.
- The same with the attention stack (#4797 to #4810) under both sides: 759
  forward and 626 backward and attention-gym configs (defaults, seeds,
  pinned configs), 7,493 more configs that the search reaches on 12
  forward cases (one knob changed at a time, random draws) and 3,861 with
  random draws on the backward and attention-gym kernels generate the same
  source with and without this stack, and the 11 kernels compiled on the
  GPU (the eight forward shapes below and three fp8 attention inputs) have
  the same MLIR bytecode.
- Time: the eight forward shapes of examples/attention.py (dense and
  causal, B2 H32 S1024 D64 fp16 to B8 H32 S8192 D128 bf16) at pinned
  configs, with and without this stack, interleaved, a new process for
  every reading, 4 to 8 rounds a shape. The best readings with the stack
  are 0.994 to 1.007 times those without. On this power-capped GPU every
  implementation, cuDNN SDPA included, reads one of two levels 3 to 5%
  apart from process to process; both sides read the same two levels.

The five other inputs up to 16384 features end where they did, within 0.4
us: the vector width is a knob, which the search moves from the 8-wide
seeds by itself. Pinned, the seeds take 21% to 29% less kernel time 4-wide
than 8-wide (4096 rows of layer_norm_bwd): 13.9 -> 9.9 us at 1024
features, 25.6 -> 20.1 us at 2048, 45.5 -> 34.3 us at 4096 and 88.0 ->
64.9 us at 8192. Kernels with 16-bit rows keep their seeds.

At 32768 features of rms_norm_bwd no seed holds the row in its threads'
registers, at origin/main or here: the search starts from seeds that spill
(the 256-thread one runs 2267 us) and ends where its random path takes it:
in a layout of 240 to 365 us, or in one of about 805 us, which is where
one of origin/main's four searches and two of this commit's three ended.
The twin that this commit adds at that width spills as well. The layout
that origin/main's first search found renders the same kernel at this
commit and runs 365 us pinned, as the search times it (the call with its
host sum; the kernel alone takes 319.6 us of it). The commit above seeds a
reloading layout for this row (195.7 us of kernel time), which a search
cannot end behind, so the two are best landed together.

The resident seed lattice's 256- and 512-thread entries and the vector rows
carry 8-wide feature vectors: 16 bytes of a 16-bit row, which is one async
copy or one vector load.  Of a 32-bit row 16 bytes are 4 features, and an
8-wide vector is two copies.  The 4-wide layout took 21% to 29% less time on
fp32 rows (B200, examples/layer_norm.py::layer_norm_bwd, 4096 rows, staged,
kernel time in us):

  features  threads  row group  8-wide  4-wide
      1024      128          4    13.9     9.9
      2048      256          2    25.6    20.1
      4096      256          2    45.5    34.3
      4096      512          2    47.4    35.7
      8192      256          1    88.0    64.9
      8192      512          1    86.0    65.1

For a kernel whose rows are all 32-bit (`_packet_vector`: the features in 16
bytes of the tensors the kernel loads whose last dim is the row's length),
the family repeats its 8-wide entries 4-wide.  The twins follow the
existing seeds, which keep their rank, and a layout the list already holds
is not repeated.  A kernel of 16-bit rows keeps its seeds, and so does one
whose rows' element sizes differ or are unknown.

A 32-bit row is twice the bytes of a 16-bit one, so a staged twin takes the
largest row group, of its entry's halved down to one, whose two slots the
shared memory holds (`_staged_rows`), and no staged twin is seeded when not
even one row's slots fit.  Of 4096 fp32 features the stage holds seven
rows: the four-row group of 512 threads becomes two.  Of 8192 it holds
three: every staged twin is one row.  Those are the layouts of the table,
which all render.  Of 16384 features the twins are the unstaged ones.

Compatibility: CuTe only, autotuner seeds only.  The compiler seed list of
a resident reduction kernel with 32-bit rows grows, and with it the
fingerprint of its autotune cache entry changes.

Tests (test/test_cute_resident_packet_seeds.py, new, CPU): the packet of
fp32, bf16 and fp16 rows; for fp32 rows of 1024, 2048, 4096, 8192 and 16384
features the seeds are the previous ones followed by the listed 4-wide
twins, in order; at 8192 features the one-row staged twin renders, and its
two-row form, which the lowering refuses, renders with the shared memory
doubled; a bf16 row's seeds are unchanged.  The module holds no GPU test,
so `test/shard_durations.json` has no entry for it.

Testing: B200, CUDA 13.2, torch 2.15.0+cu132, on origin/main 74ac871. At
this commit: `scripts/run_tests.py --backend cute --lane cpu`, 27386 passed,
684 skipped, 1 failed
(test/test_cute_fragment_assertion.py::test_assertions_in_binary_cross_entropy_decomposition,
which needs the nightly's decomposition: it fails on torch 2.15.0 at
origin/main as well); the new module and the four resident row modules
beside it (test_cute_resident_row_widths.py,
test_cute_resident_reductions.py, test_cute_resident_reduction_runtime.py,
test_cute_resident_reductions_codegen.py) on both lanes with GPU 4, GPU lane
10 passed, CPU lane 1304 passed. The commit changes seeds only; the tests
that read them on a device ran at the tip of the stack, which holds this
commit: `scripts/run_tests.py --backend cute --gpus 4,5,6,7`, GPU lane 16010
passed, 2374 skipped; CPU lane 27408 passed, 684 skipped and the same 1
failed. The cold autotunes of the lead: origin/main at f615a9b and at
57009cb (seeds 1 and 2, and the nightly's seed again for the widest
rms_norm-bwd input), this commit on each; #4763 to #4767, which landed in
between and since, leave the seeds and the code of these kernels as they
were (at the tip of the stack, the compiler seeds, the default config and 40
random configs of each of the 15 TritonBench inputs (1023 configs) render
the same code, or are refused alike, before and after the rebase onto #4766
and the one onto #4767). The lanes ran before the last review of the stack's
bottom commit changed two of that commit's tests
(test_cute_smem_footprint.py, test_cute_resident_reductions_codegen.py); the
two modules ran again at this commit, 63 passed. `./lint.sh check` passes.

autoreview passed: claude, codex

stack-info: PR: #4820, branch: choijon5/cute-norm-bwd/10
@choijon5
choijon5 force-pushed the choijon5/cute-norm-bwd/9 branch from 8a2b6a5 to b0c11e2 Compare November 28, 2026 17:16
@choijon5
choijon5 force-pushed the choijon5/cute-norm-bwd/10 branch from 91de93c to a37572b Compare November 28, 2026 17:16
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 28, 2026
@choijon5
choijon5 marked this pull request as draft November 28, 2026 20:36
@choijon5
choijon5 changed the base branch from choijon5/cute-norm-bwd/9 to main November 28, 2026 20:37
@choijon5
choijon5 force-pushed the choijon5/cute-norm-bwd/10 branch from a37572b to c14464e Compare November 28, 2026 20:37
@choijon5
choijon5 changed the base branch from main to choijon5/cute-norm-bwd/9 November 28, 2026 20:37
@choijon5
choijon5 marked this pull request as ready for review November 28, 2026 20:38
@choijon5
choijon5 marked this pull request as draft November 29, 2026 18:14
@choijon5
choijon5 changed the base branch from choijon5/cute-norm-bwd/9 to main November 29, 2026 18:14
@choijon5
choijon5 force-pushed the choijon5/cute-norm-bwd/10 branch from c14464e to 881d769 Compare November 29, 2026 18:15
@choijon5
choijon5 changed the base branch from main to choijon5/cute-norm-bwd/9 November 29, 2026 18:15
@choijon5
choijon5 marked this pull request as ready for review November 29, 2026 18:15
@choijon5
choijon5 force-pushed the choijon5/cute-norm-bwd/9 branch from 7cd3f91 to 107f7c1 Compare November 29, 2026 20:07
@choijon5
choijon5 force-pushed the choijon5/cute-norm-bwd/10 branch from 881d769 to a215330 Compare November 29, 2026 20:07
choijon5 added a commit that referenced this pull request Nov 29, 2026
For the norm backward kernels (layer_norm_bwd in examples/layer_norm.py and
rms_norm_bwd in examples/rms_norm.py, which TritonBench runs as
layer_norm-bwd and rms_norm-bwd): part of their hillclimb on the CuTe
backend.

Kernels: resident reduction kernels whose rows are 32-bit:
examples/layer_norm.py::layer_norm_bwd and
examples/rms_norm.py::rms_norm_bwd with fp32 inputs. TritonBench on a B200,
one cold full autotune per input, the time the search measured for its
winner, origin/main (f615a9b) -> this commit:
- layer_norm-bwd (4096, 4096): 56.9 us -> 49.8 us
- layer_norm-bwd (4096, 1024): 24.8 us -> 24.7 us
- rms_norm-bwd (2048, 1024), (2048, 2048), (2048, 4096) and (2048,
  16384): 14.8, 19.5, 30.0 and 93.2 us -> 14.6, 19.1, 29.6 and 93.2 us
- rms_norm-bwd (2048, 32768): a search ends in one of two kinds of layout
  at either commit. origin/main, four searches (the nightly's search seed
  at f615a9b, seeds 1 and 2, and the nightly's seed again at 57009cb):
  365.4, 321.6, 324.6 and 807.4 us. This commit, three searches (the
  nightly's seed, then seeds 1 and 2): 809.4, 242.8 and 802.5 us. The next
  commit seeds a layout that reloads this row, and its search ends at
  201.8 us

Regression check for attention, which was hillclimbed before this stack:
the 12 pull requests of this stack together (#4811 to #4822) against plain
main (74ac871), on a B200.
- Generated code, rendered on CPU for the B200 target: all 1,298 configs
  that main renders for 145 attention cases generate the same source with
  the stack, and no seed list changes. The cases are the kernels of
  examples/attention.py (forward and backward), flex_attention.py,
  blackwell_attention.py and fp8_attention.py, and of
  benchmarks/cute/attnbwd_kernels.py and attngym_kernels.py; the configs
  are each case's default and every compiler seed.
- The same with the attention stack (#4797 to #4810) under both sides: 759
  forward and 626 backward and attention-gym configs (defaults, seeds,
  pinned configs), 7,493 more configs that the search reaches on 12
  forward cases (one knob changed at a time, random draws) and 3,861 with
  random draws on the backward and attention-gym kernels generate the same
  source with and without this stack, and the 11 kernels compiled on the
  GPU (the eight forward shapes below and three fp8 attention inputs) have
  the same MLIR bytecode.
- Time: the eight forward shapes of examples/attention.py (dense and
  causal, B2 H32 S1024 D64 fp16 to B8 H32 S8192 D128 bf16) at pinned
  configs, with and without this stack, interleaved, a new process for
  every reading, 4 to 8 rounds a shape. The best readings with the stack
  are 0.994 to 1.007 times those without. On this power-capped GPU every
  implementation, cuDNN SDPA included, reads one of two levels 3 to 5%
  apart from process to process; both sides read the same two levels.

The five other inputs up to 16384 features end where they did, within 0.4
us: the vector width is a knob, which the search moves from the 8-wide
seeds by itself. Pinned, the seeds take 21% to 29% less kernel time 4-wide
than 8-wide (4096 rows of layer_norm_bwd): 13.9 -> 9.9 us at 1024
features, 25.6 -> 20.1 us at 2048, 45.5 -> 34.3 us at 4096 and 88.0 ->
64.9 us at 8192. Kernels with 16-bit rows keep their seeds.

At 32768 features of rms_norm_bwd no seed holds the row in its threads'
registers, at origin/main or here: the search starts from seeds that spill
(the 256-thread one runs 2267 us) and ends where its random path takes it:
in a layout of 240 to 365 us, or in one of about 805 us, which is where
one of origin/main's four searches and two of this commit's three ended.
The twin that this commit adds at that width spills as well. The layout
that origin/main's first search found renders the same kernel at this
commit and runs 365 us pinned, as the search times it (the call with its
host sum; the kernel alone takes 319.6 us of it). The commit above seeds a
reloading layout for this row (195.7 us of kernel time), which a search
cannot end behind, so the two are best landed together.

The resident seed lattice's 256- and 512-thread entries and the vector rows
carry 8-wide feature vectors: 16 bytes of a 16-bit row, which is one async
copy or one vector load.  Of a 32-bit row 16 bytes are 4 features, and an
8-wide vector is two copies.  The 4-wide layout took 21% to 29% less time on
fp32 rows (B200, examples/layer_norm.py::layer_norm_bwd, 4096 rows, staged,
kernel time in us):

  features  threads  row group  8-wide  4-wide
      1024      128          4    13.9     9.9
      2048      256          2    25.6    20.1
      4096      256          2    45.5    34.3
      4096      512          2    47.4    35.7
      8192      256          1    88.0    64.9
      8192      512          1    86.0    65.1

For a kernel whose rows are all 32-bit (`_packet_vector`: the features in 16
bytes of the tensors the kernel loads whose last dim is the row's length),
the family repeats its 8-wide entries 4-wide.  The twins follow the
existing seeds, which keep their rank, and a layout the list already holds
is not repeated.  A kernel of 16-bit rows keeps its seeds, and so does one
whose rows' element sizes differ or are unknown.

A 32-bit row is twice the bytes of a 16-bit one, so a staged twin takes the
largest row group, of its entry's halved down to one, whose two slots the
shared memory holds (`_staged_rows`), and no staged twin is seeded when not
even one row's slots fit.  Of 4096 fp32 features the stage holds seven
rows: the four-row group of 512 threads becomes two.  Of 8192 it holds
three: every staged twin is one row.  Those are the layouts of the table,
which all render.  Of 16384 features the twins are the unstaged ones.

Compatibility: CuTe only, autotuner seeds only.  The compiler seed list of
a resident reduction kernel with 32-bit rows grows, and with it the
fingerprint of its autotune cache entry changes.

Tests (test/test_cute_resident_packet_seeds.py, new, CPU): the packet of
fp32, bf16 and fp16 rows; for fp32 rows of 1024, 2048, 4096, 8192 and 16384
features the seeds are the previous ones followed by the listed 4-wide
twins, in order; at 8192 features the one-row staged twin renders, and its
two-row form, which the lowering refuses, renders with the shared memory
doubled; a bf16 row's seeds are unchanged.  The module holds no GPU test,
so `test/shard_durations.json` has no entry for it.

Testing: B200, CUDA 13.2, torch 2.15.0+cu132, on origin/main 74ac871. At
this commit: `scripts/run_tests.py --backend cute --lane cpu`, 27386 passed,
684 skipped, 1 failed
(test/test_cute_fragment_assertion.py::test_assertions_in_binary_cross_entropy_decomposition,
which needs the nightly's decomposition: it fails on torch 2.15.0 at
origin/main as well); the new module and the four resident row modules
beside it (test_cute_resident_row_widths.py,
test_cute_resident_reductions.py, test_cute_resident_reduction_runtime.py,
test_cute_resident_reductions_codegen.py) on both lanes with GPU 4, GPU lane
10 passed, CPU lane 1304 passed. The commit changes seeds only; the tests
that read them on a device ran at the tip of the stack, which holds this
commit: `scripts/run_tests.py --backend cute --gpus 4,5,6,7`, GPU lane 16010
passed, 2374 skipped; CPU lane 27408 passed, 684 skipped and the same 1
failed. The cold autotunes of the lead: origin/main at f615a9b and at
57009cb (seeds 1 and 2, and the nightly's seed again for the widest
rms_norm-bwd input), this commit on each; #4763 to #4767, which landed in
between and since, leave the seeds and the code of these kernels as they
were (at the tip of the stack, the compiler seeds, the default config and 40
random configs of each of the 15 TritonBench inputs (1023 configs) render
the same code, or are refused alike, before and after the rebase onto #4766
and the one onto #4767). The lanes ran before the last review of the stack's
bottom commit changed two of that commit's tests
(test_cute_smem_footprint.py, test_cute_resident_reductions_codegen.py); the
two modules ran again at this commit, 63 passed. `./lint.sh check` passes.

autoreview passed: claude, codex

stack-info: PR: #4820, branch: choijon5/cute-norm-bwd/10
@choijon5
choijon5 force-pushed the choijon5/cute-norm-bwd/9 branch from 107f7c1 to a44123f Compare November 29, 2026 20:08
@choijon5
choijon5 force-pushed the choijon5/cute-norm-bwd/10 branch from a215330 to 317a5f8 Compare November 29, 2026 20:08
choijon5 added a commit that referenced this pull request Nov 29, 2026
For the norm backward kernels (layer_norm_bwd in examples/layer_norm.py and
rms_norm_bwd in examples/rms_norm.py, which TritonBench runs as
layer_norm-bwd and rms_norm-bwd): part of their hillclimb on the CuTe
backend.

Kernels: resident reduction kernels whose rows are 32-bit:
examples/layer_norm.py::layer_norm_bwd and
examples/rms_norm.py::rms_norm_bwd with fp32 inputs. TritonBench on a B200,
one cold full autotune per input, the time the search measured for its
winner, origin/main (f615a9b) -> this commit:
- layer_norm-bwd (4096, 4096): 56.9 us -> 49.8 us
- layer_norm-bwd (4096, 1024): 24.8 us -> 24.7 us
- rms_norm-bwd (2048, 1024), (2048, 2048), (2048, 4096) and (2048,
  16384): 14.8, 19.5, 30.0 and 93.2 us -> 14.6, 19.1, 29.6 and 93.2 us
- rms_norm-bwd (2048, 32768): a search ends in one of two kinds of layout
  at either commit. origin/main, four searches (the nightly's search seed
  at f615a9b, seeds 1 and 2, and the nightly's seed again at 57009cb):
  365.4, 321.6, 324.6 and 807.4 us. This commit, three searches (the
  nightly's seed, then seeds 1 and 2): 809.4, 242.8 and 802.5 us. The next
  commit seeds a layout that reloads this row, and its search ends at
  201.8 us

Regression check for attention, which was hillclimbed before this stack:
the 12 pull requests of this stack together (#4811 to #4822) against plain
main (74ac871), on a B200.
- Generated code, rendered on CPU for the B200 target: all 1,298 configs
  that main renders for 145 attention cases generate the same source with
  the stack, and no seed list changes. The cases are the kernels of
  examples/attention.py (forward and backward), flex_attention.py,
  blackwell_attention.py and fp8_attention.py, and of
  benchmarks/cute/attnbwd_kernels.py and attngym_kernels.py; the configs
  are each case's default and every compiler seed.
- The same with the attention stack (#4797 to #4810) under both sides: 759
  forward and 626 backward and attention-gym configs (defaults, seeds,
  pinned configs), 7,493 more configs that the search reaches on 12
  forward cases (one knob changed at a time, random draws) and 3,861 with
  random draws on the backward and attention-gym kernels generate the same
  source with and without this stack, and the 11 kernels compiled on the
  GPU (the eight forward shapes below and three fp8 attention inputs) have
  the same MLIR bytecode.
- Time: the eight forward shapes of examples/attention.py (dense and
  causal, B2 H32 S1024 D64 fp16 to B8 H32 S8192 D128 bf16) at pinned
  configs, with and without this stack, interleaved, a new process for
  every reading, 4 to 8 rounds a shape. The best readings with the stack
  are 0.994 to 1.007 times those without. On this power-capped GPU every
  implementation, cuDNN SDPA included, reads one of two levels 3 to 5%
  apart from process to process; both sides read the same two levels.

The five other inputs up to 16384 features end where they did, within 0.4
us: the vector width is a knob, which the search moves from the 8-wide
seeds by itself. Pinned, the seeds take 21% to 29% less kernel time 4-wide
than 8-wide (4096 rows of layer_norm_bwd): 13.9 -> 9.9 us at 1024
features, 25.6 -> 20.1 us at 2048, 45.5 -> 34.3 us at 4096 and 88.0 ->
64.9 us at 8192. Kernels with 16-bit rows keep their seeds.

At 32768 features of rms_norm_bwd no seed holds the row in its threads'
registers, at origin/main or here: the search starts from seeds that spill
(the 256-thread one runs 2267 us) and ends where its random path takes it:
in a layout of 240 to 365 us, or in one of about 805 us, which is where
one of origin/main's four searches and two of this commit's three ended.
The twin that this commit adds at that width spills as well. The layout
that origin/main's first search found renders the same kernel at this
commit and runs 365 us pinned, as the search times it (the call with its
host sum; the kernel alone takes 319.6 us of it). The commit above seeds a
reloading layout for this row (195.7 us of kernel time), which a search
cannot end behind, so the two are best landed together.

The resident seed lattice's 256- and 512-thread entries and the vector rows
carry 8-wide feature vectors: 16 bytes of a 16-bit row, which is one async
copy or one vector load.  Of a 32-bit row 16 bytes are 4 features, and an
8-wide vector is two copies.  The 4-wide layout took 21% to 29% less time on
fp32 rows (B200, examples/layer_norm.py::layer_norm_bwd, 4096 rows, staged,
kernel time in us):

  features  threads  row group  8-wide  4-wide
      1024      128          4    13.9     9.9
      2048      256          2    25.6    20.1
      4096      256          2    45.5    34.3
      4096      512          2    47.4    35.7
      8192      256          1    88.0    64.9
      8192      512          1    86.0    65.1

For a kernel whose rows are all 32-bit (`_packet_vector`: the features in 16
bytes of the tensors the kernel loads whose last dim is the row's length),
the family repeats its 8-wide entries 4-wide.  The twins follow the
existing seeds, which keep their rank, and a layout the list already holds
is not repeated.  A kernel of 16-bit rows keeps its seeds, and so does one
whose rows' element sizes differ or are unknown.

A 32-bit row is twice the bytes of a 16-bit one, so a staged twin takes the
largest row group, of its entry's halved down to one, whose two slots the
shared memory holds (`_staged_rows`), and no staged twin is seeded when not
even one row's slots fit.  Of 4096 fp32 features the stage holds seven
rows: the four-row group of 512 threads becomes two.  Of 8192 it holds
three: every staged twin is one row.  Those are the layouts of the table,
which all render.  Of 16384 features the twins are the unstaged ones.

Compatibility: CuTe only, autotuner seeds only.  The compiler seed list of
a resident reduction kernel with 32-bit rows grows, and with it the
fingerprint of its autotune cache entry changes.

Tests (test/test_cute_resident_packet_seeds.py, new, CPU): the packet of
fp32, bf16 and fp16 rows; for fp32 rows of 1024, 2048, 4096, 8192 and 16384
features the seeds are the previous ones followed by the listed 4-wide
twins, in order; at 8192 features the one-row staged twin renders, and its
two-row form, which the lowering refuses, renders with the shared memory
doubled; a bf16 row's seeds are unchanged.  The module holds no GPU test,
so `test/shard_durations.json` has no entry for it.

Testing: B200, CUDA 13.2, torch 2.15.0+cu132, on origin/main 74ac871. At
this commit: `scripts/run_tests.py --backend cute --lane cpu`, 27386 passed,
684 skipped, 1 failed
(test/test_cute_fragment_assertion.py::test_assertions_in_binary_cross_entropy_decomposition,
which needs the nightly's decomposition: it fails on torch 2.15.0 at
origin/main as well); the new module and the four resident row modules
beside it (test_cute_resident_row_widths.py,
test_cute_resident_reductions.py, test_cute_resident_reduction_runtime.py,
test_cute_resident_reductions_codegen.py) on both lanes with GPU 4, GPU lane
10 passed, CPU lane 1304 passed. The commit changes seeds only; the tests
that read them on a device ran at the tip of the stack, which holds this
commit: `scripts/run_tests.py --backend cute --gpus 4,5,6,7`, GPU lane 16010
passed, 2374 skipped; CPU lane 27408 passed, 684 skipped and the same 1
failed. The cold autotunes of the lead: origin/main at f615a9b and at
57009cb (seeds 1 and 2, and the nightly's seed again for the widest
rms_norm-bwd input), this commit on each; #4763 to #4767, which landed in
between and since, leave the seeds and the code of these kernels as they
were (at the tip of the stack, the compiler seeds, the default config and 40
random configs of each of the 15 TritonBench inputs (1023 configs) render
the same code, or are refused alike, before and after the rebase onto #4766
and the one onto #4767). The lanes ran before the last review of the stack's
bottom commit changed two of that commit's tests
(test_cute_smem_footprint.py, test_cute_resident_reductions_codegen.py); the
two modules ran again at this commit, 63 passed. `./lint.sh check` passes.

autoreview passed: claude, codex

stack-info: PR: #4820, branch: choijon5/cute-norm-bwd/10
@choijon5
choijon5 force-pushed the choijon5/cute-norm-bwd/9 branch from a44123f to 3c6bf20 Compare November 29, 2026 20:09
@choijon5
choijon5 force-pushed the choijon5/cute-norm-bwd/10 branch from 317a5f8 to 4225387 Compare November 29, 2026 20:09
choijon5 added a commit that referenced this pull request Nov 29, 2026
For the norm backward kernels (layer_norm_bwd in examples/layer_norm.py and
rms_norm_bwd in examples/rms_norm.py, which TritonBench runs as
layer_norm-bwd and rms_norm-bwd): part of their hillclimb on the CuTe
backend.

Kernels: resident reduction kernels whose rows are 32-bit:
examples/layer_norm.py::layer_norm_bwd and
examples/rms_norm.py::rms_norm_bwd with fp32 inputs. TritonBench on a B200,
one cold full autotune per input, the time the search measured for its
winner, origin/main (f615a9b) -> this commit:
- layer_norm-bwd (4096, 4096): 56.9 us -> 49.8 us
- layer_norm-bwd (4096, 1024): 24.8 us -> 24.7 us
- rms_norm-bwd (2048, 1024), (2048, 2048), (2048, 4096) and (2048,
  16384): 14.8, 19.5, 30.0 and 93.2 us -> 14.6, 19.1, 29.6 and 93.2 us
- rms_norm-bwd (2048, 32768): a search ends in one of two kinds of layout
  at either commit. origin/main, four searches (the nightly's search seed
  at f615a9b, seeds 1 and 2, and the nightly's seed again at 57009cb):
  365.4, 321.6, 324.6 and 807.4 us. This commit, three searches (the
  nightly's seed, then seeds 1 and 2): 809.4, 242.8 and 802.5 us. The next
  commit seeds a layout that reloads this row, and its search ends at
  201.8 us

Regression check for attention, which was hillclimbed before this stack:
the 12 pull requests of this stack together (#4811 to #4822) against plain
main (74ac871), on a B200.
- Generated code, rendered on CPU for the B200 target: all 1,298 configs
  that main renders for 145 attention cases generate the same source with
  the stack, and no seed list changes. The cases are the kernels of
  examples/attention.py (forward and backward), flex_attention.py,
  blackwell_attention.py and fp8_attention.py, and of
  benchmarks/cute/attnbwd_kernels.py and attngym_kernels.py; the configs
  are each case's default and every compiler seed.
- The same with the attention stack (#4797 to #4810) under both sides: 759
  forward and 626 backward and attention-gym configs (defaults, seeds,
  pinned configs), 7,493 more configs that the search reaches on 12
  forward cases (one knob changed at a time, random draws) and 3,861 with
  random draws on the backward and attention-gym kernels generate the same
  source with and without this stack, and the 11 kernels compiled on the
  GPU (the eight forward shapes below and three fp8 attention inputs) have
  the same MLIR bytecode.
- Time: the eight forward shapes of examples/attention.py (dense and
  causal, B2 H32 S1024 D64 fp16 to B8 H32 S8192 D128 bf16) at pinned
  configs, with and without this stack, interleaved, a new process for
  every reading, 4 to 8 rounds a shape. The best readings with the stack
  are 0.994 to 1.007 times those without. On this power-capped GPU every
  implementation, cuDNN SDPA included, reads one of two levels 3 to 5%
  apart from process to process; both sides read the same two levels.

The five other inputs up to 16384 features end where they did, within 0.4
us: the vector width is a knob, which the search moves from the 8-wide
seeds by itself. Pinned, the seeds take 21% to 29% less kernel time 4-wide
than 8-wide (4096 rows of layer_norm_bwd): 13.9 -> 9.9 us at 1024
features, 25.6 -> 20.1 us at 2048, 45.5 -> 34.3 us at 4096 and 88.0 ->
64.9 us at 8192. Kernels with 16-bit rows keep their seeds.

At 32768 features of rms_norm_bwd no seed holds the row in its threads'
registers, at origin/main or here: the search starts from seeds that spill
(the 256-thread one runs 2267 us) and ends where its random path takes it:
in a layout of 240 to 365 us, or in one of about 805 us, which is where
one of origin/main's four searches and two of this commit's three ended.
The twin that this commit adds at that width spills as well. The layout
that origin/main's first search found renders the same kernel at this
commit and runs 365 us pinned, as the search times it (the call with its
host sum; the kernel alone takes 319.6 us of it). The commit above seeds a
reloading layout for this row (195.7 us of kernel time), which a search
cannot end behind, so the two are best landed together.

The resident seed lattice's 256- and 512-thread entries and the vector rows
carry 8-wide feature vectors: 16 bytes of a 16-bit row, which is one async
copy or one vector load.  Of a 32-bit row 16 bytes are 4 features, and an
8-wide vector is two copies.  The 4-wide layout took 21% to 29% less time on
fp32 rows (B200, examples/layer_norm.py::layer_norm_bwd, 4096 rows, staged,
kernel time in us):

  features  threads  row group  8-wide  4-wide
      1024      128          4    13.9     9.9
      2048      256          2    25.6    20.1
      4096      256          2    45.5    34.3
      4096      512          2    47.4    35.7
      8192      256          1    88.0    64.9
      8192      512          1    86.0    65.1

For a kernel whose rows are all 32-bit (`_packet_vector`: the features in 16
bytes of the tensors the kernel loads whose last dim is the row's length),
the family repeats its 8-wide entries 4-wide.  The twins follow the
existing seeds, which keep their rank, and a layout the list already holds
is not repeated.  A kernel of 16-bit rows keeps its seeds, and so does one
whose rows' element sizes differ or are unknown.

A 32-bit row is twice the bytes of a 16-bit one, so a staged twin takes the
largest row group, of its entry's halved down to one, whose two slots the
shared memory holds (`_staged_rows`), and no staged twin is seeded when not
even one row's slots fit.  Of 4096 fp32 features the stage holds seven
rows: the four-row group of 512 threads becomes two.  Of 8192 it holds
three: every staged twin is one row.  Those are the layouts of the table,
which all render.  Of 16384 features the twins are the unstaged ones.

Compatibility: CuTe only, autotuner seeds only.  The compiler seed list of
a resident reduction kernel with 32-bit rows grows, and with it the
fingerprint of its autotune cache entry changes.

Tests (test/test_cute_resident_packet_seeds.py, new, CPU): the packet of
fp32, bf16 and fp16 rows; for fp32 rows of 1024, 2048, 4096, 8192 and 16384
features the seeds are the previous ones followed by the listed 4-wide
twins, in order; at 8192 features the one-row staged twin renders, and its
two-row form, which the lowering refuses, renders with the shared memory
doubled; a bf16 row's seeds are unchanged.  The module holds no GPU test,
so `test/shard_durations.json` has no entry for it.

Testing: B200, CUDA 13.2, torch 2.15.0+cu132, on origin/main 74ac871. At
this commit: `scripts/run_tests.py --backend cute --lane cpu`, 27386 passed,
684 skipped, 1 failed
(test/test_cute_fragment_assertion.py::test_assertions_in_binary_cross_entropy_decomposition,
which needs the nightly's decomposition: it fails on torch 2.15.0 at
origin/main as well); the new module and the four resident row modules
beside it (test_cute_resident_row_widths.py,
test_cute_resident_reductions.py, test_cute_resident_reduction_runtime.py,
test_cute_resident_reductions_codegen.py) on both lanes with GPU 4, GPU lane
10 passed, CPU lane 1304 passed. The commit changes seeds only; the tests
that read them on a device ran at the tip of the stack, which holds this
commit: `scripts/run_tests.py --backend cute --gpus 4,5,6,7`, GPU lane 16010
passed, 2374 skipped; CPU lane 27408 passed, 684 skipped and the same 1
failed. The cold autotunes of the lead: origin/main at f615a9b and at
57009cb (seeds 1 and 2, and the nightly's seed again for the widest
rms_norm-bwd input), this commit on each; #4763 to #4767, which landed in
between and since, leave the seeds and the code of these kernels as they
were (at the tip of the stack, the compiler seeds, the default config and 40
random configs of each of the 15 TritonBench inputs (1023 configs) render
the same code, or are refused alike, before and after the rebase onto #4766
and the one onto #4767). The lanes ran before the last review of the stack's
bottom commit changed two of that commit's tests
(test_cute_smem_footprint.py, test_cute_resident_reductions_codegen.py); the
two modules ran again at this commit, 63 passed. `./lint.sh check` passes.

autoreview passed: claude, codex

stack-info: PR: #4820, branch: choijon5/cute-norm-bwd/10
@choijon5
choijon5 force-pushed the choijon5/cute-norm-bwd/9 branch from 3c6bf20 to f93cb80 Compare November 29, 2026 20:10
@choijon5
choijon5 force-pushed the choijon5/cute-norm-bwd/10 branch from 4225387 to 0d33485 Compare November 29, 2026 20:10
choijon5 added a commit that referenced this pull request Nov 29, 2026
For the norm backward kernels (layer_norm_bwd in examples/layer_norm.py and
rms_norm_bwd in examples/rms_norm.py, which TritonBench runs as
layer_norm-bwd and rms_norm-bwd): part of their hillclimb on the CuTe
backend.

Kernels: resident reduction kernels whose rows are 32-bit:
examples/layer_norm.py::layer_norm_bwd and
examples/rms_norm.py::rms_norm_bwd with fp32 inputs. TritonBench on a B200,
one cold full autotune per input, the time the search measured for its
winner, origin/main (f615a9b) -> this commit:
- layer_norm-bwd (4096, 4096): 56.9 us -> 49.8 us
- layer_norm-bwd (4096, 1024): 24.8 us -> 24.7 us
- rms_norm-bwd (2048, 1024), (2048, 2048), (2048, 4096) and (2048,
  16384): 14.8, 19.5, 30.0 and 93.2 us -> 14.6, 19.1, 29.6 and 93.2 us
- rms_norm-bwd (2048, 32768): a search ends in one of two kinds of layout
  at either commit. origin/main, four searches (the nightly's search seed
  at f615a9b, seeds 1 and 2, and the nightly's seed again at 57009cb):
  365.4, 321.6, 324.6 and 807.4 us. This commit, three searches (the
  nightly's seed, then seeds 1 and 2): 809.4, 242.8 and 802.5 us. The next
  commit seeds a layout that reloads this row, and its search ends at
  201.8 us

Regression check for attention, which was hillclimbed before this stack:
the 12 pull requests of this stack together (#4811 to #4822) against plain
main (74ac871), on a B200.
- Generated code, rendered on CPU for the B200 target: all 1,298 configs
  that main renders for 145 attention cases generate the same source with
  the stack, and no seed list changes. The cases are the kernels of
  examples/attention.py (forward and backward), flex_attention.py,
  blackwell_attention.py and fp8_attention.py, and of
  benchmarks/cute/attnbwd_kernels.py and attngym_kernels.py; the configs
  are each case's default and every compiler seed.
- The same with the attention stack (#4797 to #4810) under both sides: 759
  forward and 626 backward and attention-gym configs (defaults, seeds,
  pinned configs), 7,493 more configs that the search reaches on 12
  forward cases (one knob changed at a time, random draws) and 3,861 with
  random draws on the backward and attention-gym kernels generate the same
  source with and without this stack, and the 11 kernels compiled on the
  GPU (the eight forward shapes below and three fp8 attention inputs) have
  the same MLIR bytecode.
- Time: the eight forward shapes of examples/attention.py (dense and
  causal, B2 H32 S1024 D64 fp16 to B8 H32 S8192 D128 bf16) at pinned
  configs, with and without this stack, interleaved, a new process for
  every reading, 4 to 8 rounds a shape. The best readings with the stack
  are 0.994 to 1.007 times those without. On this power-capped GPU every
  implementation, cuDNN SDPA included, reads one of two levels 3 to 5%
  apart from process to process; both sides read the same two levels.

The five other inputs up to 16384 features end where they did, within 0.4
us: the vector width is a knob, which the search moves from the 8-wide
seeds by itself. Pinned, the seeds take 21% to 29% less kernel time 4-wide
than 8-wide (4096 rows of layer_norm_bwd): 13.9 -> 9.9 us at 1024
features, 25.6 -> 20.1 us at 2048, 45.5 -> 34.3 us at 4096 and 88.0 ->
64.9 us at 8192. Kernels with 16-bit rows keep their seeds.

At 32768 features of rms_norm_bwd no seed holds the row in its threads'
registers, at origin/main or here: the search starts from seeds that spill
(the 256-thread one runs 2267 us) and ends where its random path takes it:
in a layout of 240 to 365 us, or in one of about 805 us, which is where
one of origin/main's four searches and two of this commit's three ended.
The twin that this commit adds at that width spills as well. The layout
that origin/main's first search found renders the same kernel at this
commit and runs 365 us pinned, as the search times it (the call with its
host sum; the kernel alone takes 319.6 us of it). The commit above seeds a
reloading layout for this row (195.7 us of kernel time), which a search
cannot end behind, so the two are best landed together.

The resident seed lattice's 256- and 512-thread entries and the vector rows
carry 8-wide feature vectors: 16 bytes of a 16-bit row, which is one async
copy or one vector load.  Of a 32-bit row 16 bytes are 4 features, and an
8-wide vector is two copies.  The 4-wide layout took 21% to 29% less time on
fp32 rows (B200, examples/layer_norm.py::layer_norm_bwd, 4096 rows, staged,
kernel time in us):

  features  threads  row group  8-wide  4-wide
      1024      128          4    13.9     9.9
      2048      256          2    25.6    20.1
      4096      256          2    45.5    34.3
      4096      512          2    47.4    35.7
      8192      256          1    88.0    64.9
      8192      512          1    86.0    65.1

For a kernel whose rows are all 32-bit (`_packet_vector`: the features in 16
bytes of the tensors the kernel loads whose last dim is the row's length),
the family repeats its 8-wide entries 4-wide.  The twins follow the
existing seeds, which keep their rank, and a layout the list already holds
is not repeated.  A kernel of 16-bit rows keeps its seeds, and so does one
whose rows' element sizes differ or are unknown.

A 32-bit row is twice the bytes of a 16-bit one, so a staged twin takes the
largest row group, of its entry's halved down to one, whose two slots the
shared memory holds (`_staged_rows`), and no staged twin is seeded when not
even one row's slots fit.  Of 4096 fp32 features the stage holds seven
rows: the four-row group of 512 threads becomes two.  Of 8192 it holds
three: every staged twin is one row.  Those are the layouts of the table,
which all render.  Of 16384 features the twins are the unstaged ones.

Compatibility: CuTe only, autotuner seeds only.  The compiler seed list of
a resident reduction kernel with 32-bit rows grows, and with it the
fingerprint of its autotune cache entry changes.

Tests (test/test_cute_resident_packet_seeds.py, new, CPU): the packet of
fp32, bf16 and fp16 rows; for fp32 rows of 1024, 2048, 4096, 8192 and 16384
features the seeds are the previous ones followed by the listed 4-wide
twins, in order; at 8192 features the one-row staged twin renders, and its
two-row form, which the lowering refuses, renders with the shared memory
doubled; a bf16 row's seeds are unchanged.  The module holds no GPU test,
so `test/shard_durations.json` has no entry for it.

Testing: B200, CUDA 13.2, torch 2.15.0+cu132, on origin/main 74ac871. At
this commit: `scripts/run_tests.py --backend cute --lane cpu`, 27386 passed,
684 skipped, 1 failed
(test/test_cute_fragment_assertion.py::test_assertions_in_binary_cross_entropy_decomposition,
which needs the nightly's decomposition: it fails on torch 2.15.0 at
origin/main as well); the new module and the four resident row modules
beside it (test_cute_resident_row_widths.py,
test_cute_resident_reductions.py, test_cute_resident_reduction_runtime.py,
test_cute_resident_reductions_codegen.py) on both lanes with GPU 4, GPU lane
10 passed, CPU lane 1304 passed. The commit changes seeds only; the tests
that read them on a device ran at the tip of the stack, which holds this
commit: `scripts/run_tests.py --backend cute --gpus 4,5,6,7`, GPU lane 16010
passed, 2374 skipped; CPU lane 27408 passed, 684 skipped and the same 1
failed. The cold autotunes of the lead: origin/main at f615a9b and at
57009cb (seeds 1 and 2, and the nightly's seed again for the widest
rms_norm-bwd input), this commit on each; #4763 to #4767, which landed in
between and since, leave the seeds and the code of these kernels as they
were (at the tip of the stack, the compiler seeds, the default config and 40
random configs of each of the 15 TritonBench inputs (1023 configs) render
the same code, or are refused alike, before and after the rebase onto #4766
and the one onto #4767). The lanes ran before the last review of the stack's
bottom commit changed two of that commit's tests
(test_cute_smem_footprint.py, test_cute_resident_reductions_codegen.py); the
two modules ran again at this commit, 63 passed. `./lint.sh check` passes.

autoreview passed: claude, codex

stack-info: PR: #4820, branch: choijon5/cute-norm-bwd/10
@choijon5
choijon5 force-pushed the choijon5/cute-norm-bwd/9 branch from f93cb80 to 5624eeb Compare November 29, 2026 20:11
@choijon5
choijon5 force-pushed the choijon5/cute-norm-bwd/10 branch from 0d33485 to 766bbda Compare November 29, 2026 20:11
choijon5 added a commit that referenced this pull request Nov 29, 2026
For the norm backward kernels (layer_norm_bwd in examples/layer_norm.py and
rms_norm_bwd in examples/rms_norm.py, which TritonBench runs as
layer_norm-bwd and rms_norm-bwd): part of their hillclimb on the CuTe
backend.

Kernels: resident reduction kernels whose rows are 32-bit:
examples/layer_norm.py::layer_norm_bwd and
examples/rms_norm.py::rms_norm_bwd with fp32 inputs. TritonBench on a B200,
one cold full autotune per input, the time the search measured for its
winner, origin/main (f615a9b) -> this commit:
- layer_norm-bwd (4096, 4096): 56.9 us -> 49.8 us
- layer_norm-bwd (4096, 1024): 24.8 us -> 24.7 us
- rms_norm-bwd (2048, 1024), (2048, 2048), (2048, 4096) and (2048,
  16384): 14.8, 19.5, 30.0 and 93.2 us -> 14.6, 19.1, 29.6 and 93.2 us
- rms_norm-bwd (2048, 32768): a search ends in one of two kinds of layout
  at either commit. origin/main, four searches (the nightly's search seed
  at f615a9b, seeds 1 and 2, and the nightly's seed again at 57009cb):
  365.4, 321.6, 324.6 and 807.4 us. This commit, three searches (the
  nightly's seed, then seeds 1 and 2): 809.4, 242.8 and 802.5 us. The next
  commit seeds a layout that reloads this row, and its search ends at
  201.8 us

Regression check for attention, which was hillclimbed before this stack:
the 12 pull requests of this stack together (#4811 to #4822) against plain
main (74ac871), on a B200.
- Generated code, rendered on CPU for the B200 target: all 1,298 configs
  that main renders for 145 attention cases generate the same source with
  the stack, and no seed list changes. The cases are the kernels of
  examples/attention.py (forward and backward), flex_attention.py,
  blackwell_attention.py and fp8_attention.py, and of
  benchmarks/cute/attnbwd_kernels.py and attngym_kernels.py; the configs
  are each case's default and every compiler seed.
- The same with the attention stack (#4797 to #4810) under both sides: 759
  forward and 626 backward and attention-gym configs (defaults, seeds,
  pinned configs), 7,493 more configs that the search reaches on 12
  forward cases (one knob changed at a time, random draws) and 3,861 with
  random draws on the backward and attention-gym kernels generate the same
  source with and without this stack, and the 11 kernels compiled on the
  GPU (the eight forward shapes below and three fp8 attention inputs) have
  the same MLIR bytecode.
- Time: the eight forward shapes of examples/attention.py (dense and
  causal, B2 H32 S1024 D64 fp16 to B8 H32 S8192 D128 bf16) at pinned
  configs, with and without this stack, interleaved, a new process for
  every reading, 4 to 8 rounds a shape. The best readings with the stack
  are 0.994 to 1.007 times those without. On this power-capped GPU every
  implementation, cuDNN SDPA included, reads one of two levels 3 to 5%
  apart from process to process; both sides read the same two levels.

The five other inputs up to 16384 features end where they did, within 0.4
us: the vector width is a knob, which the search moves from the 8-wide
seeds by itself. Pinned, the seeds take 21% to 29% less kernel time 4-wide
than 8-wide (4096 rows of layer_norm_bwd): 13.9 -> 9.9 us at 1024
features, 25.6 -> 20.1 us at 2048, 45.5 -> 34.3 us at 4096 and 88.0 ->
64.9 us at 8192. Kernels with 16-bit rows keep their seeds.

At 32768 features of rms_norm_bwd no seed holds the row in its threads'
registers, at origin/main or here: the search starts from seeds that spill
(the 256-thread one runs 2267 us) and ends where its random path takes it:
in a layout of 240 to 365 us, or in one of about 805 us, which is where
one of origin/main's four searches and two of this commit's three ended.
The twin that this commit adds at that width spills as well. The layout
that origin/main's first search found renders the same kernel at this
commit and runs 365 us pinned, as the search times it (the call with its
host sum; the kernel alone takes 319.6 us of it). The commit above seeds a
reloading layout for this row (195.7 us of kernel time), which a search
cannot end behind, so the two are best landed together.

The resident seed lattice's 256- and 512-thread entries and the vector rows
carry 8-wide feature vectors: 16 bytes of a 16-bit row, which is one async
copy or one vector load.  Of a 32-bit row 16 bytes are 4 features, and an
8-wide vector is two copies.  The 4-wide layout took 21% to 29% less time on
fp32 rows (B200, examples/layer_norm.py::layer_norm_bwd, 4096 rows, staged,
kernel time in us):

  features  threads  row group  8-wide  4-wide
      1024      128          4    13.9     9.9
      2048      256          2    25.6    20.1
      4096      256          2    45.5    34.3
      4096      512          2    47.4    35.7
      8192      256          1    88.0    64.9
      8192      512          1    86.0    65.1

For a kernel whose rows are all 32-bit (`_packet_vector`: the features in 16
bytes of the tensors the kernel loads whose last dim is the row's length),
the family repeats its 8-wide entries 4-wide.  The twins follow the
existing seeds, which keep their rank, and a layout the list already holds
is not repeated.  A kernel of 16-bit rows keeps its seeds, and so does one
whose rows' element sizes differ or are unknown.

A 32-bit row is twice the bytes of a 16-bit one, so a staged twin takes the
largest row group, of its entry's halved down to one, whose two slots the
shared memory holds (`_staged_rows`), and no staged twin is seeded when not
even one row's slots fit.  Of 4096 fp32 features the stage holds seven
rows: the four-row group of 512 threads becomes two.  Of 8192 it holds
three: every staged twin is one row.  Those are the layouts of the table,
which all render.  Of 16384 features the twins are the unstaged ones.

Compatibility: CuTe only, autotuner seeds only.  The compiler seed list of
a resident reduction kernel with 32-bit rows grows, and with it the
fingerprint of its autotune cache entry changes.

Tests (test/test_cute_resident_packet_seeds.py, new, CPU): the packet of
fp32, bf16 and fp16 rows; for fp32 rows of 1024, 2048, 4096, 8192 and 16384
features the seeds are the previous ones followed by the listed 4-wide
twins, in order; at 8192 features the one-row staged twin renders, and its
two-row form, which the lowering refuses, renders with the shared memory
doubled; a bf16 row's seeds are unchanged.  The module holds no GPU test,
so `test/shard_durations.json` has no entry for it.

Testing: B200, CUDA 13.2, torch 2.15.0+cu132, on origin/main 74ac871. At
this commit: `scripts/run_tests.py --backend cute --lane cpu`, 27386 passed,
684 skipped, 1 failed
(test/test_cute_fragment_assertion.py::test_assertions_in_binary_cross_entropy_decomposition,
which needs the nightly's decomposition: it fails on torch 2.15.0 at
origin/main as well); the new module and the four resident row modules
beside it (test_cute_resident_row_widths.py,
test_cute_resident_reductions.py, test_cute_resident_reduction_runtime.py,
test_cute_resident_reductions_codegen.py) on both lanes with GPU 4, GPU lane
10 passed, CPU lane 1304 passed. The commit changes seeds only; the tests
that read them on a device ran at the tip of the stack, which holds this
commit: `scripts/run_tests.py --backend cute --gpus 4,5,6,7`, GPU lane 16010
passed, 2374 skipped; CPU lane 27408 passed, 684 skipped and the same 1
failed. The cold autotunes of the lead: origin/main at f615a9b and at
57009cb (seeds 1 and 2, and the nightly's seed again for the widest
rms_norm-bwd input), this commit on each; #4763 to #4767, which landed in
between and since, leave the seeds and the code of these kernels as they
were (at the tip of the stack, the compiler seeds, the default config and 40
random configs of each of the 15 TritonBench inputs (1023 configs) render
the same code, or are refused alike, before and after the rebase onto #4766
and the one onto #4767). The lanes ran before the last review of the stack's
bottom commit changed two of that commit's tests
(test_cute_smem_footprint.py, test_cute_resident_reductions_codegen.py); the
two modules ran again at this commit, 63 passed. `./lint.sh check` passes.

autoreview passed: claude, codex

stack-info: PR: #4820, branch: choijon5/cute-norm-bwd/10
@choijon5
choijon5 force-pushed the choijon5/cute-norm-bwd/9 branch from 5624eeb to 72e201c Compare November 29, 2026 20:12
@choijon5
choijon5 force-pushed the choijon5/cute-norm-bwd/10 branch from 766bbda to 161c1b9 Compare November 29, 2026 20:12
choijon5 added a commit that referenced this pull request Nov 29, 2026
For the norm backward kernels (layer_norm_bwd in examples/layer_norm.py and
rms_norm_bwd in examples/rms_norm.py, which TritonBench runs as
layer_norm-bwd and rms_norm-bwd): part of their hillclimb on the CuTe
backend.

Kernels: resident reduction kernels whose rows are 32-bit:
examples/layer_norm.py::layer_norm_bwd and
examples/rms_norm.py::rms_norm_bwd with fp32 inputs. TritonBench on a B200,
one cold full autotune per input, the time the search measured for its
winner, origin/main (f615a9b) -> this commit:
- layer_norm-bwd (4096, 4096): 56.9 us -> 49.8 us
- layer_norm-bwd (4096, 1024): 24.8 us -> 24.7 us
- rms_norm-bwd (2048, 1024), (2048, 2048), (2048, 4096) and (2048,
  16384): 14.8, 19.5, 30.0 and 93.2 us -> 14.6, 19.1, 29.6 and 93.2 us
- rms_norm-bwd (2048, 32768): a search ends in one of two kinds of layout
  at either commit. origin/main, four searches (the nightly's search seed
  at f615a9b, seeds 1 and 2, and the nightly's seed again at 57009cb):
  365.4, 321.6, 324.6 and 807.4 us. This commit, three searches (the
  nightly's seed, then seeds 1 and 2): 809.4, 242.8 and 802.5 us. The next
  commit seeds a layout that reloads this row, and its search ends at
  201.8 us

Regression check for attention, which was hillclimbed before this stack:
the 12 pull requests of this stack together (#4811 to #4822) against plain
main (74ac871), on a B200.
- Generated code, rendered on CPU for the B200 target: all 1,298 configs
  that main renders for 145 attention cases generate the same source with
  the stack, and no seed list changes. The cases are the kernels of
  examples/attention.py (forward and backward), flex_attention.py,
  blackwell_attention.py and fp8_attention.py, and of
  benchmarks/cute/attnbwd_kernels.py and attngym_kernels.py; the configs
  are each case's default and every compiler seed.
- The same with the attention stack (#4797 to #4810) under both sides: 759
  forward and 626 backward and attention-gym configs (defaults, seeds,
  pinned configs), 7,493 more configs that the search reaches on 12
  forward cases (one knob changed at a time, random draws) and 3,861 with
  random draws on the backward and attention-gym kernels generate the same
  source with and without this stack, and the 11 kernels compiled on the
  GPU (the eight forward shapes below and three fp8 attention inputs) have
  the same MLIR bytecode.
- Time: the eight forward shapes of examples/attention.py (dense and
  causal, B2 H32 S1024 D64 fp16 to B8 H32 S8192 D128 bf16) at pinned
  configs, with and without this stack, interleaved, a new process for
  every reading, 4 to 8 rounds a shape. The best readings with the stack
  are 0.994 to 1.007 times those without. On this power-capped GPU every
  implementation, cuDNN SDPA included, reads one of two levels 3 to 5%
  apart from process to process; both sides read the same two levels.

The five other inputs up to 16384 features end where they did, within 0.4
us: the vector width is a knob, which the search moves from the 8-wide
seeds by itself. Pinned, the seeds take 21% to 29% less kernel time 4-wide
than 8-wide (4096 rows of layer_norm_bwd): 13.9 -> 9.9 us at 1024
features, 25.6 -> 20.1 us at 2048, 45.5 -> 34.3 us at 4096 and 88.0 ->
64.9 us at 8192. Kernels with 16-bit rows keep their seeds.

At 32768 features of rms_norm_bwd no seed holds the row in its threads'
registers, at origin/main or here: the search starts from seeds that spill
(the 256-thread one runs 2267 us) and ends where its random path takes it:
in a layout of 240 to 365 us, or in one of about 805 us, which is where
one of origin/main's four searches and two of this commit's three ended.
The twin that this commit adds at that width spills as well. The layout
that origin/main's first search found renders the same kernel at this
commit and runs 365 us pinned, as the search times it (the call with its
host sum; the kernel alone takes 319.6 us of it). The commit above seeds a
reloading layout for this row (195.7 us of kernel time), which a search
cannot end behind, so the two are best landed together.

The resident seed lattice's 256- and 512-thread entries and the vector rows
carry 8-wide feature vectors: 16 bytes of a 16-bit row, which is one async
copy or one vector load.  Of a 32-bit row 16 bytes are 4 features, and an
8-wide vector is two copies.  The 4-wide layout took 21% to 29% less time on
fp32 rows (B200, examples/layer_norm.py::layer_norm_bwd, 4096 rows, staged,
kernel time in us):

  features  threads  row group  8-wide  4-wide
      1024      128          4    13.9     9.9
      2048      256          2    25.6    20.1
      4096      256          2    45.5    34.3
      4096      512          2    47.4    35.7
      8192      256          1    88.0    64.9
      8192      512          1    86.0    65.1

For a kernel whose rows are all 32-bit (`_packet_vector`: the features in 16
bytes of the tensors the kernel loads whose last dim is the row's length),
the family repeats its 8-wide entries 4-wide.  The twins follow the
existing seeds, which keep their rank, and a layout the list already holds
is not repeated.  A kernel of 16-bit rows keeps its seeds, and so does one
whose rows' element sizes differ or are unknown.

A 32-bit row is twice the bytes of a 16-bit one, so a staged twin takes the
largest row group, of its entry's halved down to one, whose two slots the
shared memory holds (`_staged_rows`), and no staged twin is seeded when not
even one row's slots fit.  Of 4096 fp32 features the stage holds seven
rows: the four-row group of 512 threads becomes two.  Of 8192 it holds
three: every staged twin is one row.  Those are the layouts of the table,
which all render.  Of 16384 features the twins are the unstaged ones.

Compatibility: CuTe only, autotuner seeds only.  The compiler seed list of
a resident reduction kernel with 32-bit rows grows, and with it the
fingerprint of its autotune cache entry changes.

Tests (test/test_cute_resident_packet_seeds.py, new, CPU): the packet of
fp32, bf16 and fp16 rows; for fp32 rows of 1024, 2048, 4096, 8192 and 16384
features the seeds are the previous ones followed by the listed 4-wide
twins, in order; at 8192 features the one-row staged twin renders, and its
two-row form, which the lowering refuses, renders with the shared memory
doubled; a bf16 row's seeds are unchanged.  The module holds no GPU test,
so `test/shard_durations.json` has no entry for it.

Testing: B200, CUDA 13.2, torch 2.15.0+cu132, on origin/main 74ac871. At
this commit: `scripts/run_tests.py --backend cute --lane cpu`, 27386 passed,
684 skipped, 1 failed
(test/test_cute_fragment_assertion.py::test_assertions_in_binary_cross_entropy_decomposition,
which needs the nightly's decomposition: it fails on torch 2.15.0 at
origin/main as well); the new module and the four resident row modules
beside it (test_cute_resident_row_widths.py,
test_cute_resident_reductions.py, test_cute_resident_reduction_runtime.py,
test_cute_resident_reductions_codegen.py) on both lanes with GPU 4, GPU lane
10 passed, CPU lane 1304 passed. The commit changes seeds only; the tests
that read them on a device ran at the tip of the stack, which holds this
commit: `scripts/run_tests.py --backend cute --gpus 4,5,6,7`, GPU lane 16010
passed, 2374 skipped; CPU lane 27408 passed, 684 skipped and the same 1
failed. The cold autotunes of the lead: origin/main at f615a9b and at
57009cb (seeds 1 and 2, and the nightly's seed again for the widest
rms_norm-bwd input), this commit on each; #4763 to #4767, which landed in
between and since, leave the seeds and the code of these kernels as they
were (at the tip of the stack, the compiler seeds, the default config and 40
random configs of each of the 15 TritonBench inputs (1023 configs) render
the same code, or are refused alike, before and after the rebase onto #4766
and the one onto #4767). The lanes ran before the last review of the stack's
bottom commit changed two of that commit's tests
(test_cute_smem_footprint.py, test_cute_resident_reductions_codegen.py); the
two modules ran again at this commit, 63 passed. `./lint.sh check` passes.

autoreview passed: claude, codex

stack-info: PR: #4820, branch: choijon5/cute-norm-bwd/10
@choijon5
choijon5 force-pushed the choijon5/cute-norm-bwd/9 branch from 72e201c to ef64a3b Compare November 29, 2026 20:13
@choijon5
choijon5 force-pushed the choijon5/cute-norm-bwd/10 branch from 161c1b9 to dc37883 Compare November 29, 2026 20:13
choijon5 added a commit that referenced this pull request Nov 29, 2026
For the norm backward kernels (layer_norm_bwd in examples/layer_norm.py and
rms_norm_bwd in examples/rms_norm.py, which TritonBench runs as
layer_norm-bwd and rms_norm-bwd): part of their hillclimb on the CuTe
backend.

Kernels: resident reduction kernels whose rows are 32-bit:
examples/layer_norm.py::layer_norm_bwd and
examples/rms_norm.py::rms_norm_bwd with fp32 inputs. TritonBench on a B200,
one cold full autotune per input, the time the search measured for its
winner, origin/main (f615a9b) -> this commit:
- layer_norm-bwd (4096, 4096): 56.9 us -> 49.8 us
- layer_norm-bwd (4096, 1024): 24.8 us -> 24.7 us
- rms_norm-bwd (2048, 1024), (2048, 2048), (2048, 4096) and (2048,
  16384): 14.8, 19.5, 30.0 and 93.2 us -> 14.6, 19.1, 29.6 and 93.2 us
- rms_norm-bwd (2048, 32768): a search ends in one of two kinds of layout
  at either commit. origin/main, four searches (the nightly's search seed
  at f615a9b, seeds 1 and 2, and the nightly's seed again at 57009cb):
  365.4, 321.6, 324.6 and 807.4 us. This commit, three searches (the
  nightly's seed, then seeds 1 and 2): 809.4, 242.8 and 802.5 us. The next
  commit seeds a layout that reloads this row, and its search ends at
  201.8 us

Regression check for attention, which was hillclimbed before this stack:
the 12 pull requests of this stack together (#4811 to #4822) against plain
main (74ac871), on a B200.
- Generated code, rendered on CPU for the B200 target: all 1,298 configs
  that main renders for 145 attention cases generate the same source with
  the stack, and no seed list changes. The cases are the kernels of
  examples/attention.py (forward and backward), flex_attention.py,
  blackwell_attention.py and fp8_attention.py, and of
  benchmarks/cute/attnbwd_kernels.py and attngym_kernels.py; the configs
  are each case's default and every compiler seed.
- The same with the attention stack (#4797 to #4810) under both sides: 759
  forward and 626 backward and attention-gym configs (defaults, seeds,
  pinned configs), 7,493 more configs that the search reaches on 12
  forward cases (one knob changed at a time, random draws) and 3,861 with
  random draws on the backward and attention-gym kernels generate the same
  source with and without this stack, and the 11 kernels compiled on the
  GPU (the eight forward shapes below and three fp8 attention inputs) have
  the same MLIR bytecode.
- Time: the eight forward shapes of examples/attention.py (dense and
  causal, B2 H32 S1024 D64 fp16 to B8 H32 S8192 D128 bf16) at pinned
  configs, with and without this stack, interleaved, a new process for
  every reading, 4 to 8 rounds a shape. The best readings with the stack
  are 0.994 to 1.007 times those without. On this power-capped GPU every
  implementation, cuDNN SDPA included, reads one of two levels 3 to 5%
  apart from process to process; both sides read the same two levels.

The five other inputs up to 16384 features end where they did, within 0.4
us: the vector width is a knob, which the search moves from the 8-wide
seeds by itself. Pinned, the seeds take 21% to 29% less kernel time 4-wide
than 8-wide (4096 rows of layer_norm_bwd): 13.9 -> 9.9 us at 1024
features, 25.6 -> 20.1 us at 2048, 45.5 -> 34.3 us at 4096 and 88.0 ->
64.9 us at 8192. Kernels with 16-bit rows keep their seeds.

At 32768 features of rms_norm_bwd no seed holds the row in its threads'
registers, at origin/main or here: the search starts from seeds that spill
(the 256-thread one runs 2267 us) and ends where its random path takes it:
in a layout of 240 to 365 us, or in one of about 805 us, which is where
one of origin/main's four searches and two of this commit's three ended.
The twin that this commit adds at that width spills as well. The layout
that origin/main's first search found renders the same kernel at this
commit and runs 365 us pinned, as the search times it (the call with its
host sum; the kernel alone takes 319.6 us of it). The commit above seeds a
reloading layout for this row (195.7 us of kernel time), which a search
cannot end behind, so the two are best landed together.

The resident seed lattice's 256- and 512-thread entries and the vector rows
carry 8-wide feature vectors: 16 bytes of a 16-bit row, which is one async
copy or one vector load.  Of a 32-bit row 16 bytes are 4 features, and an
8-wide vector is two copies.  The 4-wide layout took 21% to 29% less time on
fp32 rows (B200, examples/layer_norm.py::layer_norm_bwd, 4096 rows, staged,
kernel time in us):

  features  threads  row group  8-wide  4-wide
      1024      128          4    13.9     9.9
      2048      256          2    25.6    20.1
      4096      256          2    45.5    34.3
      4096      512          2    47.4    35.7
      8192      256          1    88.0    64.9
      8192      512          1    86.0    65.1

For a kernel whose rows are all 32-bit (`_packet_vector`: the features in 16
bytes of the tensors the kernel loads whose last dim is the row's length),
the family repeats its 8-wide entries 4-wide.  The twins follow the
existing seeds, which keep their rank, and a layout the list already holds
is not repeated.  A kernel of 16-bit rows keeps its seeds, and so does one
whose rows' element sizes differ or are unknown.

A 32-bit row is twice the bytes of a 16-bit one, so a staged twin takes the
largest row group, of its entry's halved down to one, whose two slots the
shared memory holds (`_staged_rows`), and no staged twin is seeded when not
even one row's slots fit.  Of 4096 fp32 features the stage holds seven
rows: the four-row group of 512 threads becomes two.  Of 8192 it holds
three: every staged twin is one row.  Those are the layouts of the table,
which all render.  Of 16384 features the twins are the unstaged ones.

Compatibility: CuTe only, autotuner seeds only.  The compiler seed list of
a resident reduction kernel with 32-bit rows grows, and with it the
fingerprint of its autotune cache entry changes.

Tests (test/test_cute_resident_packet_seeds.py, new, CPU): the packet of
fp32, bf16 and fp16 rows; for fp32 rows of 1024, 2048, 4096, 8192 and 16384
features the seeds are the previous ones followed by the listed 4-wide
twins, in order; at 8192 features the one-row staged twin renders, and its
two-row form, which the lowering refuses, renders with the shared memory
doubled; a bf16 row's seeds are unchanged.  The module holds no GPU test,
so `test/shard_durations.json` has no entry for it.

Testing: B200, CUDA 13.2, torch 2.15.0+cu132, on origin/main 74ac871. At
this commit: `scripts/run_tests.py --backend cute --lane cpu`, 27386 passed,
684 skipped, 1 failed
(test/test_cute_fragment_assertion.py::test_assertions_in_binary_cross_entropy_decomposition,
which needs the nightly's decomposition: it fails on torch 2.15.0 at
origin/main as well); the new module and the four resident row modules
beside it (test_cute_resident_row_widths.py,
test_cute_resident_reductions.py, test_cute_resident_reduction_runtime.py,
test_cute_resident_reductions_codegen.py) on both lanes with GPU 4, GPU lane
10 passed, CPU lane 1304 passed. The commit changes seeds only; the tests
that read them on a device ran at the tip of the stack, which holds this
commit: `scripts/run_tests.py --backend cute --gpus 4,5,6,7`, GPU lane 16010
passed, 2374 skipped; CPU lane 27408 passed, 684 skipped and the same 1
failed. The cold autotunes of the lead: origin/main at f615a9b and at
57009cb (seeds 1 and 2, and the nightly's seed again for the widest
rms_norm-bwd input), this commit on each; #4763 to #4767, which landed in
between and since, leave the seeds and the code of these kernels as they
were (at the tip of the stack, the compiler seeds, the default config and 40
random configs of each of the 15 TritonBench inputs (1023 configs) render
the same code, or are refused alike, before and after the rebase onto #4766
and the one onto #4767). The lanes ran before the last review of the stack's
bottom commit changed two of that commit's tests
(test_cute_smem_footprint.py, test_cute_resident_reductions_codegen.py); the
two modules ran again at this commit, 63 passed. `./lint.sh check` passes.

autoreview passed: claude, codex

stack-info: PR: #4820, branch: choijon5/cute-norm-bwd/10
@choijon5
choijon5 force-pushed the choijon5/cute-norm-bwd/10 branch from dc37883 to bab5b80 Compare November 29, 2026 20:14
@choijon5
choijon5 changed the base branch from choijon5/cute-norm-bwd/9 to main November 29, 2026 20:14
@choijon5
choijon5 merged commit c43b9ec into main Nov 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants