-
Notifications
You must be signed in to change notification settings - Fork 674
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
implement an argument to directly set ff_inner_dim #52
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,6 +124,7 @@ def __init__( | |
qk_rmsnorm = False, | ||
qk_scale = 8, | ||
ff_mult = 4, | ||
ff_inner_dim = None, | ||
attn_dropout = 0., | ||
ff_dropout = 0., | ||
use_xpos = True, | ||
|
@@ -134,7 +135,8 @@ def __init__( | |
self.norm = LayerNorm(dim) | ||
|
||
attn_inner_dim = dim_head * heads | ||
ff_inner_dim = dim * ff_mult | ||
# silently ignores ff_mult if ff_inner_dim is provided in the arguments | ||
ff_inner_dim = dim * ff_mult if not ff_inner_dim else self.ff_inner_dim | ||
self.fused_dims = (attn_inner_dim, dim_head, dim_head, (ff_inner_dim * 2)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be beneficial to add a comment explaining why |
||
|
||
self.qk_rmsnorm = qk_rmsnorm | ||
|
@@ -270,6 +272,7 @@ def __init__( | |
dim_head = 64, | ||
heads = 8, | ||
ff_mult = 4, | ||
ff_inner_dim = None, | ||
attn_dropout = 0., | ||
ff_dropout = 0., | ||
qk_rmsnorm = False, | ||
|
@@ -297,6 +300,7 @@ def __init__( | |
heads = heads, | ||
qk_rmsnorm = qk_rmsnorm, | ||
ff_mult = ff_mult, | ||
ff_inner_dim = ff_inner_dim, | ||
attn_dropout = attn_dropout, | ||
ff_dropout = ff_dropout, | ||
xpos_scale_base = rotary_xpos_scale_base, | ||
|
@@ -511,4 +515,4 @@ def forward( | |
return ret | ||
|
||
logits = rearrange(logits, 'b n c -> b c n') | ||
return F.cross_entropy(logits, labels, ignore_index = self.cross_entropy_ignore_index) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding a newline at the end of the file. This is a common convention that helps with file processing in various systems. [medium] |
||
return F.cross_entropy(logits, labels, ignore_index = self.cross_entropy_ignore_index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a check to ensure that
ff_inner_dim
is a positive integer if it is not None. This will prevent potential errors or unexpected behavior. [important]