Calling graph.in_degrees() stalls code?

Hi I am having a weird problem recently,

I’ve created my graph using a very basic:

graph = dgl.from_scipy(coo_matrix(adjacency_matrix), eweight_name="distance")

The graph seems to be created successfully:

Graph(num_nodes=770, num_edges=25504,
      ndata_schemes={}
      edata_schemes={'distance': Scheme(shape=(), dtype=torch.float32)})

However calling:

assert (
            graph.in_degrees().min() > 0
        ), f"There are 0-in-degree nodes in the graph of {path}"

Stalls the code. I tried saving to file like this:

        save_graphs("graph_in_degree", [graph])

I get the file attached but somehow I can’t open it:

>>> load_graphs("graph_in_degree")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Caskroom/miniconda/base/envs/timed-gx/lib/python3.7/site-packages/dgl/data/graph_serialize.py", line 182, in load_graphs
    return load_graph_v2(filename, idx_list)
  File "/usr/local/Caskroom/miniconda/base/envs/timed-gx/lib/python3.7/site-packages/dgl/data/graph_serialize.py", line 192, in load_graph_v2
    heterograph_list = _CAPI_LoadGraphFiles_V2(filename, idx_list)
  File "dgl/_ffi/_cython/./function.pxi", line 287, in dgl._ffi._cy3.core.FunctionBase.__call__
  File "dgl/_ffi/_cython/./function.pxi", line 222, in dgl._ffi._cy3.core.FuncCall
  File "dgl/_ffi/_cython/./function.pxi", line 211, in dgl._ffi._cy3.core.FuncCall3
  File "dgl/_ffi/_cython/./base.pxi", line 155, in dgl._ffi._cy3.core.CALL
dgl._ffi.base.DGLError: [12:54:43] /tmp/dgl_src/src/graph/heterograph.cc:509: Check failed: magicNum == kDGLSerialize_HeteroGraph (2 vs. 15949673719616654015) : Invalid HeteroGraph Data
Stack trace:
  [bt] (0) 1   libdgl.dylib                        0x0000000115e3ffff dmlc::LogMessageFatal::~LogMessageFatal() + 111
  [bt] (1) 2   libdgl.dylib                        0x000000011678ec36 dgl::HeteroGraph::Load(dmlc::Stream*) + 374
  [bt] (2) 3   libdgl.dylib                        0x000000011681fa6b dgl::serialize::HeteroGraphDataObject::Load(dmlc::Stream*) + 43
  [bt] (3) 4   libdgl.dylib                        0x000000011681de97 dgl::serialize::LoadHeteroGraphs(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::vector<unsigned long long, std::__1::allocator<unsigned long long> >) + 2247
  [bt] (4) 5   libdgl.dylib                        0x000000011681bfd9 std::__1::__function::__func<dgl::serialize::$_8, std::__1::allocator<dgl::serialize::$_8>, void (dgl::runtime::DGLArgs, dgl::runtime::DGLRetValue*)>::operator()(dgl::runtime::DGLArgs&&, dgl::runtime::DGLRetValue*&&) + 297
  [bt] (5) 6   libdgl.dylib                        0x0000000116728f28 DGLFuncCall + 72
  [bt] (6) 7   core.cpython-37m-darwin.so          0x0000000116f3dfe1 __pyx_f_3dgl_4_ffi_4_cy3_4core_FuncCall(void*, _object*, DGLValue*, int*) + 513
  [bt] (7) 8   core.cpython-37m-darwin.so          0x0000000116f423f4 __pyx_pw_3dgl_4_ffi_4_cy3_4core_12FunctionBase_5__call__(_object*, _object*, _object*) + 52
  [bt] (8) 9   python                              0x0000000109651bfb _PyObject_FastCallKeywords + 683

What’s happening exactly? Why am I not getting any errors from DGL?

Paradoxically, I have no clue how this was an error, but removing an import of a totally unrelated library (import ampal.amino_acids) made the above error. Hence reinserting it made everything work again.

I still have got no clue why DGL stalled at that point. Maybe some sort of bug on your side. Might be worth investigating

This is indeed very weird. Could you raise an issue on GitHub with a reproducible example?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.