Repository navigation
Examples crate: kernels written against the API we want - #20
Merged
Merged
Conversation
Its own workspace, like device-tests, so cargo at the root never sees it and an aspirational kernel cannot break the library's build. Aspirational kernels sit behind per-kernel features and are off by default, so anything in the default build genuinely compiles and the two kinds are distinguishable without running anything. gemm is the first thing to exercise the cta_group::2 path: a CTA pair shares one M256_N128 UMMA, K is software-pipelined over a SharedTileRing pair with SemaphoreRing owning the parity arithmetic, and `free` is released by the MMA's own commit rather than by a thread. It builds under `cargo oxide build kittens-examples --arch sm_100a`; it has not been run. Three things it had to reach past the library for, each fenced and marked in the file: cluster-scope TMEM allocation (alloc_block is cta_group::1), cluster-scope semaphore arrival (Semaphore is CTA-scoped, so the peer's TMA cannot complete on the leader's barrier), and a global store from registers (#11). None has an open issue. The root manifest needs `autoexamples = false`: `examples/` is one of cargo's own target directory names and `exclude` does not stop target auto-discovery, so without it `examples/src/main.rs` is compiled as an example target of the library, against the library's dependencies.
Only the kernels marked *compiles* are in the default feature set, so a real
`cargo oxide build --arch sm_100a` of this crate is what keeps that claim
honest -- a post-monomorphization `const { assert!(..) }` in a tile shape is
invisible to `cargo check`.
Each names the API it wants at the call site that wants it, with the issue numbers it is blocked on in its header. Verified that every resulting compiler error is an unresolved import, a missing method, or an unsatisfied FragmentLayout bound -- nothing in these files fails for any reason other than the API not existing. What they turned up beyond the filed backlog: there is no shared -> register path at all, so softmax cannot get past its first line; the movers are per-[16, 16]-block, so every kernel rewrites the same composition loop; SwizzledChunks refuses tiles wider than one swizzle atom, so a [128, 128] tile has no register -> shared path; and the RegTile shape set is closed by a macro inside src/reg.rs, so flash cannot name its [32, 64] score band out of tree. #7's make_causal also needs a coordinate origin it is not filed with: a flash kernel masks a band whose diagonal sits at query_base - key_base.
Grouped and mapped to issues, with the nine things no open issue covers called out separately -- that last set is the part of the backlog derived from trying to write a kernel rather than from reading ThunderKittens' feature list. Two negative results worth as much as the gaps: #12 (MMA coverage) was not demanded by any of the four, and multicast has no geometry to live in -- under a 2-CTA UMMA both operands are already split across the pair, so tma_load_2d_multicast_cg2 has nothing to broadcast and the GEMM cannot use it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four kernels, each with a header stating compiles or aspirational, and
examples/README.mdcollecting the API surface all four demand that does notexist yet.
Its own workspace like
device-tests, socargoat the root never sees it.Each aspirational kernel sits behind its own feature and is off by default, so
everything in the default build genuinely compiles and a reader can tell the two
apart without running anything. Turning a feature on prints that kernel's gap
list as compiler errors, at the call sites that want it.
gemmflash_forwardsoftmaxlayernormVerification
modal run modal_app.py::buildpasses:cargo check --features host --all-targets, the host tests,cargo oxide build device-tests --arch sm_100a,and a new
cargo oxide build kittens-examples --arch sm_100a.gemmreallybuilds — that last step is the only thing that catches post-monomorphization
const { assert!(..) }failures. It has not been run: this issue needs noGPU, so treat it as a statement about expressiveness, not a numerical result.
The 2-CTA operand split is the first thing to check on hardware.
cargo fmt --checkandcargo clippyclean. Confirmed that every error theaspirational kernels produce is an unresolved import, a missing method, or an
unsatisfied
FragmentLayoutbound — nothing in those files fails for any reasonother than the API not existing.
The part worth reading
Nine things the kernels needed that no open issue covers, in
examples/README.md. The top four:ldstis store-only. Anykernel whose input is not an MMA operand — every normalization, activation,
elementwise epilogue — cannot start. Softmax is four lines of algorithm and
is blocked before the first one.
[16,16]-block.fragment_tileandstore_fragmentforce every kernel to rewrite the same block-composition loop.
reg.rs's owntest states that composition as an invariant, and then no function implements
it.
SwizzledChunkscannot span stacked subtiles, so only 64-wide bf16 tileshave a register → shared path at all.
RegTileshape set is closed by a macro insidesrc/reg.rs; flashcannot name its
[32, 64]score band out of tree.Plus: no cluster-scope TMEM allocation, no cluster-scope semaphore arrival,
pipeline::runcannot schedule a cluster (its work items areblockIdx.xstrided, so a pair gets different items), and multicast has no geometry to live
in — under a 2-CTA UMMA both operands are already split, so
tma_load_2d_multicast_cg2has nothing to broadcast.Two corrections to filed issues: #7's
make_causalneeds a coordinate origin itis not filed with (
make_causal_at(lane, query_base, key_base, fill)), and #8is why this crate ships no host launcher —
encode_bf16_panelsbuilds 3-D panelmaps and both the GEMM's 2-D operands and layernorm's parameter vectors want
another shape.
And a negative result worth as much: #12 (MMA coverage) was not demanded by
any of the four.
mma_abt,mma_abandmma_walk_cg2covered every multiplyin the layouts they wanted. The MMA layer is the finished part of this library.
Note on the root manifest
autoexamples = falseis required:examples/is one of cargo's own targetdirectory names and
excludedoes not stop target auto-discovery, so without itexamples/src/main.rsgets compiled as an example target of the library,against the library's dependencies. (Caught the hard way.) The package is named
kittens-examplesbecause cargo forbidsexamplesas a binary target name.Closes #18