# Teaching neural networks to understand Petri nets

> Source: <https://hash.dev/blog/gnn-readable-petri-nets>
> Published: 2026-10-22 00:00:00+00:00

Simple graph neural networks miss two features of Petri nets — loops and token conservation — which our new research shows can be incorporated to improve downstream performance

October 22nd, 2026

Our latest preprint, [Structure-Aware Message Passing on Petri Nets through Directed Walks and Incidence Diffusion](https://arxiv.org/abs/2610.29725), focuses on techniques we've developed that improve how **graph neural networks** (GNNs) learn on Petri nets, and this post provides a brief summary (shorter than the original paper's full 27 pages).

A [Petri net](https://petrinaut.org/) is a diagram with large ambitions. Circles are **places** that hold tokens, rectangles are **transitions** that *move* tokens, and arrows (known as arcs) explain how these objects connect, and which way the tokens flow. When a transition fires, it takes tokens from the places feeding it and puts tokens in the places it feeds. These basic rules have been used to describe business processes like manufacturing lines and supply chains for over sixty years. In process mining, Petri nets are the models that get discovered from event logs, checked against them, and then (potentially) simulated. We have [written before](https://hash.dev/blog/sdcpns-common-language) about Petri nets in more detail, and developed extensive tooling for [modeling and simulating](https://petrinaut.org/) Petri nets.

Representing Petri nets in machine-readable form is central to much of our work at HASH, with downstream implications for retrieving similar processes from large libraries that may contain thousands, matching models to event logs, and even feeding process structures into the [Process Foundation Model](https://hash.ai/blog/towards-process-foundation-models) (PFM) we are working towards. Specifically, we want to ensure that GNNs, which compute a vector for each node in a graph by repeatedly combining it with the vectors of its neighbors, are able to understand these Petri nets. [ProcRosetta](https://www.preprints.org/manuscript/202607.0463) already applies a GNN to Petri nets, and our paper starts from two properties of a Petri net that such a simple method might miss.

All a message-passing GNN knows is that a Petri net is a directed, bipartite graph with two kinds of nodes. Running simple message passing leaves the burden of learning complicated substructures in the net completely to the GNN. Luckily, existing literature already names two substructures that matter in real processes.

The first is **process loops**. Rework cycles and retries are directed cycles in the net, and whether or not a node sits on one is of significant importance here. A GNN with a small number of message-passing rounds has a limited receptive field. Depth is not a complete fix, as adding rounds helps only up to a point, before node features [oversmooth](https://arxiv.org/abs/1905.10947). On classifying the loop structure of a net in the benchmark shown below, a three-class problem where guessing scores `0.333`, the baseline GNN scores `0.275`. Scoring below guessing takes (a very biased) effort.

The second is **token conservation**. A Petri net's incidence matrix records the net change in each place's token count when a transition fires. From it, Petri net theory reads off possible conservation laws of the process: weights for places such that their weighted token count never changes, and sequences of transitions whose net effect is zero. In the two nets below, every node has exactly one way out, so if you were walking on the net by following the arcs, you could never tell them apart. Fire both transitions once on the left and nothing changes… but do the same on the right and you'll end up with one more token than you started with (with the difference recorded in the incidence matrix).

**Ask a walker how often it comes home.** Random-walk positional encodings are a standard trick on ordinary graphs: for each node, record the probability that a random walker starting there is back after one step, two steps, and so on. Our walker is a homebody. It respects the one-way arcs, alternates between places and transitions, and reports how often it is back where it started after two steps, four steps, and so on, which makes each coordinate a statement about the directed cycles a node sits on. We call it PNRWPE, which is not pronounceable, but somewhat understandable. Most nodes do not sit on a cycle, though, so the encoding repeats itself: on the benchmark nets, 88.8% of nodes share their signature with another node of the same type in the same net. We were briefly sad about this. Then we averaged the signatures over the places and over the transitions of each net, and this averaged descriptor, fed into a simple nearest-neighbor classifier, identified the loop factor with a balanced accuracy of `1.000`, so we became happy again.

**Let nodes of the same kind talk through the incidence matrix.** From the incidence matrix we build a diffusion operator. Apply it repeatedly and any pattern that breaks token balance decays, while any pattern that keeps it survives. Its powers give a set of numbers for every pair of places or transitions, describing how closely they relate through the net's conservation structure. We use those numbers to weight an extra message between nodes of the same kind in every round, on top of the usual messages along the arcs. We call the resulting model DA-PNGNN (yes, the acronym situation does not improve). In it, every place receives a message from every other place in a single round, which sounds like a recipe for noise, and is one, unless the weights carry information. The zero-kernel control in the next section confirms this.

We tested on two benchmarks. The first is supervised: for each of the 96 process models of the Process Discovery Contest (PDC) 2023, predict the settings of six generation factors (loops, long-term dependencies, optional tasks, and so on) used to produce it, in the setting of [PetriNet2Vec](https://arxiv.org/abs/2404.17129). The second is self-supervised: [ProcRosetta](https://www.preprints.org/manuscript/202607.0463) aligns a Petri net, its process tree, and its event log in a shared latent space, and we ask how well the net's embedding retrieves the other two views. The baseline is ProcRosetta's own Petri net encoder, which the paper calls the PNGNN, and every number is a mean over ten training seeds. We will not be showing detailed results from the second benchmark in this blog post, so as not to annoy you with more tables. If you are interested though, the retrieval gains are summarized after the table, and the full tables are in [our paper](https://arxiv.org/abs/2610.29725).

| Model (PDC 2023) | Macro balanced accuracy | Balanced accuracy on loops | 
|---|---|---|
| Baseline PNGNN | 0.751 | 0.275 | 
| + walk encoding (PNRWPE) | 0.796 | 0.506 | 
| + diffusion kernels (DA-PNGNN) | 0.830 | 0.579 | 
| + both | 0.832 | 0.619 | 

The walk encoding nearly doubles accuracy on loops: the kernels raise macro balanced accuracy by an average of `0.078`, with observable improvements in all ten seeds; and on ProcRosetta, with the configuration chosen on PDC and no retuning, they improve net-to-tree top-1 retrieval accuracy by `4.1` to `5.9` percentage points. The most important control zeroes the kernel values and keeps every parameter and every same-type connection. That model scores `0.686`, below the baseline it was built to improve, so the kernel values carry the gain.

We also tried to fix the walk encoding's weakness on nets without loops, where every signature collapses to a constant, by letting the walker teleport now and then, PageRank-style. The fix passed every diagnostic we could write down: no all-zero signatures remained, and the number of distinct signatures per net doubled or tripled, depending on the setting. It then moved no downstream metric by more than two points, because a teleporting walker comes home along routes that do not exist in the net. The paper reports this at length.

HASH represents processes as Petri nets — both the kind outlined herein, and more advanced extensions of them (such as [Stochastic Dynamic Coloured Petri Nets](https://hash.dev/blog/sdcpns-common-language), also known as *SDCPNs*). To allow machines to reason about these processes, we can exploit the structural information that Petri nets already elegantly encode. Geometric deep learning gives the general rule: when data comes with known symmetries, build an operator that carries those symmetries into the model. The work in our new paper applies that rule twice, and we expect to look to it again for inspiration many more times during the course of our research.

Thank you for reading, and for scrolling to the end if you skipped the middle, which also counts. If you want to hear about our next research and development posts, subscribe below. Until next time!

Get notified when new long-reads and articles go live. Follow along as we dive deep into new tech, and share our experiences. **No sales stuff.**
