Skip to content

Commit 924d86f

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 29c0369 commit 924d86f

70 files changed

Lines changed: 1091 additions & 434 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

deepmd/kernels/cute/neo/compile_cache.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,25 @@
22
# SPDX-License-Identifier: LGPL-3.0-or-later
33
"""Device-aware caching for architecture-specific CuTe compilation."""
44

5-
from __future__ import annotations
6-
7-
from collections.abc import Callable
8-
from contextlib import nullcontext
9-
from functools import lru_cache, wraps
10-
from typing import Any, TypeVar, cast
5+
from __future__ import (
6+
annotations,
7+
)
118

9+
from collections.abc import (
10+
Callable,
11+
)
12+
from contextlib import (
13+
nullcontext,
14+
)
15+
from functools import (
16+
lru_cache,
17+
wraps,
18+
)
19+
from typing import (
20+
Any,
21+
TypeVar,
22+
cast,
23+
)
1224

1325
_T = TypeVar("_T", bound=Callable[..., Any])
1426

deepmd/kernels/cute/neo/gie.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,34 @@
1515
fusion by default; ``DP_CUTE_GIE=0`` disables it explicitly.
1616
"""
1717

18-
from __future__ import annotations
18+
from __future__ import (
19+
annotations,
20+
)
1921

2022
import threading
21-
from typing import TYPE_CHECKING, Any
23+
from typing import (
24+
TYPE_CHECKING,
25+
Any,
26+
)
2227

2328
import torch
24-
from torch import Tensor
29+
from torch import (
30+
Tensor,
31+
)
2532

2633
if TYPE_CHECKING:
27-
from collections.abc import Callable
34+
from collections.abc import (
35+
Callable,
36+
)
2837

2938
try:
3039
import cutlass
3140
import cutlass.cute as cute
3241
import cutlass.torch as cutlass_torch
3342
from cuda.bindings.driver import CUstream # noqa: TC002
34-
from cutlass.cute.runtime import from_dlpack
43+
from cutlass.cute.runtime import (
44+
from_dlpack,
45+
)
3546

3647
SEZM_CUTE_GIE_AVAILABLE = True
3748
except Exception: # pragma: no cover - import guard for non-CuTe environments
@@ -40,7 +51,9 @@
4051

4152
def is_cute_gie_enabled(device: torch.device | None = None) -> bool:
4253
"""Return whether the architecture-selected GIE path is enabled."""
43-
from .runtime_policy import is_gie_enabled
54+
from .runtime_policy import (
55+
is_gie_enabled,
56+
)
4457

4558
if device is None:
4659
if not torch.cuda.is_available():

deepmd/kernels/cute/neo/k1.py

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,41 @@
22
# SPDX-License-Identifier: LGPL-3.0-or-later
33
"""Opt-in CuTe Neo K1 custom op for SeZM/DPA4 inference."""
44

5-
from __future__ import annotations
5+
from __future__ import (
6+
annotations,
7+
)
68

79
import threading
810
import weakref
9-
from dataclasses import dataclass, field
10-
from functools import lru_cache
11-
from types import SimpleNamespace
12-
from typing import Any
11+
from dataclasses import (
12+
dataclass,
13+
field,
14+
)
15+
from functools import (
16+
lru_cache,
17+
)
18+
from types import (
19+
SimpleNamespace,
20+
)
21+
from typing import (
22+
Any,
23+
)
1324

1425
import torch
15-
from torch import Tensor
26+
from torch import (
27+
Tensor,
28+
)
1629

17-
from deepmd.pt.model.descriptor.sezm_nn.norm import EquivariantRMSNorm
18-
from . import runtime_policy
19-
from .k1_message_grid_packed import is_supported_message_grid
30+
from deepmd.pt.model.descriptor.sezm_nn.norm import (
31+
EquivariantRMSNorm,
32+
)
33+
34+
from . import (
35+
runtime_policy,
36+
)
37+
from .k1_message_grid_packed import (
38+
is_supported_message_grid,
39+
)
2040

2141

2242
@dataclass(frozen=True)
@@ -836,7 +856,9 @@ def _neo_so2_linear_backward_input_with_residual(
836856
inplace_residual: bool = False,
837857
out: Tensor | None = None,
838858
) -> Tensor:
839-
from .k1_so2linear import cached_neo_so2_linear_weights
859+
from .k1_so2linear import (
860+
cached_neo_so2_linear_weights,
861+
)
840862

841863
w0, wpair = cached_neo_so2_linear_weights(so2_linear)
842864
cache = getattr(so2_linear, "_deepmd_cute_neo_manual_weights_t", None)

deepmd/kernels/cute/neo/k1_gate_structural.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@
77
slice of ``grad_y`` through the GEMM beta epilogue.
88
"""
99

10-
from __future__ import annotations
10+
from __future__ import (
11+
annotations,
12+
)
1113

12-
from typing import Any
14+
from typing import (
15+
Any,
16+
)
1317

1418
import torch
15-
from torch import Tensor
19+
from torch import (
20+
Tensor,
21+
)
1622

1723
FOCUS_COUNT = 2
1824
CHANNELS = 32

deepmd/kernels/cute/neo/k1_kernels/cute_envelope_gated_softmax.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,35 @@
88

99
# ruff: noqa: ANN001, ANN201, ANN204, TC002
1010

11-
from __future__ import annotations
11+
from __future__ import (
12+
annotations,
13+
)
1214

13-
from dataclasses import dataclass
14-
from typing import TYPE_CHECKING
15+
from dataclasses import (
16+
dataclass,
17+
)
18+
from typing import (
19+
TYPE_CHECKING,
20+
)
1521

1622
import cutlass
1723
import cutlass.cute as cute
18-
from cuda.bindings.driver import CUstream
19-
from cutlass.cute.runtime import make_fake_compact_tensor, make_fake_stream
20-
21-
from ..compile_cache import device_aware_lru_cache
22-
24+
from cuda.bindings.driver import (
25+
CUstream,
26+
)
27+
from cutlass.cute.runtime import (
28+
make_fake_compact_tensor,
29+
make_fake_stream,
30+
)
31+
32+
from ..compile_cache import (
33+
device_aware_lru_cache,
34+
)
2335

2436
if TYPE_CHECKING:
25-
from collections.abc import Callable
37+
from collections.abc import (
38+
Callable,
39+
)
2640

2741

2842
@dataclass(frozen=True)

deepmd/kernels/cute/neo/k1_kernels/cute_neo_focus_src_backward.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,26 @@
1111
The kernel is specialized to the Neo K1 shape `(E, F=2, C=32)`.
1212
"""
1313

14-
from __future__ import annotations
14+
from __future__ import (
15+
annotations,
16+
)
1517

16-
from functools import lru_cache
17-
from typing import Callable
18+
from functools import (
19+
lru_cache,
20+
)
21+
from typing import (
22+
Callable,
23+
)
1824

1925
import cutlass
2026
import cutlass.cute as cute
21-
from cuda.bindings.driver import CUstream
22-
from cutlass.cute.runtime import make_fake_compact_tensor, make_fake_stream
23-
27+
from cuda.bindings.driver import (
28+
CUstream,
29+
)
30+
from cutlass.cute.runtime import (
31+
make_fake_compact_tensor,
32+
make_fake_stream,
33+
)
2434

2535
FAKE_TENSOR_KW = {"assumed_align": 16, "use_32bit_stride": True}
2636

deepmd/kernels/cute/neo/k1_kernels/cute_neo_gate_linear_residual_backward_fused.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,36 @@
22
# SPDX-License-Identifier: LGPL-3.0-or-later
33
"""CuTe Neo gate-linear + gate/residual backward without saved logits."""
44

5-
from __future__ import annotations
5+
from __future__ import (
6+
annotations,
7+
)
68

7-
from typing import TYPE_CHECKING
8-
9-
# CuTe JIT functions use DSL-inferred argument and return types.
10-
# ruff: noqa: ANN001, ANN201, ANN202, TC002
9+
from typing import (
10+
TYPE_CHECKING,
11+
)
1112

1213
import cutlass
1314
import cutlass.cute as cute
14-
from cuda.bindings.driver import CUstream
15-
from cutlass.cute.runtime import make_fake_compact_tensor, make_fake_stream
15+
from cuda.bindings.driver import (
16+
CUstream,
17+
)
18+
from cutlass.cute.runtime import (
19+
make_fake_compact_tensor,
20+
make_fake_stream,
21+
)
22+
23+
from ..compile_cache import (
24+
device_aware_lru_cache,
25+
)
26+
27+
# CuTe JIT functions use DSL-inferred argument and return types.
28+
# ruff: noqa: ANN001, ANN201, ANN202, TC002
1629

17-
from ..compile_cache import device_aware_lru_cache
1830

1931
if TYPE_CHECKING:
20-
from collections.abc import Callable
32+
from collections.abc import (
33+
Callable,
34+
)
2135

2236

2337
FAKE_TENSOR_KW = {"assumed_align": 16, "use_32bit_stride": True}

deepmd/kernels/cute/neo/k1_kernels/cute_neo_gate_split_structural_vec4_sm80.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,30 @@
99
split-gate tensor contract and leave dense projections in PyTorch/cuBLAS.
1010
"""
1111

