cyx-6 commented on code in PR #14907:
URL: https://github.com/apache/tvm/pull/14907#discussion_r1201664099
##########
python/tvm/relax/op/nn/nn.py:
##########
@@ -1035,13 +1036,32 @@ def attention(
a 4-D tensor ending with seq_len_kv, and broadcastable to
(batch_size, num_head, seq_len, seq_len_kv).
- scale: Optional[FloatImm]
- The custom scale applied before the softmax. The default value is 1 /
sqrt(head_dim).
+ causal_mask: Optional[str]
+ The optional causal mask, i.e. 'TopLeft' and 'BottomRight'.
+ For example, with seq_len = 4, seq_len_kv = 2,
+ mask for 'TopLeft':
+ [[1, 0],
+ [1, 1],
+ [1, 1],
+ [1, 1]]
+ mask for 'BottomRight':
+ [[1, 1],
+ [1, 1],
+ [1, 1],
+ [1, 1]]
Review Comment:
It is wierd. Because refer to the unit test
`test_codegen_cutlass.py::test_attention_causal_offload`, the result between
cutlass and numpy mismatches when we use
```
[[0, 0],
[0, 0],
[1, 0],
[1, 1]]
```
In other word, in cutlass impl, the "BottomRight" means `np.tril(*,
k=abs(seq_len - seq_len_kv))`, rather than `k=seq_len - seq_len_kv` or vice
versa. I have no idea if cutlass impl is correct.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]