Skip to content

Commit 5b2cb2e

Browse files
kmontemayorclaude
andcommitted
test(distributed): with_edge derivation across weighted, PPR, and graph-store modes
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent b73a25f commit 5b2cb2e

3 files changed

Lines changed: 43 additions & 0 deletions

File tree

tests/unit/distributed/dist_ppr_sampler_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,13 @@ def _run_ppr_loader_correctness_check(
316316

317317
dataset = create_homogeneous_dataset(edge_index=_TEST_EDGE_INDEX, edge_dir=edge_dir)
318318

319+
# This dataset has no edge features, so with_edge is derived as False. PPR
320+
# outputs come from metadata (ppr_edge_index/ppr_edge_attr), not sampled edge
321+
# ids, so with_edge must not affect the PPR results verified below.
322+
assert dataset.edge_features is None, (
323+
"PPR regression fixture must be edge-feature-free so with_edge is False."
324+
)
325+
319326
loader = DistNeighborLoader(
320327
dataset=dataset,
321328
num_neighbors=[], # Unused by PPR sampler; required by interface

tests/unit/distributed/distributed_weighted_sampling_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,12 @@ def _run_weighted_sampling_correctness_homogeneous(
327327
for datum in loader:
328328
assert isinstance(datum, Data), f"Expected Data, got {type(datum)}"
329329
assert datum.x is not None, "Node features missing from sampled subgraph"
330+
# The graph has no edge features, so with_edge is derived as False and GLT
331+
# must not attach sampled edge ids -- yet weighted sampling still works.
332+
assert getattr(datum, "edge", None) is None, (
333+
"Featureless weighted dataset should sample with with_edge=False, "
334+
"but sampled edge ids were attached to the batch."
335+
)
330336
# Bad nodes have feature 0.0; hub and good nodes have feature > 0.
331337
bad_mask = datum.x[:, 0] == 0.0
332338
assert not bad_mask.any(), (

tests/unit/distributed/graph_store/remote_dist_dataset_test.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,36 @@ def test_graph_metadata_getters_homogeneous(self, mock_request):
200200
self.assertIsNone(remote_dataset.fetch_edge_types())
201201
self.assertIsNone(remote_dataset.fetch_node_types())
202202

203+
def test_fetch_edge_feature_info_populated_from_server(self, mock_request):
204+
"""Edge feature info is fetched from server rank 0 for the compute-side schema.
205+
206+
The ``with_edge`` sampling flag is derived on the compute side as
207+
``dataset_schema.edge_feature_info is not None`` (see
208+
``BaseDistLoader.create_sampling_config``). This test confirms the field
209+
is populated from the storage cluster when the graph has edge features,
210+
so that derivation yields ``with_edge=True`` off-node.
211+
"""
212+
global _test_server
213+
num_edges = DEFAULT_HOMOGENEOUS_EDGE_INDEX.shape[1]
214+
dataset_with_edge_features = create_homogeneous_dataset(
215+
edge_index=DEFAULT_HOMOGENEOUS_EDGE_INDEX,
216+
node_features=torch.zeros(10, 3),
217+
edge_features=torch.zeros(num_edges, 4),
218+
)
219+
_test_server = DistServer(dataset_with_edge_features)
220+
dist_server_module._dist_server = _test_server
221+
222+
cluster_info = _create_mock_graph_store_info()
223+
remote_dataset = RemoteDistDataset(cluster_info=cluster_info, local_rank=0)
224+
225+
edge_feature_info = remote_dataset.fetch_edge_feature_info()
226+
self.assertEqual(
227+
edge_feature_info,
228+
FeatureInfo(dim=4, dtype=torch.float32),
229+
)
230+
# The derivation used off-node by create_sampling_config.
231+
self.assertTrue(edge_feature_info is not None)
232+
203233
def test_cluster_info_property(self, mock_request):
204234
cluster_info = _create_mock_graph_store_info(
205235
num_storage_nodes=3, num_compute_nodes=2

0 commit comments

Comments
 (0)