Enable Weight Preswizzling only when Swizzle fusion is available#3232
Enable Weight Preswizzling only when Swizzle fusion is available#3232vthumbe1503 wants to merge 10 commits into
Conversation
Signed-off-by: Varun Thumbe <vthumbe@nvidia.com>
Signed-off-by: Varun Thumbe <vthumbe@nvidia.com>
Greptile SummaryThis PR fixes a CUDA graph stale pointer bug by conditionally enabling weight preswizzling only when the fused quantize+swizzle kernel is actually available. The previous code unconditionally set
Confidence Score: 5/5Safe to merge — the change narrows the set of cases where preswizzling is enabled, directly fixing the CUDA graph stale pointer bug without regressing the aligned-shape fast path. The logic in No files require special attention. The most nuanced change is in Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[forward pass called] --> B{primary_weights_in_fp8?}
B -- yes --> C[optimize_for_gemm = False]
B -- no --> D{isinstance NVFP4Quantizer?}
D -- no --> E[optimize_for_gemm = True\ne.g. MXFP8]
D -- yes --> F{quantizer.with_rht?}
F -- yes --> G{arch >= SM10.0 AND\nrows%64==0 AND cols%128==0?}
G -- yes --> H[optimize_for_gemm = True]
G -- no --> C
F -- no --> I{arch >= SM10.0 AND\nwith_2d_quantization AND\nnot row_scaled AND\nnot 4over6 AND\nrows%128==0 AND cols%128==0?}
I -- yes --> H
I -- no --> C
C --> J[weight quantized without preswizzle]
E --> K[weight quantized with preswizzle]
H --> K
Reviews (4): Last reviewed commit: "Merge branch 'main' into optimize_for_ge..." | Re-trigger Greptile |
Signed-off-by: Varun Thumbe <vthumbe@nvidia.com>
Signed-off-by: Varun Thumbe <vthumbe@nvidia.com>
for more information, see https://pre-commit.ci
Signed-off-by: Varun Thumbe <vthumbe@nvidia.com>
…3/TransformerEngine into optimize_for_gemm_conditional
|
/te-ci pytorch |
|
/te-ci pytorch |
Description
#3190 recently fixed a bug where enabled nvfp4 2d quantize swizzle fusion for the weights. Enabling this was needed, since without swizzle fusion, if we cache swizzle weights, it causes stale pointer issue with cuda graphs.
However, swizzle fusion isnt available in all nvfp4 quantization cases. And so this PR makes sure to disable optimize_for_gemm for the cases where the fusion isnt even available.
Fixes #3220 (issue)
Type of change
Changes
Please list the changes introduced in this PR:
Checklist: