Skip to content

Commit d4831ab

Browse files
authored
[Fix] Support Paddle 3.4 compat imports (#5)
Co-authored-by: huangjiyi <huangjiyi@users.noreply.github.com>
1 parent 34c5385 commit d4831ab

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

fla/modules/conv/cp/ops.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def _prepare_initial_state_for_cp(
3535
weight: torch.Tensor,
3636
cu_seqlens: torch.Tensor | None,
3737
context: FLACPContext,
38-
group: dist.ProcessGroup | None,
38+
group: "dist.ProcessGroup | None",
3939
) -> torch.Tensor | None:
4040
"""Prepare initial_state for CP forward pass by communicating with previous rank.
4141
@@ -81,7 +81,7 @@ def _correct_dx_for_cp(
8181
dx: torch.Tensor,
8282
dh0: torch.Tensor | None,
8383
W: int,
84-
group: dist.ProcessGroup | None,
84+
group: "dist.ProcessGroup | None",
8585
is_first_rank: bool,
8686
pre_num_conv_tokens: int = 0,
8787
) -> None:

fla/ops/utils/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def prepare_split_cu_seqlens(
7272
split_size: int | None = None,
7373
cu_seqlens: torch.LongTensor | None = None,
7474
dtype: torch.dtype | None = torch.int32,
75-
device: "torch.device | None" = torch.device('cpu'),
75+
device: "torch.device | None" = "cpu",
7676
) -> torch.LongTensor:
7777
"""Sub-split a (optionally packed) batch along the token axis.
7878

tests/paddle/test_kimi_delta_attention.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def test_huggingface_kda_training_import_contract():
176176
from fla.modules.backends import dispatch as modules_dispatch
177177
from fla.ops.backends import dispatch as ops_dispatch
178178
from fla.ops.kda import chunk_kda
179-
from fla.ops.utils.index import prepare_cu_seqlens_from_mask, prepare_lens_from_mask
179+
from fla.ops.utils.index import prepare_cu_seqlens_from_mask, prepare_lens_from_mask, prepare_split_cu_seqlens
180180
from fla.utils import tensor_cache
181181
182182
assert FusedRMSNormGated is not None
@@ -185,6 +185,7 @@ def test_huggingface_kda_training_import_contract():
185185
assert callable(chunk_kda)
186186
assert callable(prepare_cu_seqlens_from_mask)
187187
assert callable(prepare_lens_from_mask)
188+
assert prepare_split_cu_seqlens(batch_size=2, seq_len=5, split_size=3).tolist() == [0, 3, 5, 8, 10]
188189
assert callable(tensor_cache)
189190
assert fla.modules is sys.modules["fla.modules"]
190191
assert fla.modules.conv.cp is sys.modules["fla.modules.conv.cp"]

0 commit comments

Comments
 (0)