Add support for fused Q Up-Proj GEMM/RoPE/Quant. - #3303
Conversation
Greptile SummaryThe PR introduces a Blackwell-targeted fused MLA Q up-projection, RoPE, and MXFP8 quantization path and integrates its pre-quantized output with fused attention.
Confidence Score: 5/5The PR appears safe to merge based on the eligible follow-up findings available in this review. No blocking failure remains. Important Files Changed
Sequence DiagramsequenceDiagram
participant Model
participant Fusion as Fused MLA Q Up-Proj
participant Quant as MXFP8 Layout Preparation
participant DPA as DotProductAttention
participant cuDNN as cuDNN Fused Attention
Model->>Fusion: Q-LORA activation, weight, cos, sin
Fusion->>Fusion: GEMM + per-head RoPE + MXFP8 quantization
Fusion-->>Quant: Quantized Q and saved activation
Model->>Quant: K and V
Quant->>Quant: Quantize and transpose/swizzle scales
Quant->>DPA: Pre-quantized Q, K, V
DPA->>cuDNN: MXFP8 fused-attention request
cuDNN-->>DPA: Attention output
DPA-->>Model: Output and backward gradients
Reviews (11): Last reviewed commit: "Merge branch 'main' into qrope_fusion" | Re-trigger Greptile |
sudhakarsingh27
left a comment
There was a problem hiding this comment.
- Commented feedback inline
- Pls fix DCA here and in the other PR
- Also, I wonder if you've measured perf for
mxfp8_quantize_onlyand its swizzle counterpart. I feel they could be further optimized as I see a lot of for loops.
This commit add support for fusing the GEMM in the Q Up Proj step of DeepseekV3 training with the following RoPE and MXFP8 quantization operations. This uses a custom kernel from cudnn_frontend, and supports both 16-bit projection and mxfp8 projection. Signed-off-by: Chase Block <cblock@nvidia.com>
for more information, see https://pre-commit.ci
Signed-off-by: Chase Block <cblock@nvidia.com>
for more information, see https://pre-commit.ci
Signed-off-by: Chase Block <cblock@nvidia.com>
fd21ddf to
5f90db7
Compare
This commit adds support for fusing the q up proj gemm with the following rope and mxfp8 quantization operations. Relies on the TE functionality from NVIDIA/TransformerEngine#3303 Signed-off-by: Chase Block <cblock@nvidia.com>
Addressed inline feedback. DCA fixed. I haven't explicitly modeled the perf of these two functions, but they were essentially extracted from the existing |
|
/te-ci pytorch |
mxfp8_quantize_fast_path. Signed-off-by: Chase Block <cblock@nvidia.com>
Signed-off-by: Chase Block <cblock@nvidia.com>
e529067 to
417d233
Compare
Signed-off-by: Chase Block <cblock@nvidia.com>
a4178fd to
dc89f01
Compare
for more information, see https://pre-commit.ci
Signed-off-by: Chase Block <cblock@nvidia.com>
for more information, see https://pre-commit.ci
Signed-off-by: Chase Block <cblock@nvidia.com>
for more information, see https://pre-commit.ci
|
|
||
| from cuda.bindings import driver as cuda | ||
|
|
||
| stream = cuda.CUstream(torch.cuda.current_stream().cuda_stream) |
There was a problem hiding this comment.
should this be the same stream as the input tensor's?
These tests really belong in Megatron. Signed-off-by: Chase Block <cblock@nvidia.com>
This PR adds support for fusing the GEMM in the Q Up Proj step of DeepseekV3 training with the following RoPE and MXFP8 quantization operations. This uses a custom kernel from cudnn_frontend, and supports both 16-bit projection and mxfp8 projection.
Type of change
Checklist: