Skip to content

Add test to reproduce issue with double weights, fix issue (graph cre…#2305

Merged
rapids-bot[bot] merged 4 commits intorapidsai:branch-22.06from
ChuckHastings:fix_sssp_c_api_double
May 26, 2022
Merged

Add test to reproduce issue with double weights, fix issue (graph cre…#2305
rapids-bot[bot] merged 4 commits intorapidsai:branch-22.06from
ChuckHastings:fix_sssp_c_api_double

Conversation

@ChuckHastings
Copy link
Collaborator

@alexbarghi-nv discovered issue with creating graphs through the C API with double weights.

Added CAPI SSSP test which demonstrates the error. Added fix to the error in the graph creation logic (both SG and MG).

@ChuckHastings ChuckHastings requested a review from a team as a code owner May 23, 2022 19:43
@ChuckHastings ChuckHastings self-assigned this May 23, 2022
@ChuckHastings ChuckHastings added 3 - Ready for Review improvement Improvement / enhancement to an existing function non-breaking Non-breaking change bug Something isn't working and removed improvement Improvement / enhancement to an existing function labels May 23, 2022
@ChuckHastings ChuckHastings added this to the 22.06 milestone May 23, 2022
@alexbarghi-nv
Copy link
Member

I just ran some tests and it looks like ints as weights are being rejected as well, which causes some of the tests to fail. Is there any reason integer weights aren't supported? Right now it return this error:
RuntimeError: non-success value returned from cugraph_sg_graph_create(): CUGRAPH_UNSUPPORTED_TYPE_COMBINATION

@ChuckHastings
Copy link
Collaborator Author

I just ran some tests and it looks like ints as weights are being rejected as well, which causes some of the tests to fail. Is there any reason integer weights aren't supported? Right now it return this error:
RuntimeError: non-success value returned from cugraph_sg_graph_create(): CUGRAPH_UNSUPPORTED_TYPE_COMBINATION

Integer weights are not supported primarily because it would explode the compilation time (which is already very long).

Our code uses C++ templates and are templated on the vertex type (int32_t or int64_t), the edge type (int32_t or int64_t), the weight type (float or double), whether or not the graph is stored in transposed format, and whether or not the graph is represented on a single GPU or multiple GPUs. This results in 16 different supported combinations, each of which is generated and compiled. Adding support for integer weight types would double the compile time of the C++ code. To this point we have had very few requests to support integer types.

It is certainly something we can add if there is sufficient user interest.

@alexbarghi-nv
Copy link
Member

Ok, in that case I will force float/double weights. That must have been what it was doing before if we were never supporting integer weights.

Copy link
Member

@alexbarghi-nv alexbarghi-nv left a comment

Choose a reason for hiding this comment

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

LGTM, tests are passing.

CAPI_EXPECTS((weights == nullptr) || (p_weights->size_ == p_src->size_),
CUGRAPH_INVALID_INPUT,
"Invalid input arguments: src size != weights size.",
*error);
Copy link
Contributor

Choose a reason for hiding this comment

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

Question, weights can be nullptr for either unweighted graphs or weighted but # (local) edges == 0. How do you distinguish these two cases?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The assumption in the C API is the following:

  • For an unweighted graph, weights == nullptr
  • For a weighted graph, the weights will be passed, but that it will be an empty array if the number of local edges is 0. So the cugraph_type-erased_device_array_view_t * would be passed if the graph is weighted, but the data pointer will be nullptr and the size will be 0

I will add that to the documentation of the graph creation functions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will also add some unit tests to the creation functions to demonstrate and validate this functionality.

@codecov-commenter
Copy link

Codecov Report

Merging #2305 (9d1bced) into branch-22.06 (38be932) will decrease coverage by 7.03%.
The diff coverage is n/a.

@@               Coverage Diff                @@
##           branch-22.06    #2305      +/-   ##
================================================
- Coverage         70.82%   63.78%   -7.04%     
================================================
  Files               170      100      -70     
  Lines             11036     4498    -6538     
================================================
- Hits               7816     2869    -4947     
+ Misses             3220     1629    -1591     
Impacted Files Coverage Δ
python/cugraph/cugraph/__init__.py 100.00% <ø> (ø)
python/cugraph/cugraph/centrality/__init__.py 100.00% <ø> (ø)
...graph/cugraph/centrality/betweenness_centrality.py 89.65% <ø> (ø)
...on/cugraph/cugraph/centrality/degree_centrality.py 81.81% <ø> (ø)
...thon/cugraph/cugraph/centrality/katz_centrality.py 88.23% <ø> (-1.24%) ⬇️
python/cugraph/cugraph/community/egonet.py 97.36% <ø> (ø)
...ython/cugraph/cugraph/community/ktruss_subgraph.py 88.23% <ø> (+2.94%) ⬆️
python/cugraph/cugraph/community/leiden.py 100.00% <ø> (+7.69%) ⬆️
python/cugraph/cugraph/community/louvain.py 100.00% <ø> (+7.69%) ⬆️
python/cugraph/cugraph/community/triangle_count.py 100.00% <ø> (+11.11%) ⬆️
... and 133 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b6c111f...9d1bced. Read the comment docs.

@BradReesWork
Copy link
Member

@gpucibot merge

@rapids-bot rapids-bot bot merged commit b0c6a9e into rapidsai:branch-22.06 May 26, 2022
@ChuckHastings ChuckHastings deleted the fix_sssp_c_api_double branch August 4, 2022 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants