You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
moe_scatter_dy: one thread per slot serializes a 3072-float row copy + dot #45
moe_scatter_dy gives each (token, slot) pair a single thread that (a) copies the token's D=3072 gradient row into the expert bin and (b) accumulates the gate gradient Σ_d dy·bin_output over the same 3072 elements — a serial, stride-1-per-thread loop with no coalescing across the row. The forward scatter of the very same tensor shape is thread-per-element and still 4× cheaper while doing comparable traffic; the backward variant is only shaped this way because of the fused dot.
At ≈ 21 ms this is 5% of the ~410 ms non-attention step for what is bandwidth-wise a sub-millisecond operation.
Sketch
Split the two concerns, or restructure around a block per slot:
Block-per-(token, slot): block-wide coalesced copy of the D row (vectorized), plus a block reduction for the gate dot — one kernel, both outputs, full coalescing. N·K = 32k blocks is plenty of grid.
Or two kernels: thread-per-element scatter (exactly mirroring moe_scatter) + a separate warp-per-slot dot for gate_gradients. Simpler, two launches.
Either way backward.router.zero_dy_bins (2.5 ms full-buffer fill) can likely fold in: a block-per-slot kernel that also zeroes unassigned capacity slots removes the separate E·C·D fill pass (needs the assignment counts to enumerate dead slots, which the routing acts already hold).
Gates
MoE model parity with forced drops and underfull experts (gate-gradient reduction order changes → existing fp32 tolerances; token/slot write disjointness must be preserved exactly).
§10.1 same-container profile: scatter_dy from ≈ 20.8 ms to ≈ 1 ms or below.
Activity
Merge pull request #49 from feitreim/perf/issue-45-scatter-dy
perf(moe): float4 scatter_dy rows + dead-slot bin zeroing (#55)