TGraphX › Insights › TGraphX for Research-Engineering Workflows: A Practical Positioning Note
← Back to Insights

TGraphX for Research-Engineering Workflows: A Practical Positioning Note

Topic: APIs, tooling and research-engineering workflow

TGraphX is a PyTorch graph-learning library whose tensor layers keep node features as [C, H, W] or [C, D, H, W] tensors through message passing, and which also ships helpers for splits, logging and run records. It is Beta software. This note helps you decide whether it fits an experiment you will have to defend later, in a paper, a thesis or a report. Statements about TGraphX were checked against version 1.5.1.

What "research-engineering" means here

It is the work between exploring architectures and running a service: controlled experiments whose numbers will be cited. The priorities are that inputs are checked, runs can be repeated, and every reported number can be traced to a configuration. A very wide choice of layers matters more for broad ablation studies, and deployment tooling matters more for products. Here both are secondary.

What TGraphX 1.5.1 provides

Data and validation

  • Graph(node_features, edge_index, ...) checks shapes, index range, mask lengths and devices at construction.
  • GraphBatch([g1, g2, ...]) batches graphs; GraphDataLoader(GraphDataset(graphs), batch_size=...) iterates over them.
  • Builders such as build_grid_graph, build_knn_graph and build_fully_connected_graph return edge_index tensors; image_to_patches and volume_to_patches cut images and volumes into patches that you can use as node features.

Layers

  • Tensor layers: ConvMessagePassing, TensorGATLayer, TensorGraphSAGELayer, TensorGINLayer.
  • Vector layers: GCNConv, GATv2Conv, APPNP.
  • TGraphXSetAttention for problems without a trusted graph. It learns relations from node content and ignores edge_index.

Beyond one full graph

  • Sampling: NeighborLoader, LinkNeighborLoader, GraphSAINT and Cluster-GCN loaders.
  • Knowledge-graph embeddings (tgraphx.kg), graph mining and algorithms, and Experimental heterogeneous and temporal building blocks.

Experiment records

  • Seeding and environment: set_seed, reproducibility_report(), env_report().
  • Loggers: CSVLogger, TensorBoardLogger, MLflowLogger (the last two need their optional dependencies).
  • Writers: write_run_metadata, write_experiment_config, write_metrics_summary, write_hardware_report.
  • A config-driven Runner and GridRunner, a local dashboard, and .tgx files for Graph and KnowledgeGraph objects.

One limit matters for this audience: in 1.5.1 the config-driven Runner trains on a single full batch and computes no validation loss, so treat it as a smoke runner. On node tasks it also ignores masks set with Graph(train_mask=...): it looks for the key 'train_mask' in metadata['masks'], while Graph stores 'train', so it trains on validation and test nodes too. When a node-level model must be selected on validation data, write the loop yourself, as the shape-checked experiment skeleton does. fit is an option for graph-level tasks with separate training and validation loaders: it reports val_loss each epoch, but it has no early stopping and does not keep the best weights. It also ignores node masks, so on a single graph it would train on validation and test nodes too.

Fit by need

Your need In TGraphX 1.5.1 Also consider
Message passing over [C, H, W] or [C, D, H, W] node features Built-in layers PyG: Data.x can hold such tensors, but most built-in convolutions expect vectors, so you would write the layer
Sequence node features [N, T, D] Graph stores them; no message-passing layer or build_model family is designed for them Reduce to [N, D] first with your own PyTorch module or the Experimental tgraphx.mining.GraphSequenceEncoder (an LSTM over [B, L, D]), then use vector layers
Vector node classification GCNConv, GATv2Conv, APPNP PyG or DGL for a much wider layer collection
Many small graphs GraphBatch and global pooling PyG, DGL
Mini-batch training on a large graph Samplers and loaders (Beta) PyG or DGL if scale is the main difficulty
Multi-GPU or multi-node training Experimental helpers; you set up the process group PyG with PyTorch DDP; DGL's distributed package
Heterogeneous or temporal graphs Experimental PyG; DGL for heterogeneous graphs
Knowledge-graph embeddings tgraphx.kg (TransE and DistMult Beta; ComplEx and RotatE are Beta in the README but experimental in api_status()) PyKEEN, a library dedicated to this task
Classical graph analytics tgraphx.mining and tgraphx.algorithms, small implementations NetworkX, which is far broader
Production serving No serving or model-export tooling Your own PyTorch deployment path

In 1.5.1, tgraphx.mining.modularity returns wrong values (one community containing the whole karate club scores about 0.40 instead of 0). Use networkx.community.modularity for that metric.

Try it on one experiment

Before committing, run one small experiment end to end. The shape-checked experiment skeleton is a runnable script for node classification on [C, H, W] features: it seeds, splits, checks the graph, trains on training nodes, selects on validation nodes, reports on test nodes and writes the run record.

What stays your responsibility

  • Records contain only what you pass. The writers do not collect the git commit, package list or dataset version for you. Convert tensors with .item() first, or they are stored as strings.
  • CSVLogger fixes its columns on the first row and appends to an existing file, so log every key from the start and use a new directory per run.
  • Sampling needs the mask. NeighborLoader seeds every node unless you pass mask=graph.train_mask. After RandomNodeSplit or FixedSplit (from tgraphx.transforms), and for the synthetic:node_classification dataset, graph.train_mask is None, so passing it still seeds every node, and check_leakage(graph) reports ok with nothing checked. There the mask is graph.metadata['masks']['train_mask']. An assert graph.train_mask is not None before building the loader catches the problem.
  • Splits are more than node masks. Pass check_leakage its masks by keyword, because positional arguments bind to the wrong parameters. It does not detect edge leakage or two patches of the same image landing in different splits.
  • Two functions are called set_seed. tgraphx.reproducibility.set_seed(seed, deterministic=True) also turns on PyTorch's deterministic algorithms (warn-only by default); tgx.set_seed does not.
  • Seeds do not make results portable. The same seed on other hardware or library versions can give other numbers.
  • .tgx loading unpickles. Load only files you trust.

The guide to masks, splits and leakage covers the supervision side in detail.

When another tool is the better choice

  • PyG when you need many published architectures for an ablation study, or reference implementations for standard benchmarks.
  • PyG or DGL when scale, distributed training or heterogeneous graphs are central rather than incidental. Check that the release you want supports your PyTorch and CUDA versions.
  • NetworkX when the question is graph analytics and nothing needs to be trained.
  • Plain PyTorch when your aggregation does not fit a message-passing layer and you want to control every operation.

Before installing DGL, read the dated warning about its dgl.ai domain in TGraphX vs DGL.

These tools combine well. tgraphx.interop converts graphs to and from PyG and DGL objects, but check your masks after every conversion. to_pyg_data leaves them under data.metadata['masks'] rather than data.train_mask, and from_pyg_data ignores data.train_mask, data.val_mask and data.test_mask, so reassign them in both directions. The DGL converters do not map masks either.

Beta status

The package metadata says Development Status 4 (Beta), and stability differs between components; tgx.api_status(name) reports the label for the names in its registry. Behaviour can change between releases. For example, 1.5.0 changed the default dropout inside CNNEncoder and the convolutional aggregator of ConvMessagePassing from a hidden 0.3 to 0.0. Pin the version you report (tgraphx==1.5.1 here, which requires Python 3.10 or newer) and read the changelog before upgrading.

Summary

TGraphX is a reasonable choice when your nodes carry spatial tensors, your experiments run on one machine, you are willing to write the training and evaluation loop that decides your numbers, and a Beta dependency is acceptable for the project's lifetime. If node features are plain vectors, or scale and deployment are the hard part, a larger ecosystem is likely to serve you better.

Related guides