12-
from __future__ import annotations
12+
from __future__ import (
13+
annotations,
14+
)
1315

14-
from collections.abc import Callable
15-
from functools import lru_cache
16+
from collections.abc import (
17+
Callable,
18+
)
19+
from functools import (
20+
lru_cache,
21+
)
1622

1723
import cutlass
1824
import cutlass.cute as cute
19-
from cuda.bindings.driver import CUstream
20-
from cutlass.cute.runtime import make_fake_compact_tensor, make_fake_stream
21-
22-
from .. import runtime_policy
23-
25+
from cuda.bindings.driver import (
26+
CUstream,
27+
)
28+
from cutlass.cute.runtime import (
29+
make_fake_compact_tensor,
30+
make_fake_stream,
31+
)
32+
33+
from .. import (
34+
runtime_policy,
35+
)
2436

2537
FOCUS_COUNT = 2
2638
REDUCED_COUNT = 10
@@ -39,7 +51,9 @@ def _guard_vec4_dispatch(
3951
kernel: Callable,
4052
tensor_names: tuple[str, ...],
4153
) -> Callable:
42-
from ..k1_gate_structural import _dispatch_aligned_vec4_kernel
54+
from ..k1_gate_structural import (
55+
_dispatch_aligned_vec4_kernel,
56+
)
4357

4458
def dispatch(*tensors: object):
4559
return _dispatch_aligned_vec4_kernel(kernel, tensor_names, *tensors)

deepmd/kernels/cute/neo/k1_kernels/cute_neo_message_grid_product.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,34 @@
22
# SPDX-License-Identifier: LGPL-3.0-or-later
33
"""Packed strict-FP32 CuTe grid product for Neo's F=2 K1 branch."""
44

5-
from __future__ import annotations
6-
7-
# CuTe JIT functions use DSL-inferred argument and return types.
8-
# ruff: noqa: ANN001, ANN201, TC003
9-
10-
from collections.abc import Callable
11-
from functools import lru_cache
12-
from typing import Any
5+
from __future__ import (
6+
annotations,
7+
)
8+
9+
from collections.abc import (
10+
Callable,
11+
)
12+
from functools import (
13+
lru_cache,
14+
)
15+
from typing import (
16+
Any,
17+
)
1318

1419
import cutlass
1520
import cutlass.cute as cute
1621
import cutlass.pipeline as pipeline
17-
from cutlass.cute.runtime import make_fake_compact_tensor, make_fake_stream
22+
from cutlass.cute.runtime import (
23+
make_fake_compact_tensor,
24+
make_fake_stream,
25+
)
1826

19-
from .. import runtime_policy
27+
from .. import (
28+
runtime_policy,
29+
)
30+
31+
# CuTe JIT functions use DSL-inferred argument and return types.
32+
# ruff: noqa: ANN001, ANN201, TC003
2033

2134

2235
PACKED_COEFF_DIM = 48

0 commit comments

Comments
 (0)