Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions hopper/tile_size.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

constexpr int smem_estimate_bytes(int block_m, int block_n, int headdim, int headdim_v, int element_size) {
// Double-buffer the residency for Q/K/V and the accumulators when the head/value dims are modest.
// For very large dimensions the single-stage SM120 pipeline only needs a single residency footprint, so
// avoid over-clamping by scaling the estimate down to one buffer in that regime.
int const buffering = (headdim + headdim_v >= 512) ? 1 : 2;
// Value dimensions 256+ already drive the shared-memory footprint high, so treat them like the large
// combined-head/value case and drop to a single buffer in that regime to avoid over-clamping.
int const buffering = (headdim_v >= 256 || headdim + headdim_v >= 512) ? 1 : 2;
return buffering * (block_m + block_n) * (headdim + headdim_v) * element_size;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/hopper/test_tile_size_shared_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _load_bridge() -> ctypes.CDLL:

def estimate_smem_bytes(block_m: int, block_n: int, headdim: int, headdim_v: int, element_size: int) -> int:
# Mirror the buffering-aware estimate used in hopper/tile_size.h.
buffering = 1 if headdim + headdim_v >= 512 else 2
buffering = 1 if (headdim_v >= 256 or headdim + headdim_v >= 512) else 2
return buffering * (block_m + block_n) * (headdim + headdim_v) * element_size


Expand Down