[ROCm] Route dense CP softmax-LSE correction through a native kernel - #708
Open
zjin-lcf wants to merge 1 commit into
Open
[ROCm] Route dense CP softmax-LSE correction through a native kernel#708zjin-lcf wants to merge 1 commit into
zjin-lcf wants to merge 1 commit into
Conversation
The context-parallel softmax-LSE merge (flash_attn_fwd_softmax_lse_correction and its second-half variant) ran through @jit_fuser / torch.compile on ROCm. Dynamo can hold more than one compiled variant of these functions, and on ROCm the variants disagree by ~1 ULP because libdevice.log1p contracts differently under different Triton launch configurations (issue ROCm#693). A reference model and an actor model built from the same checkpoint then diverge. Add a fixed-configuration native kernel for the dense layout, mirroring the existing THD path: * nvte_cp_lse_correction C API + context_parallel::lse_correction kernel * tex.lse_correction PyTorch binding * route flash_attn_fwd_softmax_lse_correction and the second-half variant through the native kernel on ROCm (IS_HIP_EXTENSION), leaving the CUDA path unchanged The native kernel returns identical bits for every launch configuration, so the merge is bitwise-reproducible. Add regression tests asserting bitwise stability of both correction functions across intervening shapes. Fixes: ROCm#693
zjin-lcf
requested review from
ipanfilo,
wangye805 and
wenchenvincent
as code owners
August 19, 2026 21:27
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.
The context-parallel softmax-LSE merge (flash_attn_fwd_softmax_lse_correction and its second-half variant) ran through @jit_fuser / torch.compile on ROCm. Dynamo can hold more than one compiled variant of these functions, and on ROCm the variants disagree by ~1 ULP because libdevice.log1p contracts differently under different Triton launch configurations (issue #693). A reference model and an actor model built from the same checkpoint then diverge.
Add a fixed-configuration native kernel for the dense layout, mirroring the existing THD path:
The native kernel returns identical bits for every launch configuration, so the merge is bitwise-reproducible. Add regression tests asserting bitwise stability of both correction functions across intervening shapes.
Fixes: #693