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

precision issue #7

Open
dyhBUPT opened this issue Aug 19, 2024 · 3 comments
Open

precision issue #7

dyhBUPT opened this issue Aug 19, 2024 · 3 comments

Comments

@dyhBUPT
Copy link

dyhBUPT commented Aug 19, 2024

Hi, thanks for your work. I'm trying your fa2-cm but it raises error because of the following assertion:

assert do.is_contiguous()
assert q.stride() == k.stride() == v.stride() == o.stride() == do.stride()

I solve this problem by using .contiguous() as follows:

q = q.contiguous()
k = k.contiguous()
v = v.contiguous()
o = o.contiguous()
do = do.contiguous()

Another error is, it only supports fp16 inputs, so I convert q/k/v from fp32 to fp16, and convert the out from fp16 to fp32 after fa2.

After these corrections, I can run fa2-cm normally.
However, the results seem bad, because the gradients explode.
I want to ask the possible reasons. It's because of my aforementioned modifications?

Looking forward to your reply~

@alexzhang13
Copy link
Owner

Hi,

For FP32 support, I need to make a minor edit. This was attempted by someone else earlier, but their code was buggy so I had to revert it. I will make this edit later this week and let you know!

@yyhyyh17
Copy link

yyhyyh17 commented Sep 5, 2024

Hi,

For FP32 support, I need to make a minor edit. This was attempted by someone else earlier, but their code was buggy so I had to revert it. I will make this edit later this week and let you know!

Do you have any ideas why fp32 will produce wrong results in backward?

@alexzhang13
Copy link
Owner

Oh it shouldn't, basically I specified in the code that things should be FP16, which was taken from the original Triton example. It should take the dtype of the tensors that are being fed in instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants