Skip to content

Commit 1d560a1

Browse files
author
Han Wang
committed
fix(api_cc): keep graph edges extended for multi-rank native-spin
The graph-branch edge construction still hardcoded fold_to_local=true, a leftover from when the multi-rank fail-fast guaranteed single-rank on this route. After the fail-fast was replaced by the with-comm dispatch, run_model_graph_with_comm consumed the FOLDED edge list as if it were extended: every src collapsed into [0, nloc), the owned-ghost environment edges vanished (E=4, src in {0,1} on each rank of the NiO fixture), and the 2-rank energy/force/force_mag deviated from the 1-rank result by up to 1e-1 while remaining decomposition-independent. Mirror the non-spin twin (DeepPotPTExpt.cc graph branch): fold only when the with-comm route is not taken. Covered by test_pair_deepspin_mpi_matches_single_rank (2-rank vs 1-rank at 1e-10).
1 parent 0123bcb commit 1d560a1

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

source/api_cc/src/DeepSpinPTExpt.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -816,16 +816,18 @@ void DeepSpinPTExpt::compute(ENERGYVTYPE& ener,
816816
edge_index_tensor = edge_tensors.edge_index;
817817
edge_index_ext_tensor = edge_tensors.edge_index_ext;
818818
} else if (lower_input_is_graph_) {
819-
// Native-spin NeighborGraph route: single-rank ONLY (the multi-rank
820-
// fail-fast above guarantees ``multi_rank == false`` here), so ghost
821-
// neighbours always fold onto their local owners
822-
// (``fold_to_local=true``, N == nloc). Cache the skin topology; the
823-
// model-cutoff edges are recomputed on-device every step (see
824-
// DeepPotPTExpt.cc's graph branch).
819+
// Native-spin NeighborGraph route: single-rank folds ghost neighbours
820+
// onto their local owners (``fold_to_local=true``, N == nloc);
821+
// multi-rank indexes the extended node set directly
822+
// (``fold_to_local=false``, N == nall_real) so ghost node features --
823+
// including the per-node spin embedding -- can be refreshed across
824+
// ranks via border_op (the twin of DeepPotPTExpt.cc's graph branch).
825+
// Cache the skin topology; the model-cutoff edges are recomputed
826+
// on-device every step (see DeepPotPTExpt.cc's graph branch).
825827
const auto edge_tensors = createEdgeTensors(
826828
nlist_data.jlist, dcoord, mapping, nloc, nall_real, device,
827829
/*with_geometry=*/false, /*row_centers=*/&nlist_data.ilist,
828-
/*fold_to_local=*/true);
830+
/*fold_to_local=*/!use_with_comm);
829831
edge_index_tensor = edge_tensors.edge_index;
830832
edge_index_ext_tensor = edge_tensors.edge_index_ext;
831833
} else {

0 commit comments

Comments
 (0)