Skip to content

lcsf and the rest of the prototype layer #15

Closed

Description

@feitreim

pipeline::run + trait Job is a faithful port of ThunderKittens' prototype::lcf (load-compute-finish). The rest of prototype/ is missing:

  • lcsf — load-compute-store-finish. The store stage is what a training kernel with a producer-consumer epilogue needs; without it the store folds into finish and cannot overlap the next work item's load. The most useful of the three.
  • lcsc — the store-compute variant.
  • common/templates.cuh — the shared config/state plumbing all three prototypes sit on. Our Job trait is the equivalent for lcf alone; a second prototype is the point at which that plumbing wants to be shared rather than duplicated.
  • interpreter — instruction-driven kernel where a persistent grid dispatches over an opcode stream. Newest and most speculative part of ThunderKittens; listed for completeness, not proposed.

lcsf depends on #9 — a store stage with no TMA store path is not worth building.

Activity

  1. added
    enhancement
    area:scaffolding
    on Jul 26, 2026
  2. feitreim commented on Jul 27, 2026

    @feitreim
    OwnerAuthor

    A second reason to want lcsf, from the examples work (#18).

    This issue is filed as depending on #9 (TMA store), which is right. The GEMM example surfaces an independent motivation: with the store folded into finish, a persistent GEMM cannot overlap its epilogue with the next output tile's first K loads. The store phase and the next tile's load phase are exactly the two things a persistent kernel most wants in flight together, and lcf's shape forbids it.

    So lcsf is not only "the variant with a store phase" — it is the variant that makes the persistent scaffold worth using for GEMM at all. Worth weighing when this comes up the order.

    Related: #24 records that pipeline::run cannot schedule a cluster today (work items are blockIdx.x-strided, so a CTA pair gets different items), which is the other reason the GEMM example does not use the persistent scaffold.

  3. feitreim commented on Jul 27, 2026

    @feitreim
    OwnerAuthor

    Acceptance: update examples/ as part of closing this.

    gemm does not use the persistent scaffold at all. Getting it to is the acceptance test — see the comment above on epilogue overlap.

    The examples crate (#18) exists so that "done" is checkable in the terms a kernel author cares about, rather than as a claim about a primitive nobody has tried to hold. Concretely, on closing this:

    • Delete any workaround or GAP fence in examples/src/ that this issue removes the need for, and replace it with the real API.
    • If a kernel becomes fully unblocked, move it from aspirational to compiles: flip its header, take it out of its feature gate, and confirm modal run modal_app.py::build builds it for sm_100a.
    • Update the status table and the blocked-on lists in examples/README.md.

    If the example still does not compile afterwards, that is a finding worth writing down — say what is still missing rather than leaving the README stale.

  4. feitreim commented on Jul 29, 2026

    @feitreim
    OwnerAuthor

    Scoping note from Finn, and it corrects how #107 was framed here.

    #107 measured lcsf on gemm_cg2 and found it hides nothing — f ≈ 0, −5.4% to +1.2% over two B200 sessions. That is a rejection for this kernel, not for the library, and the two should not be conflated. The prototype layer exists because a training kernel with a producer-consumer epilogue needs a store stage that overlaps the next item's load; the GEMM is not that shape, and #107 explains exactly why it isn't — the overlap window is one pipeline fill, and at [256, 256] @ STAGES = 3 that is short.

    A kernel with a longer fill, a cheaper drain, or an epilogue that is genuinely bandwidth-bound would land differently. #107's own HotStore probe is the discriminator worth reusing: it priced deleting a gigabyte of streaming HBM writes at 0–1.2%, which is what "issue-bound epilogue" looks like. A kernel where that probe reads large is a kernel lcsf should be tried on.

    So what #107 settles is narrow and worth stating precisely: the shared/TMA staging route buys nothing over the cheap reordering, and the cheap reordering buys nothing on this kernel. It does not settle whether lcsf belongs in pipeline.rs.

    Also useful and not specific to the GEMM: #107 found lcsf needs none of the 250–400 lines of fp32 plumbing that #94 and #9 both assumed. An undrained accumulator survives the item boundary in tensor memory, so the store stage is a reordering inside Job::work and pipeline::run is untouched — lcf's scaffold already admits an lcsf job. Whoever picks this up for a second kernel starts from there rather than from the plumbing estimate.

    Remaining in this issue and untouched: lcsc, common/templates.cuh, and interpreter. Worth splitting if any of them gets picked up on its own.

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

    area:scaffoldingenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions