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

Fix pairwise attention comparison in test #737

Merged
merged 4 commits into from
Nov 15, 2023
Merged
Changes from 2 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
7 changes: 5 additions & 2 deletions tests/test_flash_triton_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_attn_impl(attn_impl_0: str,

cfg = om.create({
'attn_impl': 'flash',
'd_model': 128,
'd_model': 64,
'n_heads': 4,
'attn_pdrop': 0,
'clip_qkv': clip_qkv,
Expand All @@ -88,6 +88,7 @@ def test_attn_impl(attn_impl_0: str,

cfg.attn_impl = attn_impl_0
attn0 = attention.ATTN_CLASS_REGISTRY[attn_type](**cfg).to(device)
cfg.attn_impl = attn_impl_1
attn1 = attention.ATTN_CLASS_REGISTRY[attn_type](**cfg).to(device)

attn1.load_state_dict(attn0.state_dict())
Expand Down Expand Up @@ -182,7 +183,9 @@ def gen_bias(attn_impl: str):
assert p.grad is not None
assert tp.grad is not None
assert allclose_helper(p, tp)
sashaDoubov marked this conversation as resolved.
Show resolved Hide resolved
assert allclose_helper(p.grad, tp.grad)
# Increased tolerance due to rope_impl=hf having 1 failing element
# in the torch vs. triton, clip=True, qk_ln=True case
assert allclose_helper(p.grad, tp.grad, atol=2.e-2, rtol=2.e-2)

assert x0.grad is not None
assert x1.grad is not None
Expand Down
Loading