fix(CP, FA): the conditional logic in the FA version contains a vulnerability when processing the output of Flash Attn forward pass#2825
Conversation
…he conditional logic in the FA version contains a vulnerability, fix it
Greptile SummaryThis PR fixes a conditional logic bug in three symmetric locations within Confidence Score: 5/5Safe to merge — the fix is minimal, correct, and consistently applied across all three affected call sites. All three changes follow the same correct pattern: the No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[flash_attn_fwd returns fa_outputs] --> B{use_flash_attn_3?}
B -- Yes --> C[else branch
out = fa_outputs 0
lse = fa_outputs 1
rng = None]
B -- No --> D{fa_utils.v2_7_0_plus?}
D -- No
Old FA2 format --> E[if branch
out = fa_outputs 4
lse = fa_outputs 5
rng = fa_outputs 7]
D -- Yes
New FA2 format --> F[else branch
out = fa_outputs 0
lse = fa_outputs 1
rng = fa_outputs 3]
Reviews (1): Last reviewed commit: "fix(CP, FA): when processing the output ..." | Re-trigger Greptile |
Description
The conditional logic in the FA version contains a vulnerability when processing the output of Flash Attn forward pass, this maybe caused accidentally.
For example, when I only install FA3, and FA2 is totally not installed, something is wrong.

Fixes # (issue)
Type of change
Changes
Please list the changes introduced in this PR:
Checklist: