Repository navigation
[PyTorch] Add triton requirement - #2490
Conversation
Signed-off-by: Kirthi Shankar Sivamani <ksivamani@nvidia.com>
|
/te-ci pytorch |
Greptile OverviewGreptile SummaryAdded
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant Setup as setup.py
participant BuildTools as build_tools/pytorch.py
participant PyPI
participant TE as TransformerEngine
User->>Setup: pip install transformer_engine_torch
Setup->>BuildTools: Call install_requirements()
BuildTools-->>Setup: Return dependency list including triton
Setup->>PyPI: Install triton package
PyPI-->>Setup: triton installed
Setup->>TE: Build and install TransformerEngine
TE->>TE: Import triton modules
Note over TE: Uses triton for:<br/>- Permutation kernels<br/>- Cross entropy<br/>- Padding operations<br/>- Custom GPU kernels
TE-->>User: Package ready to use
|
There was a problem hiding this comment.
Additional Comments (1)
-
build_tools/pytorch.py, line 17 (link)syntax: incorrect package name - should be
triton, notpytorch-tritonthe JAX setup in
build_tools/jax.py:23correctly usestritonas a dependency. the package on PyPI is namedtriton, notpytorch-triton
1 file reviewed, 1 comment
|
/te-ci pytorch |
Signed-off-by: Kirthi Shankar Sivamani <ksivamani@nvidia.com>
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Additional Comments (1)
-
build_tools/pytorch.py, line 25 (link)style: No version constraint specified for
triton. The codebase has compatibility code for triton>=3.5.0 (seetransformer_engine/pytorch/triton/permutation.py:21), so consider adding a minimum version constraint.
1 file reviewed, 1 comment
|
/te-ci pytorch |
|
/te-ci pytorch |
Review asked whether the -1 to None translation should sit behind a version gate keyed on the FA4 release that changed the sentinel. It does not need one, and the reason is worth recording where the next reader will look. Transcribing flash-attention's _resolve_causal_local_window from before NVIDIA#2490 (interface.py @ 59cf537812) and after it, and running every (causal, window) pair TE emits through both: mask type b11 as-is b11 normalized post-2490 as-is causal CAUSAL CAUSAL LOCAL left=-1 right=0 causal_bottom_right CAUSAL CAUSAL LOCAL left=-1 right=0 no_mask FULL FULL FULL sliding window LOCAL 511/0 LOCAL 511/0 LOCAL 511/0 Normalizing changes nothing on the older release, because the old code reaches the same resolved state from (-1, 0) by widening that the new code reaches from (None, 0) directly. So the translation is inert before the change and corrective after it, with no version boundary to get wrong. All four entry points funnel through that one resolver, on both releases, so the trace covers them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
FA4 returns an all-zero output for causal attention on SM100, silently. No
exception, no warning, finite values, every element zero. Measured against a
float64 reference on B200, with no context parallelism involved:
flash_attn_func(q, k, v, causal=True, window_size=(-1, 0))
out.abs().max() = 0.0 relerr = 1.000e+00
flash_attn_func(q, k, v, causal=True, window_size=(None, None))
out.abs().max() = 3.453125 relerr = 2.046e-03
TE normalizes an unbounded window side to -1; FA4 spells it None. Until
flash-attention NVIDIA#2490 a shim widened any pair summing below zero to full
attention, so TE's (-1, 0) was always erased and causal= alone set the mask.
NVIDIA#2490 narrowed that to pairs where both bounds are negative, so (-1, 0) now
survives as a literal band of [row + 1, row] -- empty. The kernel returns zeros
and an all -inf LSE.
Normalizing negative bounds to None at the four FA4 entry points, rather than at
the ~20 sites that build these kwargs: those sites are shared with FA2 >= 2.7 and
FA3, where -1 is the correct spelling, so fixing them in place would mean forking
every one on use_flash_attn_4.
All four entry points, not just the two used by context parallelism. The non-CP
path calls flash_attn_func/flash_attn_varlen_func; CP calls
_flash_attn_fwd/_flash_attn_bwd. Covering one pair is worse than covering
neither, because run_attention_with_cp.py grades a CP run against a non-CP run of
the same backend: with both sides zero the comparison agrees, and correcting one
side alone makes the fix present as a regression. That is not hypothetical --
it is what an earlier partial attempt did.
Three reasons CI could not see this, all still worth addressing separately:
NVTE_FLASH_ATTN_V4=0 in the distributed suite, a flash-attn-4 pin predating
NVIDIA#2490, and the self-referential comparison above, which cannot detect any error
affecting CP and non-CP equally.
The new test anchors to a float64 reference rather than to another backend, and
pins FlashAttention -- cuDNN FusedAttention wins selection for the shape under
test and would mask the defect entirely.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: Nitin Vegesna <nvegesna@nvidia.com>
Review asked whether the -1 to None translation should sit behind a version gate keyed on the FA4 release that changed the sentinel. It does not need one, and the reason is worth recording where the next reader will look. Transcribing flash-attention's _resolve_causal_local_window from before NVIDIA#2490 (interface.py @ 59cf537812) and after it, and running every (causal, window) pair TE emits through both: mask type b11 as-is b11 normalized post-2490 as-is causal CAUSAL CAUSAL LOCAL left=-1 right=0 causal_bottom_right CAUSAL CAUSAL LOCAL left=-1 right=0 no_mask FULL FULL FULL sliding window LOCAL 511/0 LOCAL 511/0 LOCAL 511/0 Normalizing changes nothing on the older release, because the old code reaches the same resolved state from (-1, 0) by widening that the new code reaches from (None, 0) directly. So the translation is inert before the change and corrective after it, with no version boundary to get wrong. All four entry points funnel through that one resolver, on both releases, so the trace covers them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Nitin Vegesna <nvegesna@nvidia.com>
Description
Add requirement for triton.
Type of change
Changes
Checklist: