TECHNOLOGY

GraphSAGE sampled batches need local-to-global node correspondence

In this article
THE QUICK TAKE

A sampled subgraph index identifies a local row, not the same global node in every minibatch.

A prediction row is not automatically a dataset row

A node-classification service may sample neighbors around requested seeds and return every output row as if it corresponded to the next global node. Sampling adds contextual nodes and relabels connectivity locally. Without the mapping, apparently valid predictions can be assigned to unrelated source entities.

The SAGEConv API describes neighborhood aggregation and source/target feature roles. This operator contract should be read together with the loader that constructs its actual input graph.

The loader preserves a global identity map

The NeighborLoader implementation documents n_id for original node identifiers and batch_size for seed nodes appearing first in a sampled batch. The remaining sampled nodes provide context rather than automatically expanding the requested prediction target set.

Retain these fields when exporting predictions. A local index can identify a different global node in another batch, so it must not become a persistent entity identifier in a results database.

Source and target arrays need distinct meanings

The GraphSAGE layer implementation accepts paired source and target features for bipartite operation. Neighbor messages and root contributions use their corresponding roles.

A wrapper should not swap the pair simply because both feature widths happen to match. The tensor-axis guide helps distinguish feature dimensions from node populations. Keep the sampled edge mapping consistent with the particular source and target arrays.

Sampling changes the supplied neighborhood

A finite neighbor budget defines a sampled computation. Its result should not be presented as an exact full-neighborhood result without an appropriate comparison. Reproducibility also depends on sampling configuration, graph preparation, and the chosen aggregation operation.

Record hop budgets and seed selection with the experiment. If evaluation requires only requested seeds, filter outputs using the loader contract rather than selecting a convenient number of arbitrary rows after an independent sort.

Verify joins before measuring prediction quality

Build a small graph whose nodes have recognizable external identities and distinct features. Inspect sampled local indices, global mappings, seed membership, and prediction export. Repeat with overlapping seed batches to reveal incorrect persistence of local identifiers.

The data identity guide explains the broader joining problem. A correctly mapped result supports valid evaluation, but it does not establish inductive accuracy on unseen graph domains or eliminate approximation introduced by the selected neighbor sampling procedure.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles