I did the similar thing earlier from docs, which also doesn’t have edata lines,
but somehow adding this line causes errors like:
File ~/miniconda3/envs/dgl/lib/python3.10/site-packages/torch/utils/data/dataloader.py:530, in _BaseDataLoaderIter.__next__(self)
528 if self._sampler_iter is None:
529 self._reset()
--> 530 data = self._next_data()
531 self._num_yielded += 1
532 if self._dataset_kind == _DatasetKind.Iterable and \
533 self._IterableDataset_len_called is not None and \
534 self._num_yielded > self._IterableDataset_len_called:
File ~/miniconda3/envs/dgl/lib/python3.10/site-packages/torch/utils/data/dataloader.py:570, in _SingleProcessDataLoaderIter._next_data(self)
568 def _next_data(self):
569 index = self._next_index() # may raise StopIteration
--> 570 data = self._dataset_fetcher.fetch(index) # may raise StopIteration
571 if self._pin_memory:
572 data = _utils.pin_memory.pin_memory(data)
File ~/miniconda3/envs/dgl/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py:40, in _IterableDatasetFetcher.fetch(self, possibly_batched_index)
38 else:
39 data = next(self.dataset_iter)
---> 40 return self.collate_fn(data)
File ~/miniconda3/envs/dgl/lib/python3.10/site-packages/dgl/dataloading/dataloader.py:519, in CollateWrapper.__call__(self, items)
516 if self.use_uva:
517 # Only copy the indices to the given device if in UVA mode.
518 items = recursive_apply(items, lambda x: x.to(self.device))
--> 519 batch = self.sample_func(self.g, items)
520 return recursive_apply(batch, remove_parent_storage_columns, self.g)
File ~/miniconda3/envs/dgl/lib/python3.10/site-packages/dgl/dataloading/base.py:420, in EdgePredictionSampler.sample(self, g, seed_edges)
414 seed_nodes = pair_graph.ndata[NID]
416 exclude_eids = find_exclude_eids(
417 g, seed_edges, exclude, self.reverse_eids, self.reverse_etypes,
418 self.output_device)
--> 420 input_nodes, _, blocks = self.sampler.sample(g, seed_nodes, exclude_eids)
422 if self.negative_sampler is None:
423 return self.assign_lazy_features((input_nodes, pair_graph, blocks))
File ~/miniconda3/envs/dgl/lib/python3.10/site-packages/dgl/dataloading/base.py:243, in BlockSampler.sample(self, g, seed_nodes, exclude_eids)
241 def sample(self, g, seed_nodes, exclude_eids=None): # pylint: disable=arguments-differ
242 """Sample a list of blocks from the given seed nodes."""
--> 243 result = self.sample_blocks(g, seed_nodes, exclude_eids=exclude_eids)
244 return self.assign_lazy_features(result)
/home/neo/notebooks/phoenix/2link_prediction/lp_nopl.ipynb Cell 7' in CustomNeighborSampler.sample_blocks(self, g, seed_nodes, exclude_eids)
29 frontier = dgl.add_self_loop(frontier)
---> 30 block = dgl.transforms.to_block(frontier, seed_nodes)
32 seed_nodes = block.srcdata[dgl.NID]
File ~/miniconda3/envs/dgl/lib/python3.10/site-packages/dgl/transforms/functional.py:2281, in to_block(g, dst_nodes, include_dst_in_src, src_nodes)
2277 else:
2278 # use an empty list to signal we need to generate it
2279 src_node_ids_nd = []
-> 2281 new_graph_index, src_nodes_ids_nd, induced_edges_nd = _CAPI_DGLToBlock(
2282 g._graph, dst_node_ids_nd, include_dst_in_src, src_node_ids_nd)
2284 # The new graph duplicates the original node types to SRC and DST sets.
2285 new_ntypes = (g.ntypes, g.ntypes)
File dgl/_ffi/_cython/./function.pxi:287, in dgl._ffi._cy3.core.FunctionBase.__call__()
File dgl/_ffi/_cython/./function.pxi:232, in dgl._ffi._cy3.core.FuncCall()
File dgl/_ffi/_cython/./base.pxi:155, in dgl._ffi._cy3.core.CALL()
DGLError: [17:02:24] /opt/dgl/src/graph/transform/to_bipartite.cc:119: Check failed: new_dst.Ptr<IdType>()[i] != -1 (-1 vs. -1) : Node 0 does not exist in `rhs_nodes`. Argument `rhs_nodes` must contain all the edge destination nodes.
Stack trace:
[bt] (0) /home/neo/miniconda3/envs/dgl/lib/python3.10/site-packages/dgl/libdgl.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x4f) [0x7f7f15ff0cdf]
[bt] (1) /home/neo/miniconda3/envs/dgl/lib/python3.10/site-packages/dgl/libdgl.so(+0x782c11) [0x7f7f16465c11]
[bt] (2) /home/neo/miniconda3/envs/dgl/lib/python3.10/site-packages/dgl/libdgl.so(std::tuple<std::shared_ptr<dgl::BaseHeteroGraph>, std::vector<dgl::runtime::NDArray, std::allocator<dgl::runtime::NDArray> > > dgl::transform::ToBlock<(DLDeviceType)1, long>(std::shared_ptr<dgl::BaseHeteroGraph>, std::vector<dgl::runtime::NDArray, std::allocator<dgl::runtime::NDArray> > const&, bool, std::vector<dgl::runtime::NDArray, std::allocator<dgl::runtime::NDArray> >*)+0x3a) [0x7f7f164669ea]
[bt] (3) /home/neo/miniconda3/envs/dgl/lib/python3.10/site-packages/dgl/libdgl.so(+0x7842c7) [0x7f7f164672c7]
[bt] (4) /home/neo/miniconda3/envs/dgl/lib/python3.10/site-packages/dgl/libdgl.so(+0x784bc4) [0x7f7f16467bc4]
[bt] (5) /home/neo/miniconda3/envs/dgl/lib/python3.10/site-packages/dgl/libdgl.so(DGLFuncCall+0x48) [0x7f7f16316228]
[bt] (6) /home/neo/miniconda3/envs/dgl/lib/python3.10/site-packages/dgl/_ffi/_cy3/core.cpython-310-x86_64-linux-gnu.so(+0x16b77) [0x7f7f15aa5b77]
[bt] (7) /home/neo/miniconda3/envs/dgl/lib/python3.10/site-packages/dgl/_ffi/_cy3/core.cpython-310-x86_64-linux-gnu.so(+0x1704b) [0x7f7f15aa604b]
[bt] (8) /home/neo/miniconda3/envs/dgl/bin/python(_PyObject_MakeTpCall+0x15e) [0x55a6c14d752e]
I am not sure why this is occurring, with only self_loop() change, as the nodes should be same with/without self-loop unless the reordering nodes from 0 for each block in mfg is being failing somehow.