Repository navigation
Conversation
…rch.compile Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
pggPL
force-pushed
the
mha_torch_compile
branch
from
December 1, 2026 08:58
4eef1d6 to
332b0e4
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Enable
torch.compile(fullgraph=True)for single-GPU FP16/BF16MultiheadAttention, including self/cross-attention, GQA, input LayerNorm/RMSNorm, and rotary embeddings in SBHD/BSHD layouts across the FlashAttention 2, fused cuDNN, and unfused backends.Includes and builds on split-parameter
torch.compilesupport (#3623), extended toLayerNormLinear, so separate Q/K/V parameters sharing adjacent storage compile without a concatenation copy while disjoint parts fall back totorch.cat. Unpacked GQA/RoPE paths ensure contiguous Q/K/V inputs. Q/K normalization, attention checkpointing, FP8 attention, and context parallelism remain unsupported by the underlying compile paths.Type of change
Changes
torch.compilesupport (dynamo/concat.py,TENSOR_LISTcustom-op support,prepare_parameter,Linear) and extend it toLayerNormLinear, with unit and numerics tests.MultiheadAttention.forwardwhen FP8 is disabled.torch.splitfor Q/K/V splitting undertorch.compile, ensuring contiguous unpacked Q/K/V tensors beforeDotProductAttention.tex.fused_rope_forward/tex.fused_rope_backward) astorch.library.custom_ops (te_attention::rope_fwdandte_attention::rope_bwd) with fake kernels while preservingFusedRoPEFunc.torch.compile(fullgraph=True)support and limitations onMultiheadAttention.torch.compiletests intests/pytorch/test_torch_compile.pycovering split-parameterLinear/LayerNormLinear,MultiheadAttention(self/cross, input LayerNorm/RMSNorm, fused/separate QKV params, GQA, RoPE, extra outputs, FP16/BF16, SBHD/BSHD, all three backends, CUDA Graphs train/eval), and standalone fused RoPE.Checklist: