# How is the performance of GraphNeuralNetworks.jl compared to PytorchGeometric?

**URL:** <https://discourse.julialang.org/t/how-is-the-performance-of-graphneuralnetworks-jl-compared-to-pytorchgeometric/97396>\
**Category:** Machine Learning\
**Tags:** question, package, machine-learning, biochemistry, graphs\
**Created:** [April 12, 2023, 3:27pm UTC](https://discourse.julialang.org/t/how-is-the-performance-of-graphneuralnetworks-jl-compared-to-pytorchgeometric/97396 "2023-04-12T15:27:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DoktorMike](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/doktormike/32/2736_2.png) [@DoktorMike](https://discourse.julialang.org/u/DoktorMike)\
**Post date:** [April 12, 2023, 3:27pm UTC](https://discourse.julialang.org/t/how-is-the-performance-of-graphneuralnetworks-jl-compared-to-pytorchgeometric/97396/1 "2023-04-12T15:27:13Z")

</div>

I’ve been playing around with the excellent `GraphNeuralNetworks.jl` and am thinking about applying it to the biochemistry domain. Specifically within drug discovery. I was wondering if anyone has tried to benchmark speed on CPU and/or GPU for training the same network as compared to [Pytorch Geometric](https://github.com/pyg-team/pytorch_geometric)?

Also if there are any gotchas that I should be on the lookout for? The tasks I’m thinking about are both node level predictions but also full graph predictions.

Sorry for the vague question. 🙂

//Mike

---

<div class="post-metadata">

**Author:** ![CarloLucibello](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carlolucibello/32/3278_2.png) [@CarloLucibello](https://discourse.julialang.org/u/CarloLucibello)\
**Post date:** [April 12, 2023, 4:55pm UTC](https://discourse.julialang.org/t/how-is-the-performance-of-graphneuralnetworks-jl-compared-to-pytorchgeometric/97396/2 "2023-04-12T16:55:37Z")

</div>

It would be nice to compare performance. PyG has plenty of examples, we should try to translate some of them and compare times. Do you have some specific dataset in mind?  
Maybe this example of graph regression on the QM9 datasets could be a good start

> <https://github.com/pyg-team/pytorch_geometric/blob/master/examples/qm9_nn_conv.py>

?  
`Set2Set` has to be implemented yet but it should be easy.

---

<div class="post-metadata">

**Author:** ![DoktorMike](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/doktormike/32/2736_2.png) [@DoktorMike](https://discourse.julialang.org/u/DoktorMike)\
**Post date:** [April 12, 2023, 5:26pm UTC](https://discourse.julialang.org/t/how-is-the-performance-of-graphneuralnetworks-jl-compared-to-pytorchgeometric/97396/3 "2023-04-12T17:26:06Z")

</div>

Yes the QM9 is super relevant. I’ll try to port it. 😊🙏🏻

---

<div class="post-metadata">

**Author:** ![CarloLucibello](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carlolucibello/32/3278_2.png) [@CarloLucibello](https://discourse.julialang.org/u/CarloLucibello)\
**Post date:** [April 12, 2023, 8:50pm UTC](https://discourse.julialang.org/t/how-is-the-performance-of-graphneuralnetworks-jl-compared-to-pytorchgeometric/97396/4 "2023-04-12T20:50:43Z")

</div>

We can omit the `Complete` transformation.  
I opened a PR for Set2Set

> <https://github.com/CarloLucibello/GraphNeuralNetworks.jl/pull/276>

The other ingredient is QM9. Hopefully it can be loaded from

> **[GitHub - simonschoelly/GraphDatasets.jl: A package for downloading and...](https://github.com/simonschoelly/GraphDatasets.jl)**
>
> A package for downloading and working with graph datasets - GitHub - simonschoelly/GraphDatasets.jl: A package for downloading and working with graph datasets

If that doesn’t work, you can try with

```julia
julia> using HuggingFaceDatasets

julia> d = load_dataset("lisn519010/QM9", split="full").with_format("julia")
Dataset({
    features: ['x', 'edge_index', 'edge_attr', 'y', 'pos', 'z', 'name', 'idx'],
    num_rows: 130831
})

```

---

<div class="post-metadata">

**Author:** ![DoktorMike](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/doktormike/32/2736_2.png) [@DoktorMike](https://discourse.julialang.org/u/DoktorMike)\
**Post date:** [April 13, 2023, 11:30am UTC](https://discourse.julialang.org/t/how-is-the-performance-of-graphneuralnetworks-jl-compared-to-pytorchgeometric/97396/5 "2023-04-13T11:30:45Z")

</div>

I found that `QM9` is already available through `MLDatasets.jl`

```julia
using MLDatasets
data = TUDataset("QM9")

```

But it doesn’t have the same number of rows as I would expect. I get 129,433 instead of 133,886. Not sure why. In the file [qm9.csv](https://deepchemdata.s3-us-west-1.amazonaws.com/datasets/qm9.csv) which I think is the original data we have 133,886 rows.

But on TUDatasets website the [qm9.zip](https://www.chrsmrrs.com/graphkerneldatasets/QM9.zip) indeed shows 129,433 graphs.

I’ll double check which one Pytorch Geometric is using in their example.
