Error when batching heterographs using DGL 2.1.0

Hey everyone,

it’s been a few years since I posted here, but I’m now slowly getting back to graph neural networks – great to see how much DGL has advanced since 2020!

I’ve been updating some of the code I wrote back in the day using DGL 0.5.2.

When attempting to batch heterogeneous graphs for processing using DGL 2.1.0, I get the following error when calling dgl.batch() here:

File "dataloaders/pytorch/ai2d_rst.py", line 96, in batch_to_device
    diagram_batch = dgl.batch(graph_batch)
                    ^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.11/site-packages/dgl/batch.py", line 173, in batch
    gidx = disjoint_union(
           ^^^^^^^^^^^^^^^
  File "lib/python3.11/site-packages/dgl/heterograph_index.py", line 1432, in disjoint_union
    return _CAPI_DGLHeteroDisjointUnion_v2(metagraph, graphs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "lib/python3.11/site-packages/dgl/_ffi/_ctypes/function.py", line 212, in __call__
    check_call(
  File "lib/python3.11/site-packages/dgl/_ffi/base.py", line 70, in check_call
    raise DGLError(py_str(_LIB.DGLGetLastError()))

dgl._ffi.base.DGLError: [20:55:05] /tmp/dgl_src/src/graph/./heterograph.h:34: Check failed: etype < meta_graph_->NumEdges() (3 vs. 3) : Invalid edge type: 3
Stack trace:
  [bt] (0) 1   libdgl.dylib                        0x000000012eac9124 dmlc::LogMessageFatal::~LogMessageFatal() + 116
  [bt] (1) 2   libdgl.dylib                        0x000000012eeb6ef8 dgl::HeteroGraph::GetRelationGraph(unsigned long long) const + 224
  [bt] (2) 3   libdgl.dylib                        0x000000012ef978f0 dgl::DisjointUnionHeteroGraph2(std::__1::shared_ptr<dgl::GraphInterface>, std::__1::vector<std::__1::shared_ptr<dgl::BaseHeteroGraph>, std::__1::allocator<std::__1::shared_ptr<dgl::BaseHeteroGraph> > > const&) + 508
  [bt] (3) 4   libdgl.dylib                        0x000000012eeca040 std::__1::__function::__func<dgl::$_54, std::__1::allocator<dgl::$_54>, void (dgl::runtime::DGLArgs, dgl::runtime::DGLRetValue*)>::operator()(dgl::runtime::DGLArgs&&, dgl::runtime::DGLRetValue*&&) + 1400
  [bt] (4) 5   libdgl.dylib                        0x000000012ee53af0 DGLFuncCall + 80
  [bt] (5) 6   libffi.dylib                        0x00000001b6e94050 ffi_call_SYSV + 80
  [bt] (6) 7   libffi.dylib                        0x00000001b6e9cae8 ffi_call_int + 1208
  [bt] (7) 8   _ctypes.cpython-311-darwin.so       0x0000000102ebc88c _ctypes_callproc + 796
  [bt] (8) 9   _ctypes.cpython-311-darwin.so       0x0000000102eb72ec PyCFuncPtr_call + 220

Any idea what might be causing this error?

If I interpret the error message correctly, there is a problem with the number of edge types in the graph.

Below is one of the graphs to be added to the batch.

Graph(num_nodes={'blobs': 4, 'relation': 2, 'text': 1},
      num_edges={('relation', 'nucleus', 'blobs'): 4, ('relation', 'nucleus', 'relation'): 1, ('text', 'satellite', 'relation'): 1},
      metagraph=[('relation', 'blobs', 'nucleus'), ('relation', 'relation', 'nucleus'), ('text', 'relation', 'satellite')])

Any help would be super appreciated!

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