Skip to content

scatter_dy phase 2: vectorized row copy + fold zero_dy_bins #55

Closed

Description

@feitreim

scatter_dy phase 2: vectorized row copy + fold zero_dy_bins into dead-slot zeroing

Follow-up to #45 (PR #49), which fixed the serialization (30.77 → 3.66 ms, block-per-pair). Two known levers remain, both measured against the sub-1 ms bandwidth floor:

  1. float4-vectorize the row copy in moe_scatter_dy (D=3072 is 16B-aligned; lanes currently move one f32 per iteration).
  2. Fold backward.router.zero_dy_bins (3.74 ms full E·C·D fill) into dead-slot zeroing: the routing acts hold assignment_counts, so a block-per-slot pass can zero only unassigned capacity slots instead of pre-filling the whole bin buffer, removing the separate fill_zero launch. PR perf: block-per-pair moe_scatter_dy (30.8 -> 3.7 ms, closes #45) #49 left this out to keep the parity-critical diff minimal (different index space: dead capacity slots per expert vs. (token, slot) pairs).

Combined these target ≈ 7.4 ms → ≈ 1–2 ms of step time at B=12.

Activity

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

    @feitreim
    OwnerAuthor

    Landed on main (64e74a4, merge 6f0d6ea). Both levers: (1) vectorized row copies in moe_scatter_dy — carried as u128, not an align(16) [f32;4] aggregate, because codegen SROAs aggregate loads back to scalar ld.global.b32; the u128 form survives as ld/st.global.v2.b64, verified in the PTX. (2) moe_zero_dead_bins replaces the full E·C·D pre-fill: block-per-(expert,slot), early-out on assigned slots — sound because bin assignment is dense, so assigned slots are exactly the prefix 0..min(count,C) and the two kernels partition the buffer. Measured (B200, same-container A/B, B=12): zero_dy_bins 3.80 ms → zero_dead_bins 0.50 ms (7.6×); scatter_dy 3.69 → 2.81 ms (1.31×); pair 7.49 → 3.31 ms (2.27×). Short of the 1–2 ms target: scatter_dy is bound by its 3-rows-per-pair traffic, noted in SPEC. Note for future readers: the gate-gradient dot changed summation order (deterministic, but not bit-identical to pre-#55). SPEC §13.9.

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