Skip to content

Drop the quack fork by zeroing dW operand padding rows - #36

Open
jaimec00 wants to merge 1 commit into
mainfrom
jaime/chore/drop-quack-fork
Open

jaimec00 wants to merge 1 commit into
mainfrom
jaime/chore/drop-quack-fork

Conversation

@jaimec00

@jaimec00 jaimec00 commented Dec 6, 2026

Copy link
Copy Markdown

Summary

Removes StreamEP's dependency on the evolutionaryscale quack fork, whose only extra commit adds seqused_k. The backward now zeroes the padding rows of the dW GEMM operands, so the GEMMs can contract over the padded slot ranges. The test env pins upstream quack-kernels==0.6.5.

Changes

  • stream_moe.py: drops seqused_k from the dW1 / dW2 grouped GEMMs. Right before them, zero_padding_rows zeroes the padding rows of dL_do_pool and pool.
  • recv_pool_compress.py: new zero_padding_rows(pool, expert_pool_block_offset, expert_frequency, tile_m), a Triton kernel with one program per (expert, H-block). It writes only the < tile_m padding rows at the tail of each expert's slot range.
  • pixi.toml / pixi.lock: quack moves from the fork git rev to ==0.6.5 from PyPI. cutlass-dsl stays at 4.7.0.
  • csrc/stream_ep.cpp, AGENTS.md, README.md: comments and docs no longer rely on quack's lens_k OOB fill or mention the fork.
  • Tests: new kernels/test_dw_gemm.py, and test_zero_padding_rows in test_recv_pool_compress.py.

Why

The padding rows of pool and of the intranode dL_do_pool are uninitialized. The other dW operands (dL_dswiglu_in, postact_a_for_dW2) are exactly zero there, but 0 × NaN = NaN, so the garbage side has to be clean too. seqused_k excluded those rows; zeroing them does the same job with stock quack.

Evoscale must pin the same quack (quack-kernels==0.6.5) when it picks up this StreamEP version. StreamEP runs on whatever quack evoscale has installed. Between the fork base and 0.6.5, upstream's only change is a SwiGLU epilogue fix for the (2, 2) layout.

Verification

H100, quack 0.6.5, torch 2.11:

  • kernels: 188 passed. This includes the dW GEMMs at the default tile configs with NaN / inf padding against a real-rows-only reference (worst error 1.67e-3, tolerance 4e-3), and a control showing the NaN reaches dW without the zeroing.
  • dist (8 GPUs): 234 passed. internode (2 × 8 GPUs): 236 passed and 4 skipped per node. The skips are the existing level-2 empty-rank known bug.
  • profile_pipeline at the default bench shape, 3 interleaved runs vs main:
per iteration (µs) main this PR
zero_padding_rows (2 calls) — ~30
bwd e2e 4051 / 3975 / 4079 3982 / 4072 / 3987
fwd + bwd e2e 6195 / 6222 / 6214 6166 / 6249 / 6243

Performance is at parity within run-to-run noise. Not tested: evoscale itself on quack 0.6.5.

🤖 Generated with Claude Code

The dW1 / dW2 grouped GEMMs contract over each expert's padded pool slot
range. The fork's seqused_k bounded that contraction to the real rows,
because the padding rows of pool and the intranode dL_do_pool are
uninitialized and 0 * NaN poisons the expert's gradient. The other operand
of each GEMM (dL_dswiglu_in, postact_a_for_dW2) already has exact-zero
padding from kernel_y_bwd's padding mask.

Instead, the backward now zeroes the padding rows of dL_do_pool and pool
right before the dW GEMMs, so padding contributes 0 * 0, and drops
seqused_k. zero_padding_rows (a Triton kernel next to the level-2
compress/expand kernels) launches one program per (expert, H-block) and
stores zeros over [block_offset[e] * tile_m + frequency[e],
block_offset[e + 1] * tile_m), the fewer than tile_m padding rows at the
tail of each expert's range. dispatch_grads never writes padding slots,
so the zeroing cannot race its tail. With no fork commit left, the test
env pins upstream quack-kernels==0.6.5 from PyPI; cutlass-dsl stays at
4.7.0. Evoscale must move to the same quack version when it picks up this
StreamEP version.

test_dw_gemm runs both dW GEMMs at the default tile configs with NaN / inf
padding on the garbage operand against a real-rows-only reference, plus a
control showing the NaN reaches dW without the zeroing. Worst per-expert
relative error 1.67e-3 over all shapes and layouts, tolerance 4e-3.

Measured on H100, quack 0.6.5, torch 2.11:
- kernels suite: 188 passed (8 files), 1 GPU.
- dist suite: 234 passed (6 files), 8 GPUs.
- internode suite: 236 passed, 4 skipped (existing level-2 empty-rank
  known bug) per node, 2 nodes x 8 GPUs.
- profile_pipeline at the default bench shape (H 3072, I 768, 256 experts,
  top-8, 8192 tokens/rank, 8 GPUs), 3 interleaved runs vs main:
  zero_padding_rows ~15 us per call (2 per backward); bwd e2e
  3982 / 4072 / 3987 us vs 4051 / 3975 / 4079 us; fwd+bwd
  6166 / 6249 / 6243 us vs 6195 / 6222 / 6214 us. Parity within noise.
  A first version that launched one program per slot cost 240 us per call
  (+5% bwd).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant