|
26 | 26 | from deepmd.dpmodel.utils.serialization import ( |
27 | 27 | traverse_model_dict, |
28 | 28 | ) |
| 29 | +from deepmd.pt_expt.model.graph_lower import ( |
| 30 | + graph_edge_dtype, |
| 31 | +) |
29 | 32 |
|
30 | 33 | # --------------------------------------------------------------------------- |
31 | 34 | # AOTInductor ``.pt2`` archive layout. |
@@ -1015,28 +1018,6 @@ def _build_dynamic_shapes( |
1015 | 1018 | return (*base, None, None, None, None, None, None, None, None) |
1016 | 1019 |
|
1017 | 1020 |
|
1018 | | -def _graph_edge_dtype(model: torch.nn.Module, lower_kind: str) -> str: |
1019 | | - """Return the graph edge-vector dtype encoded by the deployment artifact. |
1020 | | -
|
1021 | | - Geometrically compressed DPA1 with float32 descriptor statistics evaluates |
1022 | | - both descriptor directions in float32 and therefore accepts float32 |
1023 | | - geometry directly. Other graph descriptors retain the model-agnostic |
1024 | | - float64 geometry ABI. |
1025 | | - """ |
1026 | | - atomic_model = getattr(model, "atomic_model", None) |
1027 | | - descriptor = getattr(atomic_model, "descriptor", None) |
1028 | | - descriptor_block = getattr(descriptor, "se_atten", None) |
1029 | | - statistics = getattr(descriptor_block, "mean", None) |
1030 | | - if ( |
1031 | | - lower_kind in ("graph", "dpa1_canonical") |
1032 | | - and bool(getattr(descriptor, "geo_compress", False)) |
1033 | | - and isinstance(statistics, torch.Tensor) |
1034 | | - and statistics.dtype == torch.float32 |
1035 | | - ): |
1036 | | - return "float32" |
1037 | | - return "float64" |
1038 | | - |
1039 | | - |
1040 | 1021 | def _supports_graph_export(model: torch.nn.Module) -> bool: |
1041 | 1022 | """Whether the model has an exportable graph-lower implementation. |
1042 | 1023 |
|
@@ -1173,7 +1154,7 @@ def _probe_has_message_passing(obj: object) -> bool | None: |
1173 | 1154 | # "graph" → NeighborGraph (atype, n_node, edge_index, edge_vec, edge_mask) |
1174 | 1155 | # The C++ loader branches on this to build the matching inputs. |
1175 | 1156 | meta["lower_input_kind"] = lower_kind |
1176 | | - meta["graph_edge_dtype"] = _graph_edge_dtype(model, lower_kind) |
| 1157 | + meta["graph_edge_dtype"] = graph_edge_dtype(model, lower_kind) |
1177 | 1158 |
|
1178 | 1159 | # Model-level pair-type exclusion (``pair_exclude_types``): a list of |
1179 | 1160 | # ``[ti, tj]`` type pairs whose interaction is dropped. Exclusion is a |
|
0 commit comments