Skip to content

gemm_sol's [256, 256] entry does not return at 4096x4096x1024, and the shape is inside its contract #149

Closed

Description

@feitreim

gemm_sol's [256, 256] entry does not return at 4096x4096x1024, and the shape is inside its contract.

#146 found it: the row printed nothing for 1200 s and scripts/modal-run's watchdog stopped the container, while 4096x4096x2048 runs and is in that PR's table 4. It was left out of both tables and not chased. #148 reproduced it and built the instrument for it; this issue is the characterization, and the fix is nobody's yet.

The shape is legal

validate_shape asks for m % 256 == 0, n % 256 == 0, k >= STAGES * BLOCK_K and k % (STAGES * BLOCK_K) == 0. 4096x4096x1024 satisfies all four: k_blocks = 16, four whole turns of the four-stage ring. So this is a defect and not a misuse, and the contract does not need widening for it to be one.

A k shorter than m is otherwise unexercised. Every timed row in bench sol, bench sol-small and bench sol-ablate has k >= 2048, and the correctness gate is 1024x1024x512 where k is half of m but the grid is 8 tiles rather than 256.

The instrument, and why it is shaped this way

bench sol-k (#148) walks k downward — 2048, 1792, 1536, 1280, 1024, 768, 512, 256 — at m = n = 4096 on the [256, 256] entry, and it announces each row on stderr before launching it. A launch that does not return takes the process with it, so the last line announced is the whole of the answer; a table that printed only completed rows would say nothing about the row that mattered.

It is its own case and no other table calls it, which is the lesson from how #146 found this: a hang takes every row after it, and the tables that pay for a container are worth more than this row is.

The boundary is k = 1280

One container. Every row below 2048 is new, every row is exact against the fp32 reference before it is timed, and the last line is the whole of the finding:

shape k_blocks turns min ms TFLOP/s of cuBLASLt spread
4096x4096x2048 32 8 0.0605 1136.2 0.789 3.0%
4096x4096x1792 28 7 0.0542 1109.9 0.803 6.0%
4096x4096x1536 24 6 0.0500 1031.1 0.780 5.2%
4096x4096x1280 20 5 0.0445 964.2 0.774 7.2%
4096x4096x1024 16 4 announced, never returned

4096x4096x1280 is the shallowest k that returns and 4096x4096x1024 is the deepest that does not, so the boundary is between 20 and 16 K blocks — five turns of the four-stage ring and four. The container was stopped from the CLI after ~30 minutes rather than left to burn, which is why there is no row for 768, 512 or 256; the ladder descends, so those are all on the far side of a shape that does not return and cost a container each to reach.

Shallow k is not otherwise broken. All four completed rows are exact, and the ratio against cuBLASLt is flat at 0.774–0.803 across them — the same neighbourhood as every deeper row. So this is a cliff at one value and not a degradation.

The stage fold in #148 is neither the cause nor the cure. #146 saw this on the ring index computed from global_k; the ladder above ran the folded spelling and it hangs at exactly the same shape. Both spellings walk while turn < turns with turns = k_blocks / STAGES, which is 4 here and 5 one rung up.

What is known and what is not

Known: the boundary above; the shape is inside the contract; the correctness gate at 1024x1024x512 passes on all three entries and every completed rung above is exact, so nothing here is a general breakage of the entry; and it does not depend on which of the two ring-index spellings the MMA warp uses.

Open: the mechanism. Also untested: whether [256, 128] and [512, 256] share the boundary, and whether the variable is the trip count or the tiles-per-cluster ratio — at these shapes the grid is 256 tiles over 256 clusters, so a cluster does one item plus whatever CLC hands it, and k_blocks and that ratio do not move independently along this ladder. Sweeping m at fixed k = 1024 would separate them, and each attempt costs a container.

One arithmetic coincidence worth writing down without any weight on it: turns = 4 is exactly STAGES, and it is the first rung where it is. Whether the ring's depth and the number of turns coinciding matters is not established, and nothing in the code obviously turns on it.

Candidate mechanisms, with the evidence each would need

Stated as candidates because #148 did not narrow them and none should be treated as the answer.

  1. A missed parity on ready after the producer has exited. Common::info is a single SharedCell<TileInfo> behind a single Semaphore, and next_info(sequence) waits parity sequence & 1. The producer republishes as soon as ClcCursor::next returns; its only throttle between items is free.wait_recycled, which holds it to roughly one item ahead of the MMA warp and says nothing about the epilogue, which lags by a further tile. If a consumer ever falls two phases behind, its parity wait lands on a phase that completes late — and if the producer has already published has_work = false and left the loop, on a phase that never completes at all. Shallow k is exactly the regime where the producer clears an item's loads fastest relative to a drain that The drain is exposed whole, and both of its expected levers measure zero #147 prices at 2.82 µs of serial work per tile, so it is the regime where that lag is largest. What would confirm it: a k boundary that moves when the drain's cost moves — for instance, the same ladder on no drain, which keeps every barrier and removes the phase the lag is measured against.
  2. The CLC work-stealing loop. ClcCursor::next is the one thing in the item loop whose termination is the hardware's rather than the code's, and 256 clusters for 256 tiles means most clusters get exactly one item and then query. What would confirm it: the same ladder with the CLC cursor replaced by a static stride, which gemm.rs already has as a separate item source.
  3. An unterminated K walk. Ruled out by construction rather than by measurement, and cheap to state: the walk is while turn < turns with turns = k_blocks / STAGES = 4, and k_blocks and turns are both runtime values that cannot be zero under the contract. Every arm of The small entry's K loop is its feed's duty cycle, and the ring index was a port defect (#144) #148's ladder at k = 2048 and above walks the same loop.
  4. A barrier deadlock in the full/empty accumulator handshake. full and empty are SemaphoreRing<2> and the MMA warp waits empty.wait(sequence - 2), so two output tiles are in flight. At one item per cluster that wait never runs, which makes this the least likely of the four at exactly this shape — worth writing down because it is the one a reader will reach for first.

Not a blocker for anything shipped

select_variant routes on m and n only, so no shape reaches a different entry because of this, and nothing in the sweeps or the gates runs at a k below 2048 except the 1024x1024x512 check, which passes. The cost of leaving it open is that the entry has an untested region of its own contract, and that a future sweep which happens to enter it burns a container to the watchdog — which is how it was found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions