Skip to content

flash_forward asks for 147536 B of shared memory and the driver admits 0 blocks per SM #70

Closed

Description

@feitreim

Surfaced the moment flash_forward joined the default build (#3) and the occupancy query from #47 could reach it. It compiles, it survives real sm_100a codegen, and it cannot launch as configured.

kernel           threads        shared   blocks/SM   warps/SM
gemm                 128       73792 B     cluster          —
softmax              128       32800 B           6         24
layernorm            128       33344 B           2          8
flash_forward        128      147536 B           0          0

cuOccupancyMaxActiveBlocksPerMultiprocessor returning 0 means the driver considers this launch envelope inadmissible. Nothing else in the table is close: flash asks for roughly 4.5x what softmax does and twice what the GEMM does.

Two candidate causes, and they want different fixes

  1. Missing opt-in. Dynamic shared memory above 48 KB requires cuFuncSetAttribute(CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_MEMORY_SIZE, ..) before launch. 147536 B is 144 KB — under a B200 SM"s ~227 KB ceiling but far over the 48 KB default. If this is it, the fix belongs in the launcher (which does not exist yet) and possibly in the library, since every kernel here that wants a large stage will hit it.
  2. The shared plan is genuinely too large. Even with the opt-in, 144 KB admits at most one block per SM, i.e. 4 warps of 64 — an occupancy ceiling that would make flash slow for the reason softmax is latency-bound, not bandwidth-bound: 362 GB/s ceiling and a flat 51us floor #47 and layernorm_rows sits at 255 registers with spills and gets 2 blocks/SM where softmax gets 6 #67 are both about. Worth computing the budget from the ring depth and tile shapes rather than accepting it.

Do not assume it is (1). Distinguish them: set the attribute and re-query. If blocks/SM goes 0 → 1, it was the opt-in and the remaining question is whether 1 is acceptable. If it stays 0, the plan does not fit at all.

Why this was invisible until now

flash_forward sat behind a cargo feature, so it was absent from the default set that cargo oxide build kittens-examples --arch sm_100a compiles — CI never codegened it, and the occupancy table never listed it. It has no launcher and no CPU reference, so "compiles" was the strongest claim available and it hid this completely. That is the argument for ungating it, validated within one run.

Scope

  • Diagnose which cause it is, with the re-query as evidence.
  • If the opt-in is needed, decide where it belongs — a launcher helper in the library beats every example repeating it, and gemm will need the same thing (73792 B is also over 48 KB, and it launches today only because cluster_launch takes a different path; check whether it is silently relying on something).
  • If the plan is too large, report the budget by component (the K/V rings, the P staging tile, the barriers) so the tradeoff is visible rather than a single number.
  • This is a prerequisite for any flash launcher, and therefore for flash ever moving from compiles to runs.

Related: #47 (the same table, opposite failure), #67 (layernorm_rows at 2 blocks/SM), #3 (which put flash in the default build and made this visible).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compute

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions