Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add causal optimizations #464

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions iree/turbine/kernel/wave/templates/extend_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import math
import torch
from typing import Optional
import sympy


def get_extend_attention_kernel(
Expand Down Expand Up @@ -231,6 +232,11 @@ def first_loop(

res_max, res_sum, res_mm = first_loop

if is_causal:
seq_len_extend = tkw.apply_expr(
seq_len_extend,
lambda x: sympy.Min(x, (WORKGROUP_0 + 1) * SEQ_TILE_SIZE),
)
tkw.set_symbol(N_KV, seq_len_extend)

@tkw.reduction(N_KV, init_args=[res_max, res_sum, res_mm])
Expand Down
Loading