"vscode:/vscode.git/clone" did not exist on "d6522e28732fd14a926440ef5f315e6a8e13792c"
Unverified Commit 95395837 authored by Ivan Dolgov's avatar Ivan Dolgov Committed by GitHub
Browse files

XLNet Bug when training with apex 16-bit precision (#6567)



* xlnet fp16 bug fix

* comment cast added

* Update modeling_xlnet.py
Co-authored-by: default avatarKevin Canwen Xu <canwenxu@126.com>
parent 505f2d74
...@@ -446,7 +446,8 @@ class XLNetRelativeAttention(nn.Module): ...@@ -446,7 +446,8 @@ class XLNetRelativeAttention(nn.Module):
v_head_h = torch.einsum("ibh,hnd->ibnd", cat, self.v) v_head_h = torch.einsum("ibh,hnd->ibnd", cat, self.v)
# positional heads # positional heads
k_head_r = torch.einsum("ibh,hnd->ibnd", r, self.r) # type casting for fp16 support
k_head_r = torch.einsum("ibh,hnd->ibnd", r.type(self.r.dtype), self.r)
# core attention ops # core attention ops
attn_vec = self.rel_attn_core( attn_vec = self.rel_attn_core(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment