Repository navigation
feat: use PyG SAGEConv on native graph_sampler mini-batches - #7
Merged
Merged
Conversation
Switch GraphSAGE message passing to torch_geometric.nn.SAGEConv while keeping neighborhood expansion on graph_sampler via sagerec_minibatch (ADR-006). Add an edge_index adapter, harness tests that spy native sample_neighbors and forbid NeighborLoader, and CPU-friendly PyG pins. Do not retcon stored MovieLens 100K quality numbers. Co-authored-by: Nithilan Kumaran <sathariels@users.noreply.github.com>
The mini-batch helper still documents that it must not fall back to a PyG NeighborLoader. Assert against imports and constructor calls instead of the bare class name. Co-authored-by: Nithilan Kumaran <sathariels@users.noreply.github.com>
sathariels
marked this pull request as ready for review
September 14, 2026 16:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 6 closes the project-requirements gap (“Use PyTorch and PyTorch Geometric”) without giving up the systems story: C++ CSR + seeded ADR-005 sampling is still what GraphSAGE consumes.
Owner decision (ADR-006): PyG production path —
torch_geometric.nn.SAGEConv(mean aggregation) for message passing; neighborhoods must still come from nativegraph_samplerviasagerec_minibatch/NativeMinibatchSampler. Primary experiments do not useNeighborLoader,ClusterLoader, or any PyG sampler.What changed
python/sagerec_graphsage.pynow uses PyGSAGEConvinstead of in-repoLinear(concat(self, mean(neighbors)))layers.neighborhood_hop_to_edge_indexconverts one nativeNeighborhoodBatchhop into the PyGedge_indexform SAGEConv expects. It does not sample.python/requirements-train.txt:torch==2.6.0andtorch-geometric==2.6.1. Mean SAGEConv does not needtorch-scatter/torch-sparse/pyg-lib.sample_neighborsis still on the path, assertSAGEConvis the conv stack, and rejectNeighborLoader/ClusterLoaderon the primary path.What stayed native
python/sagerec_minibatch.py/graph_sampler.BipartiteCSR.sample_neighborsremain the only neighborhood expansion path.PairScorer), ADR-003 split, ADR-005 without-replacement sampling, and the train-only CSR contract are unchanged.Honesty
results/graphsage_movielens_100k.json,results/gnn_vs_mf_*) are not retconned. They were measured with the Phase 5 in-repo mean layers. This PR does not invent a new 100K table.Test plan
python_binding_smokeincluded)python3 -m unittestfortest_graphsage_train.py,test_minibatch_native.py,test_gnn_vs_mf_compare.py(39 tests)sample_neighborsspy still fires; NeighborLoader/ClusterLoader are never constructedscripts/run_graphsage_synthetic_smoke.py(protocol smoke only; not stored as 100K)nativeCI green on748618d(CPU PyTorch +torch-geometric==2.6.1; no CUDA wheels, no MovieLens download)