Skip to content

Weight-gradient GEMMs phase 2: MN-major operands via tcgen05 descriptor transpose #53

Closed

Description

@feitreim

Weight-gradient GEMMs phase 2: consume MN-major operands via tcgen05 descriptor transpose

Follow-up to #43 (PR #50), which landed the fused quantize+transpose fallback (spans −10…−22%). The full win — forward-parity efficiency on the weight-grad spans — still requires eliminating the transpose materialization entirely: a dW += Aᵀ·B tcgen05 variant that reads both operands in native row-major layout via the Tcgen05InstructionDescriptor transpose_a/transpose_b bits (and matching TMA box/swizzle/smem-descriptor LBO/SBO geometry).

PR #50 deferred this deliberately: no example in cuda-oxide v0.2.1 exercises the transpose bits, and the only iteration loop for MN-major swizzle geometry is full Modal cycles with swizzle_probe. Suggested approach: first build a minimal standalone probe kernel (à la swizzle_probe / the #47 score_mma probe) that validates a descriptor-transposed MMA against a CPU oracle on one tile, then port the weight-grad path.

Also in scope once the descriptor route exists: the lm-head backward.lm_head.transpose_input/transpose_dlogits (already-bf16 movement with no quantize to fold — untouched by #50).

Remaining measured cost (post-#50, B=12): gate_up_weight_gemm 53.6 ms, down_weight_gemm 28.6 ms, qkv_proj.weight_gemm 18.5 ms, o_proj.weight_gemm 7.0 ms vs forward-parity targets roughly half that.

Activity

  1. added
    enhancement
    on Jul 23, 2026
  2. feitreim commented on Jul 25, 2026

    @feitreim
    OwnerAuthor

    Landed on main (64e74a4). The probe-first approach paid off: gpu/gemm transpose_probe sweeps descriptor geometries as launch parameters (one Modal run, many candidates). Settled geometry for a transposed M128 operand under SWIZZLE_128B: two stacked 64-wide subtiles, LBO=8192 (subtile jump, not the 16-byte core-matrix step), SBO=1024, 2048 B per K=16 chunk; the operand stays fully swizzled. M64 fails identically for K-major and MN-major A — the 7e15 dead end is a property of the shape, not the layout. The port landed: gemm_tcgen05_bf16_optimized transposed=1 (both descriptor bits + swapped TMA coords), weight grads consume native row-major operands, the #50 fused quantize+transpose kernels became plain quantizes, rhs_t and the lm-head transpose passes are deleted. BUT the perf premise didn't hold: all four weight-gemm spans are flat within noise — they're DRAM-bound re-reading the K=E·C=49152 operand slice, so operand orientation was never the lever; weight reuse is the only one left there (SPEC updated). The real win is memory: workspace 167.9 → 164.3 GiB (+35% free headroom), two kernels and three scratch buffers gone. SPEC §13.9.

  3. added 2 commits that reference this issue on Jul 26, 2026
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions