Recording Benchmark Context with TGraphX: What You Must Supply Yourself
A bare accuracy is hard to interpret. Suppose two groups report different numbers for the same model on the same public split. The cause could be the sampler seed, feature normalisation, the validation criterion, the number of seeds, the tuning budget or the numerical libraries. A results table shows none of this.
TGraphX helps with part of the problem. Its one-call workflows can write a few JSON files, and tgx.benchmark_card() attaches a fixed disclaimer string to a result. Most of the context has to come from you. This article shows which part is which.
The blocks run in order. Examples tested with TGraphX 1.5.1 on CPU, with synthetic data, so the accuracies they produce mean nothing beyond illustrating the record.
What is written without extra work
classify_nodes, kg_completion and workflow each write three JSON files when you give them out_dir. Without out_dir they write nothing. Other helpers write different files, so do not assume the same set. Here is classify_nodes:
import json
import os
import torch
import tgraphx as tgx
from tgraphx.estimators import node_train_val_test_split
generator = torch.Generator().manual_seed(0)
N = 60
y = torch.arange(N) % 3
x = torch.randn(N, 3, 8, 8, generator=generator) + 0.5 * y.view(-1, 1, 1, 1)
edge_index = torch.randint(0, N, (2, 240), generator=generator)
train, val, test = node_train_val_test_split(N, 0.6, 0.2, 0.2, seed=0)
result = tgx.classify_nodes(x, edge_index, y, train_mask=train, val_mask=val,
test_mask=test, seed=0, device="cpu", out_dir="runs/seed0")
for name in sorted(os.listdir("runs/seed0")):
with open(os.path.join("runs/seed0", name)) as f:
print(name, sorted(json.load(f)))
Output:
benchmark_summary.json ['artifacts', 'config', 'metrics', 'runtime_s', 'task', 'tgraphx_version', 'warnings']
metrics_summary.json ['epochs', 'num_classes', 'num_nodes', 'test_accuracy', 'val_accuracy']
run_metadata.json ['device', 'fast_mode', 'runtime_s', 'seed', 'task', 'tgraphx_version']
There is no dataset name, split description, optimiser, learning rate, hardware or PyTorch version in these files. The only model information is config.model in benchmark_summary.json, and that is an unverified string: whatever you passed as model=, or its default.
Before quoting such a number, know what the helper trains. In the 1.5.1 source, classify_nodes uses one ConvMessagePassing layer with a linear head for tensor features (two GCNConv layers for vector features), Adam with learning rate 5e-3, and neighbour sampling with fanouts [10, 5]. It runs 3 epochs in the default fast_mode (15 otherwise), reports the final-epoch model, and also evaluates on sampled neighbourhoods. Pass all three masks: with none it makes its own random split, and with only train_mask the reported val_accuracy covers every node, training nodes included. It also resets the global random state from seed=.
The model= string is not validated. For vector features any value, including "gat", trains the same two-layer GCN but is recorded as config.model, so do not quote it as the architecture. Even the default records "tensor_gcn" there. With tensor features, model="gat" raises an error instead.
def run(features, model):
return tgx.classify_nodes(features, edge_index, y, model=model, train_mask=train,
val_mask=val, test_mask=test, seed=0, device="cpu")
x_vec = x.mean(dim=(2, 3)) # [N, 3] vector features
as_gat, as_typo = run(x_vec, "gat"), run(x_vec, "not_a_model")
assert as_gat.metrics == as_typo.metrics # the same GCN both times
assert as_gat.config["model"] == "gat" # recorded all the same
try:
run(x, "gat") # tensor features
except ValueError as err:
assert "GCNConv expects vector node features" in str(err)
else:
raise AssertionError("expected an error")
The disclaimer: benchmark_card
card = tgx.benchmark_card(result)
print(card["disclaimer"])
full_run = tgx.benchmark_card({"fast_mode": False, "epochs": 500})
assert full_run["disclaimer"] == card["disclaimer"] # a constant string
Output:
This is a functionality / smoke benchmark, NOT a SOTA claim. Results reflect FAST_MODE or small-scale runs only. Do not compare across systems, hardware, or datasets without matching experimental conditions.
The card is the result dictionary plus the TGraphX version and this text. The text does not depend on what was run, so it also calls a long, careful run a smoke benchmark. Replace it with your own statement if it does not describe your experiment.
The project's release notes are cautious in the same way: the CHANGELOG for 1.4.1 states "No SOTA claims. New APIs are Beta." The reasoning applies to any library. A passing test suite or a short built-in run shows that the code works. It is not a comparison against other methods on the same data with the same tuning budget and seeds, so it cannot support a ranking.
Adding the context: write_benchmark_results
write_benchmark_results(path, **fields) writes exactly the fields you pass to the JSON file you name. It collects nothing and aggregates nothing, and nothing in TGraphX calls it for you. Run your seeds, compute the summary, and describe the setup:
import statistics
from tgraphx.performance import env_report
seeds = [0, 1, 2] # use more for a real comparison
runs = [tgx.classify_nodes(x, edge_index, y, train_mask=train, val_mask=val,
test_mask=test, seed=s, device="cpu").metrics
for s in seeds]
accuracy = [m["test_accuracy"] for m in runs]
tgx.write_benchmark_results(
"runs/summary/benchmark_summary.json",
benchmark="synthetic 3-class node classification (illustration only)",
seeds=seeds,
test_accuracy_per_seed=accuracy,
test_accuracy_mean=statistics.mean(accuracy),
test_accuracy_std=statistics.stdev(accuracy), # sample std (n - 1)
split={"method": "node_train_val_test_split", "seed": 0,
"sizes": [int(train.sum()), int(val.sum()), int(test.sum())]},
# Read from the 1.5.1 source: the helper does not return these.
hyperparameters={"optimizer": "Adam", "lr": 5e-3, "epochs": runs[0]["epochs"],
"train_batch_size": 16, "fanouts": [10, 5], "search": "none"},
evaluation={"metric": "accuracy", "checkpoint": "final epoch",
"inference": "neighbour-sampled"},
environment=env_report(include_hardware=True),
cuda_version=torch.version.cuda,
)
with open("runs/summary/benchmark_summary.json") as f:
assert json.load(f)["seeds"] == seeds
Pass plain numbers and lists. A tensor would be stored as the string "tensor(...)". Here only the seed for initialisation, shuffling and sampling varies; the split is fixed. If your claim is about the method rather than one split, vary the split too and say so.
Checking completeness: audit_run_dir
complete = tgx.audit_run_dir("runs/seed0")
summary_only = tgx.audit_run_dir("runs/summary")
print(complete["ok"], complete["files_missing"])
print(summary_only["ok"], summary_only["files_missing"])
Output:
True []
False ['run_metadata.json', 'metrics_summary.json']
audit_run_dir looks for run_metadata.json, metrics_summary.json and benchmark_summary.json in that one directory, checks that the JSON files parse, and expects seed and tgraphx_version in the run metadata. It does not scan subdirectories. A pass says the files exist and are well formed. It says nothing about leakage, number of seeds or whether the values are right.
What artifacts cannot do
Someone with your code and run files can check that the code runs, that the configuration matches the report and that the metrics match your table. The files alone do not show that the data was preprocessed identically, that the hardware was comparable or that every source of randomness was controlled. Publish the code, the preprocessing, the saved input graphs where licences allow, and a locked environment.
A reporting paragraph to fill in
The brackets are placeholders. Nothing here is a result.
We trained [architecture] on [dataset and version] with TGraphX [version] (Beta) and PyTorch [version] on [device]. Data were split [method, sizes, seed]. We used [optimiser, learning rate, epochs] and selected the checkpoint by [validation criterion]. Hyperparameters were searched over [space and budget], with the same budget for every baseline. We report the mean and sample standard deviation of test [metric] over [k] seeds ([list]). Code and run records: [URL].
For a reusable structure, see the graph experiment report template.
When you should NOT report a benchmark
- A single-seed run presented as a result. Label it preliminary.
- A model selected on test performance. The test score is then optimistically biased.
- A comparison where your model got a larger tuning budget than the baselines.
- A number you cannot reproduce on your own machine. Find out why first.
- A short smoke run, such as three epochs in
fast_mode, as evidence of model quality.
FAQ
Q: Does TGraphX call write_benchmark_results automatically?
A: No. classify_nodes, kg_completion and workflow write their own benchmark_summary.json when given out_dir. Other helpers write different files and not necessarily a benchmark_summary.json: the graph generation and graph RL helpers generate_graph and train_graph_rl, for example, do not. Nothing in the package calls write_benchmark_results for you.
Q: Is there a reproducibility_report.json?
A: No function writes that file. tgraphx.reproducibility.reproducibility_report() returns a dictionary of determinism settings and versions that you can save with json.dump.
Q: Where do the files go?
A: Where you say: the out_dir of a helper, or the path given to a writer.
Q: Can I keep run records in Git?
A: Small JSON files are fine in a repository. Keep checkpoints and large tensors in Git LFS or artifact storage.