Skip to content

Commit

Permalink
feat: make alibi_slope cinfigurable in block, chunk processor
Browse files Browse the repository at this point in the history
  • Loading branch information
theissenhelen committed Oct 1, 2024
1 parent bbd89dc commit 91533c6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/anemoi/models/layers/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ def __init__(
window_size: int,
dropout_p: float = 0.0,
use_flash_attention: bool = False,
softcap: float = 0.0,
softcap: float | None = 0.0,
alibi_slopes: Tensor | None = None,
):
super().__init__()

Expand All @@ -85,6 +86,7 @@ def __init__(
dropout_p=dropout_p,
use_flash_attention=use_flash_attention,
softcap=softcap,
alibi_slopes=alibi_slopes,
)

self.mlp = nn.Sequential(
Expand Down
6 changes: 4 additions & 2 deletions src/anemoi/models/layers/chunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def __init__(
activation: str = "GELU",
dropout_p: float = 0.0,
use_flash_attention: bool = False,
softcap: float = 0.0,
softcap: float | None = 0.0,
alibi_slopes: Tensor | None = None,
) -> None:
"""Initialize TransformerProcessor.
Expand Down Expand Up @@ -104,8 +105,9 @@ def __init__(
activation=activation,
window_size=window_size,
dropout_p=dropout_p,
softcap=softcap,
use_flash_attention=use_flash_attention,
softcap=softcap,
alibi_slopes=alibi_slopes,
)

def forward(
Expand Down
4 changes: 3 additions & 1 deletion src/anemoi/models/layers/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def __init__(
mlp_hidden_ratio: int = 4,
dropout_p: float = 0.1,
use_flash_attention: bool = False,
softcap: float = 0.0,
softcap: float | None = 0.0,
alibi_slopes: Tensor | None = None,
**kwargs,
) -> None:
"""Initialize TransformerProcessor.
Expand Down Expand Up @@ -141,6 +142,7 @@ def __init__(
dropout_p=dropout_p,
use_flash_attention=use_flash_attention,
softcap=softcap,
alibi_slopes=alibi_slopes,
)

self.offload_layers(cpu_offload)
Expand Down

0 comments on commit 91533c6

Please sign in to comment.