Skip to content

[TLX] Update TLX tutorials to support causal for fwd#692

Closed
njriasan wants to merge 4 commits into
facebookexperimental:mainfrom
njriasan:njriasan/causal_fa
Closed

[TLX] Update TLX tutorials to support causal for fwd#692
njriasan wants to merge 4 commits into
facebookexperimental:mainfrom
njriasan:njriasan/causal_fa

Conversation

@njriasan
Copy link
Copy Markdown
Contributor

Updates the implementations to all have a causal variant.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 24, 2025
import triton
import triton.language as tl
import triton.language.extra.tlx as tlx
from triton.tools.tensor_descriptor import TensorDescriptor
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of this is automatic formatting from pre-commit + vscode. Personally I think we should keep it so this doesn't recur when we update this again for H-DIM 64.

p = p.to(ref_dtype)
# p = torch.exp(p)
ref_out = torch.matmul(p, v).half()
ref_out = torch.nn.functional.scaled_dot_product_attention(q, k, v, scale=sm_scale, is_causal=causal)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Borrowed this from the gluon implementation. Seems to be more robust.

@njriasan njriasan requested a review from htyu November 24, 2025 19:21
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Nov 24, 2025

@njriasan has imported this pull request. If you are a Meta employee, you can view this in D87807126.

Copy link
Copy Markdown
Contributor

@htyu htyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for working on this!

@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Nov 24, 2025

@njriasan merged this pull request in fd6c6b4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. Merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants