Skip to content

regcount measures two widths because probes are hand-written, not because measuring is expensive — sweep the ladder #60

Closed

Description

@feitreim

The problem

Every register claim in this repo is measured at exactly 32 and 128 columns, and the guidance I have been handing agents is "measure both, trust neither in advance." That guidance exists because two points keep disagreeing:

Two points is enough to know the curve is not flat and not enough to know its shape. Every one of those findings is really "there is a cliff somewhere between 32 and 128, and we do not know where."

Why it is only two, and why that is the wrong reason

Not cost. ptxas is a host compiler — modal run modal_app.py::regcount is CPU-only and the ptxas -v pass is milliseconds per PTX file. The actual constraint is structural, and regcount's own docstring states it:

Only kernels that are actually monomorphized appear — an op no kernel calls emits no PTX and measures nothing, so a codegen probe in device-tests is how a bare library function gets onto this table at all.

So each width costs a hand-written probe kernel in device-tests/src/main.rs. Widths are two because writing probes is manual, which is a reason to generate them, not a reason to measure less.

What to build

A macro that emits a probe per (shape, spelling), so a ladder costs one line per rung:

  • Columns: 16, 32, 48, 64, 96, 128, 192, 256. All multiples of 16 (BaseLdtm needs N % 16 == 0).
  • Rows: at least 16, 32, 64 — the row extent has never been swept at all, and SLOTS = M/8 scales the per-thread array just as VALUES = N/4 does.
  • Deliberately cross the cliff. A thread holds M*N/32 fp32 values, so [32, 256] is 256 registers — one past the file. Shapes that spill are the informative ones; do not stop short of them, and expect some to fail to build (report, do not silently drop).

Cover the spellings #31 established as the axis that actually orders cost — how many whole bands get materialized between statements:

  • fused single expression (out.scale(k).add(b.scale(k)))
  • in-place _assign
  • rebinding (x = x.op(..))
  • open-coded loop

Acceptance

While you are in there

lane_probe's recorded table is stale in three cells — it claims 198/2816 and 72/256 where main measures 168/2816 and 56/384. Two separate agents have now noticed and correctly left it alone as #27's. If the sweep replaces those numbers wholesale, this goes away; if not, fix the three cells and say so.

Related: #27 (implicit lane), #31 (which produced the model this sweep would test).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:scaffolding

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions