Skip to content

Conversation

@zaristei
Copy link
Contributor

@zaristei zaristei commented Mar 19, 2025

This PR makes the following changes:

  • Modifies NeighborSampler so that sampling can occur from src to dst node, and not just from dst to src node, which is the current default behavior.
  • Adds a new sampler called BidirectionalNeighborSampler, which samples nodes/edges in both upstream and downstream directions for a directed graph, as if it were an undirected graph.
  • Add merge_with and collate methods to the SamplerOutput dataclass, allowing for different SamplerOutputs to be merged together. This also becomes useful in scenarios where the user may want to sample using multiple different unique sampling methods.

This PR will remain in draft until methods are also implemented on the corresponding Hetero graph classes, and unittests have been written to cover new behaviors.
UPDATE: Hetero Bidirectional Sampler and SamplerOutput merge will be a separate PR.

@puririshi98
Copy link
Contributor

looks good so far

puririshi98 added a commit that referenced this pull request Apr 2, 2025
While working on [this
PR](#10126), I noticed
that there are no sanity tests for the default NeighborSampler. Although
NeigborLoader effectively tests a lot of this functionality, having
lower level tests helps with ensuring consistency for each `sample` call
of the sampler, without the batching logic of `NeighborLoader` getting
involved.

---------

Co-authored-by: Zack Aristei <[email protected]>
Co-authored-by: Rishi Puri <[email protected]>
@puririshi98 puririshi98 marked this pull request as ready for review April 2, 2025 01:04
@puririshi98 puririshi98 requested review from a team, mananshah99 and wsad1 as code owners April 2, 2025 01:04
@zaristei zaristei force-pushed the zaristei/bidirectional-sampler branch 2 times, most recently from fdf6450 to c9eab32 Compare April 3, 2025 18:52
@zaristei zaristei force-pushed the zaristei/bidirectional-sampler branch 2 times, most recently from d2506c8 to 9adc7b9 Compare April 11, 2025 23:51
@puririshi98
Copy link
Contributor

closing since matthias said theres an existing simple way to do this. please jsut put the fix into my branch:
#9992

@puririshi98 puririshi98 reopened this Apr 14, 2025
Copy link
Contributor

@puririshi98 puririshi98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but i will request that @akihironitta or @rusty1s review this

@zaristei zaristei force-pushed the zaristei/bidirectional-sampler branch 2 times, most recently from e288d28 to d99fb71 Compare April 16, 2025 03:30
@zaristei
Copy link
Contributor Author

#10200 should be merged first

@codecov
Copy link

codecov bot commented Apr 16, 2025

Codecov Report

❌ Patch coverage is 91.63347% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.90%. Comparing base (c211214) to head (11b4899).
⚠️ Report is 138 commits behind head on master.

Files with missing lines Patch % Lines
torch_geometric/sampler/neighbor_sampler.py 87.17% 15 Missing ⚠️
torch_geometric/sampler/utils.py 73.91% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10126      +/-   ##
==========================================
- Coverage   86.11%   85.90%   -0.21%     
==========================================
  Files         496      501       +5     
  Lines       33655    34811    +1156     
==========================================
+ Hits        28981    29906     +925     
- Misses       4674     4905     +231     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

chrisn-pik pushed a commit to chrisn-pik/pytorch_geometric that referenced this pull request Jun 30, 2025
…am#10139)

While working on [this
PR](pyg-team#10126), I noticed
that there are no sanity tests for the default NeighborSampler. Although
NeigborLoader effectively tests a lot of this functionality, having
lower level tests helps with ensuring consistency for each `sample` call
of the sampler, without the batching logic of `NeighborLoader` getting
involved.

---------

Co-authored-by: Zack Aristei <[email protected]>
Co-authored-by: Rishi Puri <[email protected]>
Copy link
Contributor

@puririshi98 puririshi98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging as per discussions with matthias, these are heavily tested through NVIDIA already

@puririshi98
Copy link
Contributor

turns out this PR already included fixes from the other PR and so when they merged it duplicated them. reverting the merge just for that file seemed to fix things since the changes from his older pr still exist in main, should be good to merge once the unrelated onnx issue is fixed.

@puririshi98 puririshi98 merged commit 6b08694 into pyg-team:master Aug 27, 2025
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants