Skip to content

Device test harness #4

Closed
Closed

Description

@feitreim

The crate has three #[cfg(test)] unit tests total (mma.rs, tmem.rs), all covering address arithmetic on the host. Everything else — the swizzle phase math, the fragment ownership map, the phase-parity rules — is verified only by downstream kernels being numerically correct on a B200.

ThunderKittens has tests/ with a generated harness sweeping the type/layout cross product.

Why here in the order. #5 and #6 add roughly 40 elementwise and reduction ops whose entire correctness question is "does this agree with the fragment ownership map." Landing them without a way to check that on hardware means the map is being re-derived by hand 40 times with no feedback. The harness is worth less than the ops but has to exist before them.

Shape

  • A test kernel crate (this crate ships no kernels, so the harness needs its own) that stages a known pattern, runs an op, drains, and compares against a host reference.
  • Table-driven over tile shapes so a new op is one entry, not one kernel.
  • Split the run: cargo test for the host-side address arithmetic on any machine, a separate gated target for anything needing a GPU.
  • CI running at least cargo check on the device surface, and cargo check --features host wherever a CUDA toolkit is available.

Activity

  1. added
    infra
    on Jul 26, 2026
  2. feitreim commented on Jul 26, 2026

    @feitreim
    OwnerAuthor

    Landed, and it runs green on a B200.

    pass  swizzle round trip        4096 elements placed exactly
    pass  fragment map (16, 16)     1024 values, all at BaseLdtm's coordinates
    pass  fragment map (32, 32)     4096 values, all at BaseLdtm's coordinates
    pass  fragment map (32, 128)   16384 values, all at BaseLdtm's coordinates
    pass  stmatrix round trip       4096 elements placed exactly
    5 of 5 cases passed
    

    The fragment ownership map is now verified against silicon — the headline result. D = A·B^T seeded so D[row, col] == 128*row + col (all factors integral and exact in bf16, all products exact in fp32), drained through fragment_tile. The kernel dumps indexed by (warp, lane, slot, value) only; the host applies RegTile::coordinate. Injective encoding, so each of 16384 values inverts to exactly one coordinate — the test cannot pass vacuously, and on failure it reports the map hardware actually delivered.

    Infrastructure: device-tests/ (separate kernel crate, own workspace — this library still ships no #[cuda_module]) and modal_app.py (image recipe copied from rust-trainer, hit the layer cache; CPU-only build for iteration, B200 device_tests). Host suite 16 -> 19 tests.

    CI was not done — split out to #17, since gating the parts that matter needs a CUDA box and a GPU.

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

    infra

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions