Conversation
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
@wujingyue Thanks for the PR!
I wanted to understand what is the use-case where we have unpadded scales in the mxfp8 tensor?
TE quantizer always produces padded scales in the MXFP8 Tensor. And so we should never face this issue where the scales are not padded to (128,4) or (4,128). If external framework is constructing/manipulating the MXFP8Tensor, then I would say, it is the responsibility of that framework and not TE, to pad the scales tensor.
If the external framework cannot sacrifice the performance of additional padding. We can potentially fuse the padding within the swizzling kernel in a way swizzling kernel accepts unpadded scales and fills zero manually in those unpadded locations. We have done something similar for the grouped swizzling kernel.
Sure. Have you seen the issue this PR links to? I've been adding context there because this PR is just for demo at this moment. Shall we follow up over there?
Not really -- according to #3518, quantizer itself works great with unpadded scales. But I could certainly be missing something! cc @vthumbe1503 |
|
In the issue you mentioned, custom MXFP8Tensor is being created for weight like this. I see that this is used in Megatron FSDP v2. So I see that you are dealing with weight sharding in FSDP which can be tricky since sharded tensors might not be padded?
I understand quantization works with unpadded scales. So the problem seems to be that GEMMS need swizzled scales padded. So 2 solutions can be
With the current solution, we are silently introducing a performance penalty in the framework by doing the padding, which I am hoping to avoid. |
Signed-off-by: Jingyue Wu <jingyuew@nvidia.com>
I asked my agent to one-shot it. I really don't understand what it's doing. Could you or someone from the TE team take over? @vthumbe1503 |
general_gemm()rejects compact MXFP8 scales even whenwith_gemm_swizzled_scales=False: a 64×64 tensor requires rowwise scales of(128, 4)instead of(64, 2), or columnwise scales of(4, 128)instead of(2, 64).Accept exact compact MXFP8 scale shapes in the single-tensor swizzle API and read them directly into a padded, swizzled output. A compact-input CUDA kernel uses independent input strides and fills padding with zeros, without an intermediate padding allocation or copy. The PyTorch helper allocates the required output shape. Already-padded inputs retain the existing kernel; GEMM preparation preserves the caller's buffers and unswizzled flag.
Fixes #3518 for the PyTorch single-GEMM path. Grouped swizzle is unchanged.
Validation:
The GEMM tests construct compact inputs from independently quantized reference planes to isolate swizzle/GEMM behavior. Compact in-place quantization showed separate rectangular numerical mismatches during investigation; this patch does not address those.