Skip to content

A per-column operand in global memory has no way into registers: load_cols, the global twin of ldst::load_vec #172

Closed

Description

@feitreim

ldst::load_vec reads a ColVec out of a SharedVec, and global::load_rows reads a RegTile out of global memory. There is no third call: a per-column operand that lives in global memory has no way to reach the registers that multiply by it.

The consumer is the RMSNorm port in feitreim/oxide-train#70. Its weight is a [dim] fp32 vector shared by every row of the tile, and dim is a runtime number — so it cannot be a SharedVec<E, N>, whose length is a const, and staging one chunk at a time would cost two barriers per chunk in a kernel that has none. The only spelling available today is a GlobalRows cursor at stride 0 feeding load_rows, which broadcasts the vector into a full RegTile and then muls elementwise:

let parameters = GlobalRows::<F32>::from_raw(weight.as_ptr() as *mut u8, 0);
let w: RegTile<32, CHUNK, BaseLdtm> = load_rows(parameters, 0, column, lane);
let out = x.mul_row(inv).mul(w);

That is SLOTS * VALUES registers to hold VALUES distinct numbers — every value repeated once per row the thread owns. On a B200 it is not a rounding error, it is the cliff. Sweeping the port's chunk width against the shipped kernel (24576 x 3072 fp32, modal run modal_app.py::main --kernel ops --sweep ...):

chunk rows/warp forward vs shipped backward vs shipped
16 32 0.737x 0.689x
32 32 0.831x 0.778x
64 32 0.151x 0.098x
64 16 0.257x 0.169x
192 16 0.111x 0.064x

The collapse past 32 is the parameter tile spilling: at chunk 64 the forward holds 64 fp32 of x plus 64 more of a weight vector that has 16 distinct values in it, and the backward holds three such tiles. The chunk width is the one knob that buys memory-level parallelism in a bandwidth-bound kernel, and today it is spent on redundancy.

What is missing

The global twin of ldst::load_vec — a ColVec read directly out of a GlobalRows row:

pub unsafe fn load_cols<E: Element, const N: usize, L: ColLayout<N>>(
    src: GlobalRows<E>,
    row: u32,
    column: u32,
    lane: u32,
) -> ColVec<N, L>

L::VALUES registers instead of L::SLOTS * L::VALUES, the same addresses load_rows would touch on one row, and the same CONTIGUOUS_VALUES pairing decision, so a paired layout gets ld.global.v2 here too.

This is the concrete corner of §1.4's "RegVec has no bridge to memory at all" and §3.1's per-column operand that is nearest to a shipping kernel; #130 carries the SharedVec half of §1.4, and this is the global half, which #130 does not reach.

Scope

load_cols only. A store_cols has no consumer — a kernel that produces a per-column result produces it as a ColVec from col_reduce and would want an atomic, not a plain store — and the rule here is to ship what a kernel needs.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions