Skip to content

Commit

Permalink
bias
Browse files Browse the repository at this point in the history
  • Loading branch information
mvpatel2000 committed Sep 25, 2023
1 parent 2a4d56c commit 6e89ab5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
12 changes: 6 additions & 6 deletions llmfoundry/models/layers/attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def __init__(
norm_type: str = 'low_precision_layernorm',
fc_type: str = 'torch',
device: Optional[str] = None,
no_bias: bool = False,
bias: bool = True,
):
super().__init__()

Expand Down Expand Up @@ -452,7 +452,7 @@ def __init__(
self.attn_dropout_p = attn_pdrop

fc_kwargs = {
'bias': not no_bias,
'bias': bias,
}
if fc_type != 'te':
fc_kwargs['device'] = device
Expand Down Expand Up @@ -560,7 +560,7 @@ def __init__(
norm_type: str = 'low_precision_layernorm',
fc_type: str = 'torch',
device: Optional[str] = None,
no_bias: bool = False
bias: bool = True
):
super().__init__(
d_model=d_model,
Expand All @@ -574,7 +574,7 @@ def __init__(
norm_type=norm_type,
fc_type=fc_type,
device=device,
no_bias=no_bias,
bias=bias,
)


Expand All @@ -597,7 +597,7 @@ def __init__(
norm_type: str = 'low_precision_layernorm',
fc_type: str = 'torch',
device: Optional[str] = None,
no_bias: bool = False
bias: bool = True,
):
super().__init__(
d_model=d_model,
Expand All @@ -611,7 +611,7 @@ def __init__(
norm_type=norm_type,
fc_type=fc_type,
device=device,
no_bias=no_bias,
bias=bias,
)


Expand Down
3 changes: 2 additions & 1 deletion llmfoundry/models/layers/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(
fc_type=fc_type,
device=device,
**attn_config_subset_for_attn_class,
no_bias=no_bias,
bias=not no_bias,
)
self.norm_2 = None
if not getattr(FFN_CLASS_REGISTRY[ffn_config['ffn_type']], '_has_norm',
Expand All @@ -83,6 +83,7 @@ def __init__(
d_model=d_model,
expansion_ratio=expansion_ratio,
device=device,
bias=not no_bias,
**ffn_config,
)
self.resid_attn_dropout = nn.Dropout(resid_pdrop)
Expand Down
10 changes: 5 additions & 5 deletions llmfoundry/models/layers/ffn.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def __init__(
expansion_ratio: int,
fc_type: str = 'torch',
device: Optional[str] = None,
no_bias: bool = False,
bias: bool = True,
):
super().__init__()
fc_kwargs = {
'bias': not no_bias,
'bias': bias,
}
if fc_type != 'te':
fc_kwargs['device'] = device
Expand Down Expand Up @@ -63,7 +63,7 @@ def build_ffn(
expansion_ratio: int,
fc_type: str = 'torch',
device: Optional[str] = None,
no_bias: bool = False,
bias: bool = True,
**kwargs: Any,
) -> nn.Module:
ffn_type = kwargs.pop('ffn_type')
Expand All @@ -76,14 +76,14 @@ def build_ffn(
expansion_ratio=expansion_ratio,
fc_type=fc_type,
device=device,
no_bias=no_bias,
bias=bias,
)
elif ffn_type == 'te_ln_mlp':
assert te is not None
return te.LayerNormMLP(
hidden_size=d_model,
ffn_hidden_size=d_model * expansion_ratio,
bias=not no_bias,
bias=bias,
**kwargs,
)

Expand Down

0 comments on commit 6e89ab5

Please sign in to comment.