Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MinCut pooling for sparse adjacency matrix #9243

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

xiaohan2012
Copy link

@xiaohan2012 xiaohan2012 commented Apr 26, 2024

Motivation

The current nn.dense.mincut_pool requires the input adjacency matrix to be a dense matrix. This requirement does not scale to large graphs

What

This PR considers a sparse counterpart of nn.dense.mincut_pool, which takes in sparse adjacency matrix as input.

Preliminary experiments (not shown here) indicate that the sparse version runs much faster with smaller memory footprint.

Technical issues / questions

  • unit tests for torch 1.13 failed with NotImplementedError: Could not run 'aten::sparse_dim' with arguments from the 'CPU' backend. I have little clue of how to fix it.

Remarks on 3D sparse-dense tensor multiplication

Currently, multiplying a batched 3D dense tensor (e.g., the node-level feature matrix) with a batched 3D sparse tensor (e.g., the adjacency matrix) is implemented by looping through the batches and performing 2D matrix multiplication (detailed in the _bmm function in this PR).

We can use a more efficient way to achieve the same goal:

  1. diagonally stack the 2D batches in the sparse 3D tensor (e.g, using Batch.from_data_list),
  2. vertically stack the 2D batches in the dense tensor, and
  3. do the multiplication on the stacked 2D matrices (elaborated here)

Other remark

This PR is WIP. It is my first PR for this project, appreciate any feedback 🙏🙏🙏

@xiaohan2012 xiaohan2012 marked this pull request as draft April 26, 2024 06:27
@github-actions github-actions bot added the nn label Apr 26, 2024
Copy link

codecov bot commented Apr 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.83%. Comparing base (01e8303) to head (dc9cb52).
Report is 7 commits behind head on master.

❗ Current head dc9cb52 differs from pull request most recent head 156a03c. Consider uploading reports for the commit 156a03c to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9243      +/-   ##
==========================================
- Coverage   85.22%   78.83%   -6.40%     
==========================================
  Files         459      471      +12     
  Lines       29951    30318     +367     
==========================================
- Hits        25526    23901    -1625     
- Misses       4425     6417    +1992     

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants