Skip to content

[varlen_attn] change is_causal to window_size - #2267

Merged
tianyu-l merged 1 commit into
mainfrom
varlen_is_causal
Jan 23, 2026
Merged

tianyu-l merged 1 commit into
mainfrom
varlen_is_causal

Conversation

@liangel-02

Copy link
Copy Markdown
Contributor

is_causal flag has been deprecated in varlen_attn, use window_size = [-1, 0] instead, see this PR

Test
Screenshot 2026-01-21 at 11 55 59 AM

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jan 21, 2026
@liangel-02 liangel-02 changed the title [varlen_attn] change is_casaul to window_size [varlen_attn] change is_causalto window_size Jan 21, 2026
@liangel-02 liangel-02 changed the title [varlen_attn] change is_causalto window_size [varlen_attn] change is_causal to window_size Jan 21, 2026

@fegin fegin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We will need to wait for nightly pytorch has window_size.

Comment thread torchtitan/models/attention.py Outdated
max_k,
is_causal=True,
scale=scale,
window_size=[-1, 0],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we add descriptions to describe what -1 means and what 0 means? I checked the API's docstring, but it is still not very clear to me.

@liangel-02
liangel-02 force-pushed the varlen_is_causal branch 2 times, most recently from 621b609 to 5709bba Compare January 22, 2026 17:36

@tianyu-l tianyu-l left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CI fails because of is_causal is already deprecated. Let's test again and see if this PR is ready.

scale=scale,
# causal attention, token looks at all tokens before it
# and itself but no tokens after it
window_size=(-1, 0),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's still not clear what -1 and 0 means. Maybe explain it here or at least add a link to documents.

@tianyu-l tianyu-l left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sgtm

@tianyu-l
tianyu-l merged commit 5621112 into main Jan 23, 2026
@tianyu-l
tianyu-l deleted the varlen_is_causal branch January 23, 2026 23:23
xrsrke pushed a commit to NousResearch/torchtitan that referenced this pull request Feb 13, 2026
`is_causal` flag has been deprecated in `varlen_attn`, use `window_size
= [-1, 0]` instead, see [this
PR](pytorch/pytorch#172245)

*Test*
<img width="1225" height="496" alt="Screenshot 2026-01-21 at 11 55
59 AM"
src="https://github.com/user-attachments/assets/125c56af-76ed-4f6f-a433-da4d9a631dab"
/>
TXacs pushed a commit to McmillanTAC/torchtitan that referenced this pull request Apr 13, 2026
`is_causal` flag has been deprecated in `varlen_attn`, use `window_size
= [-1, 0]` instead, see [this
PR](pytorch/pytorch#172245)

*Test*
<img width="1225" height="496" alt="Screenshot 2026-01-21 at 11 55
59 AM"
src="https://github.com/user-attachments/assets/125c56af-76ed-4f6f-a433-da4d9a631dab"
/>
ACharacterInASimulation pushed a commit to ACharacterInASimulation/torchtitan that referenced this pull request Apr 21, 2026
`is_causal` flag has been deprecated in `varlen_attn`, use `window_size
= [-1, 0]` instead, see [this
PR](pytorch/pytorch#172245)

*Test*
<img width="1225" height="496" alt="Screenshot 2026-01-21 at 11 55
59 AM"
src="https://github.com/user-attachments/assets/125c56af-76ed-4f6f-a433-da4d9a631dab"
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/8gpu CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants