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

[Feature] add degree padding schedule #973

wants to merge 7 commits into
base: master


Copy link

yzh119 commented Nov 4, 2019


Our default degree bucketing strategy is slow for graphs whose degree variance is large (e.g. power-law graphs).

This PR implements degree padding strategy discussed in #777 , where a set of pre-defined buckets are given, messages of each node are padded to the length of least bucket size greater than its in degrees.


We defined a decorator degree_bucketing in dgl.function.reducer that specifies whether to use degree bucketing strategy and related parameters (bucket splits and padding values). The following is an example of lstm reducer used in graphsage:

def _lstm_reducer(nodes, degs):
    m = nodes.mailbox['m'] # (B, L, D)
    m_packed = pack_padded_sequence(m, degs, batch_first=True, enforce_sorted=False)

    batch_size = m.shape[0]
    h = (m.new_zeros((1, batch_size, self._in_feats)),
         m.new_zeros((1, batch_size, self._in_feats)))
    _, (rst, _) = self.lstm(m_packed, h)
    return {'neigh': rst.squeeze(0)}


Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [$CATEGORY] (such as [NN], [Model], [Doc], [Feature]])
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage
  • Code is well-documented
  • To the my best knowledge, examples are either not affected by this change,
    or have been fixed to be compatible with this change
  • Related issue is referred in this PR


yzh119 added 4 commits Nov 4, 2019
@yzh119 yzh119 changed the title [WIP][Feature] add degree padding schedule [Feature] add degree padding schedule Nov 4, 2019
yzh119 added 3 commits Nov 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.