Add MoE blockwise FP8 DTensor and compile coverage#4545
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/4545
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New FailuresAs of commit 9140d1c with merge base cb76f29 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
ae813e3 to
b52db8f
Compare
b52db8f to
0db5f7f
Compare
|
@claude review |
|
Claude finished @iamzainhuda's task in 8m 34s —— View job PR Review: Add MoE blockwise FP8 DTensor TP support
Overall this is a well-structured change. The DTensor plumbing is cleanly factored into Correctness & design1. Lost kernel-contract documentation in the wgrad custom op ( 2. Output shape now derived from scale shapes ( 3. 4. Duplicate 5. Sharding maps look internally consistent. I cross-checked the swap between the DeepGEMM and non-DeepGEMM quant ops: non-DeepGEMM forward ( Minor / nits
Tests
No blocking issues from my read; (1) and (5) are the most important to address (restore the contract comment; the sharding logic looks right). The lack of CI coverage for the TP path is the main risk. |
|
@claude review this PR again |
|
Claude finished @iamzainhuda's task in 2m 13s —— View job PR Re-Review: Add MoE blockwise FP8 DTensor TP support
The branch is still at a single commit ( Status of prior feedback1. (Still open) Missing 2. (Partially addressed) Output shape derived from scale shapes — 3. (Resolved, no action) 4. (Addressed) Emulated sharding rule comments — 5. (Confirmed correct) DeepGEMM vs non-DeepGEMM sharding swap — re-verified: Still-open minor items
Fresh observations
No blocking correctness issues from my read; the sharding logic still checks out. The top action item remains (1) — restoring the wgrad kernel-contract comment — followed by the config-validation and CI-coverage suggestions. |
| @@ -0,0 +1,28 @@ | |||
| # Copyright (c) Meta Platforms, Inc. and affiliates. | |||
There was a problem hiding this comment.
https://github.com/pytorch/ao/tree/main/torchao/testing is the right top level dir for this, test utilities should not be mixed with product code. Same for other files in this PR
There was a problem hiding this comment.
makes sense, moved. kept the suite-specific builders local under test/prototype
| # DTensor sharding can materialize local shards of a logically column-major | ||
| # operand with regular row-major strides. Preserve the logical values while | ||
| # restoring the physical RHS layout required by _scaled_mm_v2. | ||
| return x.transpose(-2, -1).contiguous().transpose(-2, -1) |
There was a problem hiding this comment.
hmm, this is unexpected. Do we know why this is needed?
There was a problem hiding this comment.
at the blockwise_scaled_mm custom-op boundary: DTensor local dispatch / redistribution can materialize the local RHS shard in a regular contiguous layout even when the logical operand is the transposed FP8 RHS produced by the quantizer, and _scaled_mm_v2 requires a physically column-major RHS
There was a problem hiding this comment.
i actually saw this issue in a job i ran internally, i can make this fix in a seperate PR if thats cleaner
|
do we need TP for experts? what's the motivation for that? |
Summary
torch.compilecan hit the production kernelsthis keeps the MoE path aligned with the blockwise FP8 linear DTensor design: shared DTensor helpers handle local tensor unwrap/rewrap, replicated metadata, placement checks, and common test parity utilities. The grouped MoE code still exercises the quantized training path rather than a BF16-only fallback.
Part of #3290
Tests
For the broader related coverage: