rapidsai / cugraph

cuGraph - RAPIDS Graph Analytics Library
https://docs.rapids.ai/api/cugraph/stable/
Apache License 2.0
1.77k stars 304 forks source link

[FEA]: Ability to not fail when given start_list contains a vertex not in graph #3666

Closed VibhuJawa closed 6 months ago

VibhuJawa commented 1 year ago

Is this a new feature, an improvement, or a change to existing functionality?

New Feature

How would you describe the priority of this feature request

Critical (currently preventing usage)

Please provide a clear description of problem this feature solves

To support inference use cases and graphs with isolated vertices we need to allow the ability to not fail on cugraph.uniform_neighbor_sample .

Describe your ideal solution


import cudf
import cugraph 

df = cudf.DataFrame({"0":[1,2,3,1],"1":[1,2,3,4]})
G = cugraph.Graph()
G.from_cudf_edgelist(df, source='0', destination='1',renumber=False)

Below Fails:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[9], line 1
----> 1 cugraph.uniform_neighbor_sample(G,start_list=[5], fanout_vals=[1])

File /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/lib/python3.10/site-packages/cugraph/sampling/uniform_neighbor_sample.py:182, in uniform_neighbor_sample(G, start_list, fanout_vals, with_replacement, with_edge_properties, batch_id_list, random_state, return_offsets)
    179     else:
    180         start_list = G.lookup_internal_vertex_id(start_list)
--> 182 sampling_result = pylibcugraph_uniform_neighbor_sample(
    183     resource_handle=ResourceHandle(),
    184     input_graph=G._plc_graph,
    185     start_list=start_list,
    186     h_fan_out=fanout_vals,
    187     with_replacement=with_replacement,
    188     do_expensive_check=False,
    189     with_edge_properties=with_edge_properties,
    190     batch_id_list=batch_id_list,
    191     random_state=random_state,
    192 )
    194 df = cudf.DataFrame()
    196 if with_edge_properties:

File uniform_neighbor_sample.pyx:229, in pylibcugraph.uniform_neighbor_sample.uniform_neighbor_sample()

File utils.pyx:53, in pylibcugraph.utils.assert_success()

RuntimeError: non-success value returned from cugraph_uniform_neighbor_sample_with_edge_properties: CUGRAPH_UNKNOWN_ERROR cuGraph failure at file=/opt/conda/conda-bld/work/cpp/src/prims/per_v_random_select_transform_outgoing_e.cuh line=745: Invalid input argument: frontier includes out-of-range keys.
Obtained 64 stack frames
#0 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/lib/python3.10/site-packages/cugraph/structure/../../../../libcugraph.so(+0xc991d4) [0x7f4bf0d161d4]
#1 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/lib/python3.10/site-packages/cugraph/structure/../../../../libcugraph.so(+0x1320afd) [0x7f4bf139dafd]
#2 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/lib/python3.10/site-packages/cugraph/structure/../../../../libcugraph.so(+0xafaed9) [0x7f4bf0b77ed9]
#3 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/lib/python3.10/site-packages/cugraph/structure/../../../../libcugraph.so(+0x2607fce) [0x7f4bf2684fce]
#4 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/lib/python3.10/site-packages/cugraph/structure/../../../../libcugraph.so(_ZN7cugraph6detail12sample_edgesIllfiiLb0EEESt5tupleIJN3rmm14device_uvectorIT_EES6_St8optionalINS4_IT1_EEES7_INS4_IT0_EEES7_INS4_IT2_EEES7_INS4_IT3_EEEEERKN4raft8handle_tERKNS_12graph_view_tIS5_SB_Lb0EXT4_EvEES7_INS_20edge_property_view_tISB_PKS8_N6thrust15iterator_traitsISV_E10value_typeEEEES7_INST_ISB_PKSB_NSX_IS13_E10value_typeEEEES7_INST_ISB_PKSE_NSX_IS19_E10value_typeEEEERNSL_6random8RngStateENSL_4spanIKS5_Lb1ELm18446744073709551615EEES7_INS1H_IKSH_Lb1ELm18446744073709551615EEEEmb+0x1cf7) [0x7f4bf27480d7]
#5 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/lib/python3.10/site-packages/cugraph/structure/../../../../libcugraph.so(_ZN7cugraph23uniform_neighbor_sampleIllfiiLb0ELb0EEESt5tupleIJN3rmm14device_uvectorIT_EES5_St8optionalINS3_IT1_EEES6_INS3_IT0_EEES6_INS3_IT2_EEES6_INS3_IiEEES6_INS3_IT3_EEES6_INS3_ImEEEEERKN4raft8handle_tERKNS_12graph_view_tIS4_SA_XT4_EXT5_EvEES6_INS_20edge_property_view_tISA_PKS7_N6thrust15iterator_traitsISY_E10value_typeEEEES6_INSW_ISA_PKSA_NS10_IS16_E10value_typeEEEES6_INSW_ISA_PKSD_NS10_IS1C_E10value_typeEEEENSO_4spanIKS4_Lb1ELm18446744073709551615EEES6_INS1H_IKSI_Lb1ELm18446744073709551615EEEES6_IS1_IJS1L_NS1H_IKiLb1ELm18446744073709551615EEEEEENS1H_IS1N_Lb0ELm18446744073709551615EEERNSO_6random8RngStateEbbb+0x389) [0x7f4bf27b16a9]
#6 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/lib/python3.10/site-packages/pylibcugraph/../../../libcugraph_c.so(+0x25f064) [0x7f4c5504b064]
#7 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/lib/python3.10/site-packages/pylibcugraph/../../../libcugraph_c.so(cugraph_uniform_neighbor_sample_with_edge_properties+0x1c40) [0x7f4c5505a8e0]
#8 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/lib/python3.10/site-packages/pylibcugraph/uniform_neighbor_sample.cpython-310-x86_64-linux-gnu.so(+0x866a) [0x7f4c7406d66a]
#9 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/lib/python3.10/site-packages/pylibcugraph/uniform_neighbor_sample.cpython-310-x86_64-linux-gnu.so(+0xba45) [0x7f4c74070a45]
#10 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyObject_MakeTpCall+0x26b) [0x563f13685bdb]
#11 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x5b6e) [0x563f136820ce]
#12 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyFunction_Vectorcall+0x6f) [0x563f1368c73f]
#13 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x13d0) [0x563f1367d930]
#14 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x1d5852) [0x563f13724852]
#15 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(PyEval_EvalCode+0x87) [0x563f13724797]
#16 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x1dcde0) [0x563f1372bde0]
#17 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x13d934) [0x563f1368c934]
#18 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x332) [0x563f1367c892]
#19 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x1df4bd) [0x563f1372e4bd]
#20 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x1bb1) [0x563f1367e111]
#21 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x1df4bd) [0x563f1372e4bd]
#22 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x1bb1) [0x563f1367e111]
#23 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x1df4bd) [0x563f1372e4bd]
#24 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x1f3a4a) [0x563f13742a4a]
#25 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x147e3f) [0x563f13696e3f]
#26 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x735) [0x563f1367cc95]
#27 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyFunction_Vectorcall+0x6f) [0x563f1368c73f]
#28 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x332) [0x563f1367c892]
#29 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyFunction_Vectorcall+0x6f) [0x563f1368c73f]
#30 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x735) [0x563f1367cc95]
#31 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x148e41) [0x563f13697e41]
#32 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(PyObject_Call+0xb8) [0x563f136987f8]
#33 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x2d79) [0x563f1367f2d9]
#34 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x148e41) [0x563f13697e41]
#35 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x13d0) [0x563f1367d930]
#36 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x1df4bd) [0x563f1372e4bd]
#37 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x1bb1) [0x563f1367e111]
#38 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x1df4bd) [0x563f1372e4bd]
#39 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x1bb1) [0x563f1367e111]
#40 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x1df4bd) [0x563f1372e4bd]
#41 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x1bb1) [0x563f1367e111]
#42 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x1df4bd) [0x563f1372e4bd]
#43 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x1bb1) [0x563f1367e111]
#44 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x1df4bd) [0x563f1372e4bd]
#45 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/lib/python3.10/lib-dynload/_asyncio.cpython-310-x86_64-linux-gnu.so(+0x7d3d) [0x7f4e09befd3d]
#46 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x13cd4b) [0x563f1368bd4b]
#47 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x25f891) [0x563f137ae891]
#48 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0xf8ef9) [0x563f13647ef9]
#49 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x135513) [0x563f13684513]
#50 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x5c81) [0x563f136821e1]
#51 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyFunction_Vectorcall+0x6f) [0x563f1368c73f]
#52 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x735) [0x563f1367cc95]
#53 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyFunction_Vectorcall+0x6f) [0x563f1368c73f]
#54 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x735) [0x563f1367cc95]
#55 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyFunction_Vectorcall+0x6f) [0x563f1368c73f]
#56 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x735) [0x563f1367cc95]
#57 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyFunction_Vectorcall+0x6f) [0x563f1368c73f]
#58 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x735) [0x563f1367cc95]
#59 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyFunction_Vectorcall+0x6f) [0x563f1368c73f]
#60 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x735) [0x563f1367cc95]
#61 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x148e41) [0x563f13697e41]
#62 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(_PyEval_EvalFrameDefault+0x4d1d) [0x563f1368127d]
#63 in /datasets/vjawa/miniconda3/envs/cugraph_dgl_23_08_19/bin/python(+0x1d5852) [0x563f13724852]

What i expect:

We give no results for that case

Describe any alternatives you have considered

TODO: Get a DGL example

Additional context

No response

Code of Conduct

ChuckHastings commented 1 year ago

Should this be the default behavior for sampling, or an optional behavior we control with a flag? I'm fine with either, but we should decide. @VibhuJawa @alexbarghi-nv

VibhuJawa commented 1 year ago

Should this be the default behavior for sampling, or an optional behavior we control with a flag? I'm fine with either, but we should decide. @VibhuJawa @alexbarghi-nv

My vote is a flag to prevent the behavior change for non GNN use cases of sampling.

alexbarghi-nv commented 6 months ago

I don't think we need this? We're adopting the new approach in PLC where we can pass in a vertex list which takes care of the isolated vertex issue. I've confirmed it works with PyG.