@@ -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+
7580class _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