Directed Acyclic Graph Neural Networks

Veronika Thost, Jie Chen

Graph Neural Networks (GNNs) have become the standard for learning on graph-structured data. Most popular GNNs rely on a "Message Passing" paradigm (MPNNs), where nodes update their representations by aggregating information from their immediate neighbors. While versatile, MPNNs have a significant limitation: a node's representation is restricted to its $L$-hop neighborhood, where $L$ is the number of network layers.

However, many real-world graphs—such as source code (Abstract Syntax Trees), neural network architectures, or logical formulas—are Directed Acyclic Graphs (DAGs). In these structures, there is a clear, unidirectional "flow" of information. Standard MPNNs treat these directed edges just like any other relation, failing to exploit the strong inductive bias of partial ordering. To address this, researchers propose DAGNN, an architecture designed to allow information to flow sequentially from "source" nodes to "target" nodes, potentially spanning the entire graph in a way that fixed-depth MPNNs cannot.

The DAGNN Architecture

DAGNN moves away from the "past-layer" aggregation of standard MPNNs toward a "current-layer" flow. Nodes are updated sequentially based on their predecessors; a node is only processed once all its predecessors in the current layer have been updated.

DAGNN Architecture

The architecture relies on two primary components at each layer:

  1. Attention Aggregator: To compute a node's incoming message, DAGNN uses an attention mechanism. The node’s representation from the previous layer acts as a "query" to weight the current layer representations of its direct predecessors. This allows the model to dynamically decide which predecessor's information is most relevant.
  2. Recurrent Combiner: Instead of a simple summation, DAGNN uses a Gated Recurrent Unit (GRU). The aggregated message is treated as the hidden state, and the node's previous representation serves as the input. This helps the network "remember" and "digest" information as it flows through the DAG.

For the final graph-level representation, DAGNN pools information specifically from "target" nodes (those with no outgoing edges), as these nodes have theoretically accumulated the summary of the entire graph's flow.

Topological Batching for Efficiency

Processing nodes strictly one by one according to the partial order is computationally slow. To overcome this sequential bottleneck, DAGNN employs topological batching.

Topological Batching

By grouping nodes into topological levels (or batches), all nodes within a single level can be processed in parallel because they do not share dependencies with one another. This technique significantly boosts GPU efficiency, making DAGNN's training time comparable to other specialized DAG architectures and practical for large-scale datasets.

Experimental Setup and Key Results

The model was evaluated across three distinct domains:

  • OGBG-CODE: Over 450,000 Python functions parsed into DAGs, tasked with predicting function names and the length of the longest path.
  • Neural Architectures (NA): Predicting the CIFAR-10 performance of 19,020 neural architectures.
  • Bayesian Networks (BN): Predicting the Bayesian Information Criterion (BIC) score for 200,000 networks.

DAGNN consistently outperformed state-of-the-art MPNNs (like GIN and GAT) and specialized DAG models (like D-VAE). On the OGBG-CODE token prediction task, it achieved an F1 score of 34.41, beating the next best GNN (GAT) at 33.59.

A key insight from the experiments is that inductive bias matters. By forcing the network to respect the DAG's flow, the model learns much more efficiently. For instance, on the Longest Path task, standard GNNs struggled, while DAGNN achieved near-perfect accuracy because its architecture naturally aligns with path-tracing logic. Furthermore, ablation studies confirmed that replacing the attention mechanism with a simpler gated sum led to a significant performance drop, proving the necessity of the query-key interaction for robust DAG representation.

Limitations and Future Directions

Despite its advantages, DAGNN has limitations. Even with topological batching, the model is inherently more sequential than standard MPNNs. For extremely "thin and long" DAGs, the number of sequential steps required could still lead to longer training times compared to "flat" GNNs. Additionally, utilizing GRUs and attention at every node update increases the memory footprint, which may pose challenges for exceptionally large graphs.

Future work may explore integrating DAGNN more deeply into generative models or applying it to other ordered structures like logical circuits and causal inference models.

Summary updated

BibTeX
@inproceedings{thost2021directed,
  author = {Veronika Thost and Jie Chen},
  title = {{Directed Acyclic Graph Neural Networks}},
  booktitle = {International Conference on Learning Representations},
  year = {2021},
}
Figure