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

[Performance][CUDA] Labor UVA optimization #5885

Merged
merged 14 commits into from
Jul 13, 2023

Conversation

mfbalin
Copy link
Collaborator

@mfbalin mfbalin commented Jun 18, 2023

Description

Labor Sampler can perform UVA sampling. However, since it has to access the indptr and indices arrays (especially indices) very often, it slows down by a lot compared to NeighborSampler slowdown. This PR focuses on optimizing the accesses to indptr and indices arrays in a way that doesn't bring any regressions to the pure GPU scenario whereas improving training throughput with fanout 10,10,10 by more than 10 percent on ogbn-products training with use_uva=True. With this change, ogbn-products UVA sampling runtime for labor went from 18ms to 13ms on an A100 machine during multi-GPU training. On other multi-GPU machines with V100s, the sampling time is more than 2x faster.

Also fixed a bug for the weighted case. Added some tests to this PR so that we can detect if things are working properly. Below are the profiles of the old and the new code for LABOR-0 UVA. The new version has the extra OneHopExtractorAlignedKernel that copies the indices array in an aligned manner if it is pinned prior to the main sampling kernel.

old
new

Checklist

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [$CATEGORY] (such as [NN], [Model], [Doc], [Feature]])
  • I've leverage the tools to beautify the python and c++ code.
  • The PR is complete and small, read the Google eng practice (CL equals to PR) to understand more about small PR. In DGL, we consider PRs with less than 200 lines of core code change are small (example, test and documentation could be exempted).
  • All changes have test coverage
  • Code is well-documented
  • To the best of my knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

@dgl-bot

This comment was marked as outdated.

@dgl-bot

This comment was marked as outdated.

@mfbalin
Copy link
Collaborator Author

mfbalin commented Jun 18, 2023

@BarclayII could you take a look? On machines with multiple GPUs where PCI-e bandwidth is highly contested, this PR should improve things by quite a lot.

@dgl-bot

This comment was marked as outdated.

@dgl-bot

This comment was marked as outdated.

@dgl-bot

This comment was marked as outdated.

@dgl-bot

This comment was marked as outdated.

@dgl-bot

This comment was marked as outdated.

@dgl-bot

This comment was marked as outdated.

@dgl-bot

This comment was marked as outdated.

@dgl-bot

This comment was marked as outdated.

@mfbalin mfbalin changed the title [Performance][CUDA] Labor UVA optimization [Draft][Performance][CUDA] Labor UVA optimization Jun 18, 2023
@dgl-bot

This comment was marked as outdated.

@dgl-bot

This comment was marked as outdated.

@mfbalin mfbalin changed the title [Draft][Performance][CUDA] Labor UVA optimization [Performance][CUDA] Labor UVA optimization Jun 18, 2023
@dgl-bot

This comment was marked as outdated.

@dgl-bot

This comment was marked as outdated.

@dgl-bot

This comment was marked as outdated.

@dgl-bot

This comment was marked as outdated.

@dgl-bot
Copy link
Collaborator

dgl-bot commented Jun 29, 2023

Not authorized to trigger CI. Please ask core developer to help trigger via issuing comment:

  • @dgl-bot

@dgl-bot
Copy link
Collaborator

dgl-bot commented Jun 29, 2023

Commit ID: 6689d7062714a895a298df245bb6701ff10a45e4

Build ID: 16

Status: ❌ CI test failed in Stage [Authentication].

Report path: link

Full logs path: link

@peizhou001 peizhou001 self-requested a review June 29, 2023 09:18
@Rhett-Ying
Copy link
Collaborator

@frozenbugs dgl.sampling.sample_labors() is not covered in existing DGL benchmarks, we need to add it in order to do performance comparison

@dgl-bot
Copy link
Collaborator

dgl-bot commented Jun 29, 2023

Not authorized to trigger CI. Please ask core developer to help trigger via issuing comment:

  • @dgl-bot

