Skip to content

Commit 133340f

Browse files
committed
fix
1 parent 1bff91d commit 133340f

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/hip_attn/v1_2/paged_hip.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -789,8 +789,8 @@ def _forward_paged_hip(
789789
)
790790
context = context.to(query.dtype)
791791
metadata = None
792-
elif using_delta_attention and (query.shape[1] > 256):
793-
if is_decode or (using_dense_prefill and (not is_decode)):
792+
elif using_delta_attention:
793+
if is_decode or (using_dense_prefill and (not is_decode)) or (query.shape[1] < 256):
794794
k_unpack = args.gather_k_from_paged_cache()
795795
v_unpack = args.gather_v_from_paged_cache()
796796

@@ -1030,12 +1030,13 @@ def _forward_paged_hip(
10301030
elif (force_dense_decode and is_decode) or (using_dense_prefill and (not is_decode)):
10311031
if is_decode:
10321032
if args.using_extend:
1033-
args.sliding_window_size = 777
1033+
args_dense = args.clone()
1034+
args_dense.sliding_window_size = 777
10341035
context, metadata = dual_stage_quadratic_hip_attention(
10351036
(query * sm_scale).to(query.dtype),
10361037
k,
10371038
v,
1038-
args=args,
1039+
args=args_dense,
10391040
cached_metadata=cached_metadata,
10401041
)
10411042
else:
@@ -1162,13 +1163,14 @@ def _forward_paged_hip(
11621163
)
11631164
context_sparse = context.to(query.dtype)
11641165

1165-
args.sliding_window_size = 777
1166-
args.position_ids = position_ids[:, -last_dense:]
1166+
args_dense = args.clone()
1167+
args_dense.sliding_window_size = 777
1168+
args_dense.position_ids = position_ids[:, -last_dense:]
11671169
context_dense, metadata = dual_stage_quadratic_hip_attention(
11681170
(query[:, -last_dense:, :, :] * sm_scale).to(query.dtype),
11691171
k,
11701172
v,
1171-
args=args,
1173+
args=args_dense,
11721174
cached_metadata=cached_metadata,
11731175
)
11741176
context_dense = context_dense.to(query.dtype)

0 commit comments

Comments
 (0)