Skip to content

Commit 105633b

Browse files
committed
fix(pt): remove stale CuTe metadata re-export
1 parent 91ddd54 commit 105633b

3 files changed

Lines changed: 20 additions & 30 deletions

File tree

deepmd/pt/model/descriptor/sezm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
UpdateSel,
6767
)
6868
from deepmd.pt_expt.kernels.cute.sezm import runtime_policy as cute_runtime_policy
69+
from deepmd.pt_expt.kernels.cute.sezm.so2.metadata import (
70+
build_sorted_edge_index_metadata,
71+
)
6972
from deepmd.pt_expt.kernels.utils import (
7073
cuda_infer_level,
7174
use_amp_infer,
@@ -108,9 +111,6 @@
108111
safe_norm,
109112
safe_numpy_to_tensor,
110113
)
111-
from .sezm_nn.edge_cache import (
112-
build_sorted_edge_index_metadata,
113-
)
114114

115115
if TYPE_CHECKING:
116116
from collections.abc import (

deepmd/pt/model/descriptor/sezm_nn/edge_cache.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
from deepmd.pt_expt.kernels.cute.sezm.runtime_policy import (
2929
is_cute_infer_enabled,
3030
)
31-
from deepmd.pt_expt.kernels.cute.sezm.so2.metadata import (
32-
build_sorted_edge_index_metadata as build_sorted_edge_index_metadata,
33-
)
3431

3532
from .utils import (
3633
get_promoted_dtype,

source/tests/pt/model/sezm_cute/test_so2_dst_ptr.py

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ def _load_extracted_sorted_metadata_function():
7272
return namespace["build_sorted_edge_index_metadata"]
7373

7474

75+
def _load_sorted_metadata_function() -> Any:
76+
module = importlib.import_module("deepmd.pt_expt.kernels.cute.sezm.so2.metadata")
77+
return module.build_sorted_edge_index_metadata
78+
79+
7580
class _FakeDst:
7681
device = "cuda:0"
7782
dtype = "int64"
@@ -384,9 +389,7 @@ def _cache(src, dst, node_count):
384389

385390
def test_builds_destination_and_indirect_source_csr(self):
386391
assert torch is not None
387-
edge_cache = importlib.import_module(
388-
"deepmd.pt.model.descriptor.sezm_nn.edge_cache"
389-
)
392+
builder = _load_sorted_metadata_function()
390393
src = torch.tensor(
391394
[2, 0, 3, 0, 1, 2],
392395
dtype=torch.int64,
@@ -397,9 +400,7 @@ def test_builds_destination_and_indirect_source_csr(self):
397400
dtype=torch.int64,
398401
device="cpu",
399402
)
400-
dst_ptr, source_order, source_ptr = edge_cache.build_sorted_edge_index_metadata(
401-
src, dst, 4
402-
)
403+
dst_ptr, source_order, source_ptr = builder(src, dst, 4)
403404

404405
self.assertEqual(dst_ptr.dtype, torch.int32)
405406
self.assertEqual(source_order.dtype, torch.int32)
@@ -437,10 +438,8 @@ def test_builds_destination_and_indirect_source_csr(self):
437438

438439
def test_empty_edges_build_valid_zero_csr(self):
439440
assert torch is not None
440-
edge_cache = importlib.import_module(
441-
"deepmd.pt.model.descriptor.sezm_nn.edge_cache"
442-
)
443-
dst_ptr, source_order, source_ptr = edge_cache.build_sorted_edge_index_metadata(
441+
builder = _load_sorted_metadata_function()
442+
dst_ptr, source_order, source_ptr = builder(
444443
torch.empty(0, dtype=torch.int64, device="cpu"),
445444
torch.empty(0, dtype=torch.int64, device="cpu"),
446445
4,
@@ -509,15 +508,13 @@ def build_ptr(src, dst):
509508

510509
def test_dynamic_node_and_edge_counts_build_independent_metadata(self):
511510
assert torch is not None
512-
edge_cache = importlib.import_module(
513-
"deepmd.pt.model.descriptor.sezm_nn.edge_cache"
514-
)
515-
first = edge_cache.build_sorted_edge_index_metadata(
511+
builder = _load_sorted_metadata_function()
512+
first = builder(
516513
torch.tensor([0, 1, 2], dtype=torch.int64, device="cpu"),
517514
torch.tensor([0, 1, 2], dtype=torch.int64, device="cpu"),
518515
4,
519516
)
520-
second = edge_cache.build_sorted_edge_index_metadata(
517+
second = builder(
521518
torch.tensor(
522519
[0, 2, 4, 1, 3],
523520
dtype=torch.int64,
@@ -553,9 +550,7 @@ def test_dynamic_node_and_edge_counts_build_independent_metadata(self):
553550

554551
def test_explicit_tensor_metadata_survives_disabled_so2_boundary(self):
555552
assert torch is not None
556-
edge_cache = importlib.import_module(
557-
"deepmd.pt.model.descriptor.sezm_nn.edge_cache"
558-
)
553+
builder = _load_sorted_metadata_function()
559554
dynamo = getattr(torch, "_dynamo", None)
560555
if dynamo is None:
561556
self.skipTest("torch._dynamo is unavailable")
@@ -616,12 +611,10 @@ def consume(cache, x, radial, dst_ptr, source_order, source_ptr):
616611
)
617612
for src, dst, node_count in cases:
618613
cache = self._cache(src, dst, node_count)
619-
dst_ptr, source_order, source_ptr = (
620-
edge_cache.build_sorted_edge_index_metadata(
621-
src,
622-
dst,
623-
node_count,
624-
)
614+
dst_ptr, source_order, source_ptr = builder(
615+
src,
616+
dst,
617+
node_count,
625618
)
626619
radial = torch.ones(src.numel(), 4, 1, device="cpu")
627620
args = (

0 commit comments

Comments
 (0)