@dgl-bot
Copy link
Collaborator

dgl-bot commented Jun 29, 2023

Commit ID: 2222a5918633685a232185a11182926a25817b60

Build ID: 17

Status: ❌ CI test failed in Stage [Authentication].

Report path: link

Full logs path: link

@dgl-bot
Copy link
Collaborator

dgl-bot commented Jun 29, 2023

Not authorized to trigger CI. Please ask core developer to help trigger via issuing comment:

  • @dgl-bot

@dgl-bot
Copy link
Collaborator

dgl-bot commented Jun 29, 2023

Commit ID: 9178269c838d842e19b45fa4e071d7db22cbfd55

Build ID: 18

Status: ❌ CI test failed in Stage [Authentication].

Report path: link

Full logs path: link

@Rhett-Ying
Copy link
Collaborator

@dgl-bot

@dgl-bot
Copy link
Collaborator

dgl-bot commented Jun 30, 2023

Commit ID: 0725f0d966af5d4289f67dd3c7629dad6db81840

Build ID: 19

Status: ❌ CI test failed in Stage [DGL-Go CPU test].

Report path: link

Full logs path: link

@dgl-bot
Copy link
Collaborator

dgl-bot commented Jul 3, 2023

Not authorized to trigger CI. Please ask core developer to help trigger via issuing comment:

  • @dgl-bot

@dgl-bot
Copy link
Collaborator

dgl-bot commented Jul 3, 2023

Commit ID: 22b5d74

Build ID: 20

Status: ❌ CI test failed in Stage [Authentication].

Report path: link

Full logs path: link

@Rhett-Ying
Copy link
Collaborator

@dgl-bot

@dgl-bot
Copy link
Collaborator

dgl-bot commented Jul 3, 2023

Commit ID: 22b5d74

Build ID: 21

Status: ✅ CI test succeeded.

Report path: link

Full logs path: link

@frozenbugs
Copy link
Collaborator

Let's get this PR merged first, and let's discuss next week to find a path to integrate it in graphbolt. @mfbalin

@mfbalin
Copy link
Collaborator Author

mfbalin commented Jul 7, 2023

I would also like to make a PR including the kappa feature I talked about in my presentation. It modifies only the random number generation logic and adds the kappa parameter to the sampler API. However, it won't be useful if #4341 or an alternative dynamic cache is not merged. With the addition of the kappa PR, the official LABOR sampling implementation living inside DGL will be complete.

@Rhett-Ying
Copy link
Collaborator

@caojy1998 FYI. We need to add benchmark for sample_labor() into our new benchmark framework.

@caojy1998
Copy link
Collaborator

@caojy1998 FYI. We need to add benchmark for sample_labor() into our new benchmark framework.

OK, got it.

@mfbalin
Copy link
Collaborator Author

mfbalin commented Jul 13, 2023

Is the lack of a benchmark script blocking the merge of this PR or are we waiting for another reviewer's approval?

@frozenbugs
Copy link
Collaborator

no, not blocking, let's run the CI, and I will merge it.

@dgl-bot
Copy link
Collaborator

dgl-bot commented Jul 13, 2023

Commit ID: 3bead55

Build ID: 22

Status: ✅ CI test succeeded.

Report path: link

Full logs path: link

@frozenbugs frozenbugs merged commit c3aea1b into dmlc:master Jul 13, 2023
1 check passed
Rhett-Ying added a commit that referenced this pull request Aug 10, 2023
Co-authored-by: Xin Yao <xiny@nvidia.com>
Co-authored-by: Rhett Ying <85214957+Rhett-Ying@users.noreply.github.com>
DominikaJedynak pushed a commit to DominikaJedynak/dgl that referenced this pull request Mar 12, 2024
Co-authored-by: Xin Yao <xiny@nvidia.com>
Co-authored-by: Rhett Ying <85214957+Rhett-Ying@users.noreply.github.com>
This pull request was closed.
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.

6 participants