Skip to content

The [256,256] tile costs 18% at 1024 cubed and n % 256, and nothing picks between the two tiles #105

Closed

Description

@feitreim

#104 promoted the pair tile to [256, 256] @ STAGES = 3 and won 21.6% at
16384³. It states its two costs rather than burying them, and both are the same
fact seen twice: a bigger tile quantizes worse at small sizes.

  • n % 256 == 0 where 128 used to do.
  • 1024³ regresses 18%. Everything at and above 2048³ improves.

The old tile is still launchable — #104 kept it as the control — so the material
for a fix already exists. What does not exist is anything choosing between them.

The shape of the fix

Tile's pair shape and stage count are const parameters after #104, so both
rungs are entry points that already build and are already checked exact. The
host picks one from n and the problem size at launch. That is a dispatch
decision, not a kernel change, and it should live wherever the launcher already
computes the grid.

The threshold is a measurement, not a guess. #104's sweep has both tiles at
8192³ and 16384³ but the crossover is somewhere below 2048³, which nothing has
timed. bench --case tile is the instrument and it already exists; the sizes
below 2048³ are what it has not been pointed at.

Note the crossover is not only about n. [256,256] costs an occupancy step
(2 CTAs/SM against 3), and #101 measured a step at 14-16% of throughput — so
the small-size loss is partly quantization and partly residency, and those two
do not have to cross over at the same size. Worth reporting which dominates
rather than fitting one threshold and moving on.

Why not just require n % 256

Because the constraint is invisible at the call site and fires at codegen. A
post-monomorphization const { assert!(..) } in a tile shape is exactly what
tier 2 exists to catch (see CI.md), which means an n of 1152 is a build
failure in a Modal container rather than an error where the caller wrote it.
That is an acceptable price for a benchmark kernel and a poor one for anything
a caller reaches for, and the ambition in examples/README.md is the latter.

Scope

  • Time both tiles below 2048³ — 512³, 1024³, 1536³ at least — and report the
    crossover with the losing rows kept.
  • Select the tile host-side from the shape. Keep both entry points; this issue
    adds a chooser, it does not delete a rung.
  • Say in the doc what the selection rule is and what measurement set it, so the
    next tile change knows what it has to re-measure.
  • Check exactness at every size on both paths before any timing.

Acceptance

No shape that worked before #104 is slower after this, and the rule that picks
the tile cites the run that set it.

Related: #87/#104 (the sweep and the two costs), #101 (the occupancy step's
price, which is half the small-size story), #102 (grouped traversal, whose
group width is the other launch-time parameter and may interact).

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions