Why Small GNN Frameworks Coexist with PyG and DGL
PyTorch Geometric (PyG) and DGL are far larger than TGraphX in users, layers, datasets and published code. So why would a small library exist next to them at all?
The answer is not that the large libraries cannot do the job. Often they can. It is about which cases a library makes convenient by default, what a narrow library can decide for you, and what you give up in exchange. The examples were tested with TGraphX 1.5.1 and PyG 2.8.1 on CPU.
Ecosystem claims age, so here is a dated snapshot. On 26 November 2026, PyG's latest release was 2.8.1 (October 2026) and DGL's latest release on GitHub was v2.4.0 (September 2024). Check both projects' release pages before you commit to either.
Large Frameworks Optimize for Breadth
PyG and DGL are general-purpose GNN libraries, and their defaults reflect a broad user base:
- Vector features are the common case. Most built-in layers expect node features of shape
[N, D], because that covers most benchmark tasks. The containers are more general: PyG'sDatastores node tensors with any trailing shape, and DGL node data only has to have one row per node. - Large layer collections, so published architectures can be reproduced without writing them.
- Wide dataset coverage, because comparing methods needs shared benchmarks.
- APIs that grow as new GNN variants appear in the literature.
Those choices are right for their scope. They also have consequences:
- Tensor-valued nodes take some setup. In PyG, a custom
MessagePassinglayer withnode_dim=0, orGINConvwithnode_dim=0and a convolutional network, handles[N, C, H, W]features. Layers such asGCNConvandSAGEConvexpect vectors. - Some workflows are out of scope. PyG 2.8.1 includes knowledge graph embedding models, Node2Vec, graph autoencoders and an explainability module, but no module for evolutionary graph search or graph reinforcement learning.
- Experiment records depend on how you train. PyG provides
seed_everything. Its GraphGym system, driven by config files, can save the config, writes astats.jsonfor each data split and, by default, saves checkpoints. In a hand-written PyG training loop, which files to write is up to you. Determinism settings are your choice in both cases.
These are design choices, not flaws.
Small Frameworks Can Make Narrow Defaults
A narrower library can commit to a choice that a general one would not impose. TGraphX's choice is that node features are often tensors, so it ships message-passing layers for [N, C, H, W] and [N, C, D, H, W] features next to vector layers for [N, D]. It does not cover every shape: no shipped message-passing layer models a time axis inside a node feature. GCNConv, GATv2Conv and the tensor layers reject [N, T, D], but LinearMessagePassing and the legacy AttentionMessagePassing built with in_shape=(D,) run on it silently, so check x.dim() == 2 or encode the sequence first.
That does not give TGraphX an operator PyG cannot express. Here is the same GIN update in both libraries, with the same weights:
import torch
import torch.nn as nn
from torch_geometric.nn import GINConv
import tgraphx as tgx
torch.manual_seed(0)
x = torch.randn(5, 3, 8, 8) # 5 nodes, each [3, 8, 8]
edge_index = torch.tensor([[0, 1, 2, 3], [1, 2, 3, 4]])
# TGraphX: one constructor call
tgx_layer = tgx.TensorGINLayer(3, 16)
# PyG: the same update, with two choices you make yourself
pyg_net = nn.Sequential(nn.Conv2d(3, 16, 1), nn.ReLU(), nn.Conv2d(16, 16, 1))
pyg_layer = GINConv(pyg_net, node_dim=0) # convolutional MLP, node axis 0
pyg_layer.nn.load_state_dict(tgx_layer.mlp.state_dict()) # same weights
a = tgx_layer(x, edge_index)
b = pyg_layer(x, edge_index)
print(tuple(a.shape), torch.allclose(a, b))
(5, 16, 8, 8) True
The difference is what you have to get right. With PyG you choose the convolutional network and pass node_dim=0; leaving node_dim out can silently give wrong results, as shown in where PyTorch Geometric is strong and what it does not cover. The TGraphX layer fixes both choices and checks the rank of its input:
for bad in (torch.randn(5, 3), torch.randn(5, 8, 8, 3)): # vectors, then channels-last
try:
tgx_layer(bad, edge_index)
except (ValueError, RuntimeError) as err:
print(type(err).__name__, "-", err)
ValueError - x must have shape [N, C, H, W] (spatial_rank=2); got (5, 3).
RuntimeError - Given groups=1, weight of size [16, 3, 1, 1], expected input[5, 8, 8, 3] to have 3 channels, but got 8 channels instead
The second message shows a limit. TGraphX does not detect channels-last input: an [N, H, W, C] tensor has the right rank, so the error comes from PyTorch's convolution, and if the sizes happen to match there is no error at all. Permute to [N, C, H, W] yourself.
Nor is tgx.validate_graph a shape-semantics checker. It checks things such as the edge_index shape, the largest node index, edge-feature and mask lengths and devices, not whether your channel count fits a layer. See shape-aware validation.
Needs at the Edges of the Large Libraries
Ready-made tensor-valued message passing. If your nodes are image patches or volumes, TGraphX saves you writing and testing the layers. Whether keeping the spatial layout improves accuracy is an empirical question for your data, so compare with a flattened baseline.
Several graph tasks in one install. A project that combines GNN training with graph generation, evolutionary structure search, knowledge graph embedding and graph mining can get all of them from one package. Do not overstate the alternative: PyG already covers knowledge graph embedding and Node2Vec, and NetworkX covers classical graph analysis. TGraphX's modules also do not share one data object (knowledge graphs use KnowledgeGraph, evolutionary search uses GraphGenome, mining functions take edge_index and a node count), and the one-call generation, evolution and RL functions are labelled Experimental.
Helpers for run records. tgx.reproducible() seeds the random generators and switches on PyTorch's deterministic settings, the sampling loaders such as NeighborLoader and LinkNeighborLoader take a seed= argument, writer functions save JSON metadata, and a local dashboard reads CSV logs. None of this is on by default: tgx.fit writes no files unless you pass it a logger. The config-driven Runner in tgraphx.experiments does write its own run files.
Errors that name the expected shape. A layer with a narrow input contract can state it, as the ValueError above does. That is easier to arrange in a small library; it is not a claim about how PyG or DGL report errors.
The Complementarity Argument
Small and large frameworks can serve different phases of one project:
| Phase | Reasonable choice |
|---|---|
| Reproducing a published model on a standard benchmark | The library its authors used |
| Message passing on image or volume node features | TGraphX layers, or a custom PyG layer |
| OGB tasks | OGB's evaluators live in the ogb package and are not tied to a GNN library; ogb also ships PyG and DGL data loaders |
| Classical graph analysis before training | NetworkX; tgraphx.mining for measures on edge_index tensors |
| Knowledge graph embedding | PyKEEN, PyG's torch_geometric.nn.kge, or tgraphx.kg |
| Random graph generation | PyG utilities, NetworkX, or tgraphx.generation |
| Seeding and run files | seed_everything plus GraphGym or your experiment tracker, or TGraphX's helpers |
This is not a ranked list. The right tool depends on the phase you are in. See TGraphX and PyTorch Geometric as complementary workflows for concrete examples of using both in one project.
Honest Accounting: What Small Frameworks Trade Away
Smaller community. Fewer users means fewer answered questions, tutorials and pre-trained models. Debugging a TGraphX problem often means reading its source.
Narrower dataset coverage. tgx.load_dataset() covers a limited set of built-in, synthetic and adapter-backed datasets. PyG-backed datasets need pip install "tgraphx[pyg]"; OGB needs the ogb extra and also torch-geometric; there is no DGL extra, so install DGL yourself, after reading the dated warning about its dgl.ai domain in TGraphX vs DGL.
Less exposure to edge cases. Large libraries have been exercised by many more users on more hardware. Where numbers matter, check a small case against a reference. In 1.5.1, for example, tgraphx.mining.modularity returns wrong values, so use NetworkX for modularity.
Maturity. TGraphX is classified as Beta and labels its areas Stable, Beta or Experimental. Experimental interfaces may change between minor releases.
If you need the most community support, the widest benchmark coverage and a well-travelled path for vector-feature GNNs, use PyG or DGL. If your work centres on tensor-valued nodes or on the bundled extras, a smaller library may be worth its costs.
Documentation You Can Check
A narrow scope makes it practical to publish a label for each area. TGraphX does so in its README, in docs/api_stability.md in its GitHub repository, and in a registry: tgx.api_status("TensorGINLayer") returns "stable". The registry does not list every public name and the three sources do not always agree, so check the names you import. What TGraphX supports compares them area by area. For related habits, see TGraphX benchmark disclaimers and explicit auditable graph APIs.
Summary
- Large frameworks optimize for breadth, and most of their built-in layers assume vector features.
- A small framework can package a narrower choice, here tensor-valued message passing plus a few integrated tools, without being able to compute anything the large ones cannot.
- That convenience is paid for with a smaller community, fewer datasets and less testing in the field.
- Choose per phase of your work, and check claims about any library, including this one, against the version you install.
Related Articles
- What is a TGX graph: TGraphX's core design idea
- TGraphX vs PyTorch Geometric: detailed comparison
- TGraphX and PyG as complementary workflows: using both in one project
- Where tensor-native graph learning fits: the wider ecosystem
- Graph learning research integrity: honest evaluation
- Recording benchmark context: what to record with a benchmark number