Pass the expert weight, not its transpose, to the grouped-mm seam - #4368
Pass the expert weight, not its transpose, to the grouped-mm seam#4368anijain2305 wants to merge 1 commit into
Conversation
12b77e7 to
c6f247b
Compare
c6f247b to
3395723
Compare
|
|
||
| def _grouped_mm( | ||
| self, *, A: torch.Tensor, B_t: torch.Tensor, offs: torch.Tensor | ||
| self, *, A: torch.Tensor, weight_ENK: torch.Tensor, offs: torch.Tensor |
There was a problem hiding this comment.
this rename is confusing, because it conflicts with existing suffix vocab https://github.com/pytorch/torchtitan/blob/main/torchtitan/models/common/moe.py#L25
There was a problem hiding this comment.
begging for a non-conflicting name and then we can land
|
@claude The PR summary states the motivation, which I couldn't visualize / digest. Could you give an example where previous representation is problematic. |
|
Claude finished @tianyu-l's task in 1m 28s —— View job Concrete example: why
|
3395723 to
3755d8c
Compare
3755d8c to
4190e67
Compare
4190e67 to
0eeda35
Compare
0eeda35 to
5fee0d6
Compare
5fee0d6 to
b8dcfbf
Compare
b8dcfbf to
7d7c760
Compare
7d7c760 to
b09d0fc
Compare
b09d0fc to
5724265
Compare
5724265 to
7eb5e17
Compare
GroupedExperts._grouped_mm is the override point low-precision variants use to swap in a scaled grouped GEMM. It currently receives B_t, the already transposed weight, which is enough for a variant that quantizes on every call but not for one whose quantized representation is owned by the weight's FSDP unshard lifetime: that representation is keyed off the stored (experts, out_features, in_features) orientation, and the transpose has erased which parameter it came from. Pass weight_ENK and move the transpose inside the seam. Behavior is unchanged; the base implementation transposes exactly as before. Update every caller: the common, gpt_oss, and kimi_k3 experts, the fused SwiGLU override, and the float8 converter's override. The fused SwiGLU case reshapes its 4D w13 parameter to the (E, 2F, D) grouped weight first, which the seam then transposes.
7eb5e17 to
86223c4
Compare
Summary
GroupedExperts._grouped_mmis the seam low-precision variants override to swap in a scaled grouped GEMM. It currently receivesB_t— the already-transposed weight. Pass the weight in its stored orientation instead, and do the transpose inside the seam.Why
B_tis enough for a variant that quantizes on every call, which is what the float8 and MXFP8 converters do today. It is not enough for one whose quantized representation is owned by the weight's FSDP unshard lifetime: that representation is keyed off the stored(experts, out_features, in_features)orientation, and the transpose has already erased which parameter it came from.Split out of #4344, which needs this, so the mechanical refactor is reviewable on its own.
Scope
No behavior change — the base implementation transposes exactly as before.
Callers updated: the common, gpt_oss, and kimi_k3 experts, the fused SwiGLU override, and the float8 converter's override. The fused SwiGLU case reshapes its 4D
w13parameter into the(E, 2F, D)grouped weight first, which the seam then transposes.