{'fraction_non_alphanumeric': 0.03459011465624597, 'fraction_numerical': 0.009275561472065959, 'mean_word_length': 4.32468274837087, 'pattern_counts': {'":': 0, '<': 2, '<?xml version=': 0, '>': 1, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
PatchGT: Transformer over Non-trainable Clusters for Learning Graph Representations

Recently the Transformer structure has shown good performances in graph learning tasks. However, these Transformer models directly work on graph nodes and may have difficulties learning high-level information. Inspired by the vision transformer, which applies to image patches, we propose a new Transformer-based graph neural network: Patch Graph Transformer (PatchGT). Unlike previous transformer-based models for learning graph representations, PatchGT learns from non-trainable graph patches, not from nodes directly. It can help save computation and improve the model performance. The key idea is to segment a graph into patches based on spectral clustering without any trainable parameters, with which the model can first use GNN layers to learn patch-level representations and then use Transformer to obtain graph-level representations. The architecture leverages the spectral information of graphs and combines the strengths of GNNs and Transformers. Further, we show the limitations of previous hierarchical trainable clusters theoretically and empirically. We also prove the proposed non-trainable spectral clustering method is permutation invariant and can help address the information bottlenecks in the graph. PatchGT achieves higher expressiveness than 1-WL-type GNNs, and the empirical study shows that PatchGT achieves competitive performances on benchmark datasets and provides interpretability to its predictions. The implementation of our algorithm is released at our Github repo: https://github.com/tufts-ml/PatchGT.


Introduction
Learning from graph data is ubiquitous in applications such as drug design [15] and social network analysis [37]. The success of a graph learning task hinges on effective extraction of information from graph structures, which often contain combinatorial structures and are highly complex. Early works [7] often need to manually extract features from graphs before applying learning models. In the era of deep learning, Graph Neural Networks (GNNs) [35] are developed to automatically extract information from graphs. Through passing learnable messages between nodes, they are able to encode graph information into vector representations of graph nodes. GNNs have become the standard tool for learning tasks on graph data.
While they have achieved good performances in a wide range of tasks, GNNs still have a few limitations. For example, GNNs [36] suffer from issues such as inadequate expressiveness [36], oversmoothing [28], and over-squashing [2]. These issues have been partially addressed by techniques such as improving message-passing functions and expanding node features [5,21].
Motivated by our question, we propose a new framework, Patch Graph Transformer (PatchGT). It first segments a graph into patches based on spectral clustering, which is a non-trainable segmentation method, then applies GNN layers to learn patch representations, and finally uses Transformer layers to learn a graph-level representation from patch representations. This framework combines the strengths of two types of learning architectures: GNN layers can extract information with message passing, while Transformer layers can aggregate information using the attention mechanism. To our best knowledge, we firstly show several limitations of previous trainable clustering method based on GNN. We also show that the proposed non-trainable clustering can provide more reasonable patches and help overcoming information bottleneck in graphs. We justify our model architecture with theoretical analysis. We show that our patch structure derived from spectral clustering is superior to patch structures learned by GNNs [4,13,39]. We also propose a new mathematical description of the information bottleneck in vanilla GNNs and further show that our architecture has the ability of mitigating this issue when graphs have small graph cuts. The contributions of this paper are summarized as follows.
-We develop a general framework to overcome the information bottleneck in traditional GNNs by applying a Transformer on graph patches in Section 3. The graph patches are from an unlearnable spectral clustering process. -We prove several new theorems for the limitations of previous pooling methods from the 1-WL algorithm in Theorem 1 and Theorem 2. And we theoretically prove that PatchGT is strictly beyond 1-WL and hence has better expressiveness in Theorem 3. Also, in Section 4.4, we show that the segmentations from hierarchical learnable clustering methods may aggregate disconnected nodes, which will definitely hurt the performance of the transformer model. -We demonstrate the existence of information bottleneck in GNNs in Section 4.3. When a graph consists of loosely-connected clusters, we make the first attempt to characterize such information bottleneck. And it indicates when there is a small graph cut between two clusters, the GNNs need to use more layers to pass signals from one group to another. And we further demonstrate with direct attention between groups, PatchGT could overcome such limitations.
We run an extensive empirical study and demonstrate that the proposed model outperforms competing methods on a list of graph learning tasks. The ablation study shows that our PatchGT is able to combine the strengths of GNN layers and Transformer layers. The attention weights in Transformer layers also provide explanations for model predictions.

Related Work
Transformer models have gained remarkable successes in NLP applications [16]. Recently, they have also been introduced to vision tasks [9] and graph tasks [6,11,18,20,24,34,38,40]. These models all treat nodes as tokens. Particularly, Memory-based graph networks [1] apply a hierarchical attention pooling methods on the nodes. GraphTrans [34] directly applies a GNN on all nodes, followed by a transformer. Therefore, they are hard to be applied to large graphs because of huge computation complexity.  Figure 1: Model review. We segment a graph into several patch subgraphs by non-trainable clustering. We first extract local information through a GNN, and the initial patch representations are summarized by the aggregation of nodes within the corresponding patches. To further encode structure information, we apply another patch-level GNN to update the representations of patches. Finally, we use Transformer to extract the representation of the entire graph based on patch representations.
At the same time, image patches have been shown to be useful for Transformer models on image data [9,31], so it is not surprising if graph patches are also helpful to Transformer models on graph data. Graph multiset pooling [3] applies trainable pooling methods on the nodes based on GNN. And then adopt a global attention layer on learned clusters. We will show that such trainable clustering has several limitations for attention mechanism in this work.
Hierarchical pooling models [4,12,13,19,27,39] are relevant to our work in that they also aggregate information from node representations in middle layers of networks. However, these methods all form their pooling structures based on representations learned from GNNs. As a result, these pooling structures inherit drawbacks from GNNs [36]. They may also aggregate nodes that are far apart on the graph and thus cannot preserve the global structure of the input graph. Also such trainable clustering methods need much computation for training. Furthermore, our main purpose is to use non-trainable patches on graphs as tokens for a Transformer model, which is different from these models.

Background
In this work, we consider graph-level learning problems. Let G = (V, E) denote a graph with node set V and edge set E. Let A denote its adjacency matrix. The graph has both node features . Let y denote the label of graph. This work aims to learn a model that maps (A, X, E) to a vector representation g, which is then used to predict the graph label y.
GNN layers. A GNN uses node vectors to represent structural information of the graph. It consists of multiple GNN layers. Each GNN layer passes learnable messages and updates node vectors. Suppose H = (h i ∈ R d : i ∈ V ) are node vectors, a typical GNN layer updates H as follows.
Here matrices (W 1 , W 2 , W 3 ) are all learnable parameters; and σ is the activation function. We denote the layer function by H = GNN(A, E, H). If there are no edge features, then the calculation can be written in matrix form.

Model design
PatchGT has three components: segmenting the input graph into patches, learning patch representations, and aggregating patch representations into a single graph vector. The overall architecture is shown in Figure 1. The second and third steps are in an end-to-end learning model. Graph segmentation is outside of the learning model, which will be justified by our theoretical analysis later.
Forming patches over the graph. We first discuss how to form patches on a graph. One consideration is to include an informative subgraph (e.g., a function group, a motif) into a single patch instead of segmenting it into pieces. A reasonable approach is to run node clustering on the input graph and treat each cluster as a graph patch. If a meaningful subgraph is densely connected, it has a good chance of being contained in a single cluster.
In this work, we consider spectral clustering [30,41] for graph segmentation. Let L = I − D −1/2 AD −1/2 be the normalized Laplacian matrix of G, and its eigen-decomposition is L = UΛU , where the eigen-values Λ = diag(λ 1 , . . . , λ |V | ) is sorted in the ascending order. By thresholding eigen-values with a small threshold γ, we get k = arg max k λ k ≤ γ eigen-vectors U 1:k , then we run k-means to get k clusters (denoted by P) of graph nodes. Here P = {C k ⊂ V : k = 1, . . . , k} with each C k representing a cluster/patch. Note that the threshold γ is a hyper-parameter, and k varies depending on the underlying graph's topology.
Computing patch representations. When we learn representations of patches in P, we consider both node connections within the patch and also connections between patches. Patches form a coarse graph, which is also referred as a patch-level graph, by treating patches as nodes and their connections as edges. We first learn node representations using GNN layers. Let H 0 = X denote the initial representations of all nodes. Then we apply L 1 GNN layers to get node representations H L1 .
Here for easier discussion, we apply GNN layers to the entire graph. We have also tried to apply GNN layers within each patch only and found that the performance is similar.
Then we read out the initial patch representation by summarizing representations of nodes within this patch. Let z 0 k denote the initial patch representation, then Here h L1 i is node i's representation in H L1 . We collectively denote these patch representations in a matrix Z 0 = (z 0 k : k = 1, . . . , k). The readout function readout(·) is a function aggregating information from a set of vectors. Our implementation uses the max pooling. We use the factor |C k | |V | to assign proper weights to patch representations.
To further refine patch representations and encode structural information of the entire graph, we apply further GNN layers to the patch-level formed by patches. We first compute the adjacency matrix A of the patch-level graph. If we convert the partition P to an assignment matrix S = (S i,k : i ∈ V, k = 1, . . . k) such that S i,k = 1[i ∈ C k ], then the adjacency matrix over patches is Note thatÃ only has connections between patches and does not maintain connection strength.
We then compute use L 2 GNN layers to refine patch representations.
GNN layers here do not have edge features. From the last layer, we get patch representations in Z L2 Graph representation via Transformer layers. Then we use L 3 Transformer layers to extract the representation of the entire graph. Here we use a learnable query vector q 0 to "retrieve" the global representation g of the graph from patch representations Z L2 .
Here MHA(·, ·, ·) is the function of a multi-head attention layer (please refer to Chp. 10 of [42]). Its three arguments are the query, key, and value. The two functions MLP(·) and LN(·) are respectively a multi-layer perceptron and a linear layer. Note that patch representations Z L2 are carried through without being updated. Only the query token is updated to query information from patch representations. The final learned graph representation is g, from which we can perform various graph level tasks.

Theoretical Analysis
In this section, we study the theoretical properties of the proposed model. To save space, we put all proofs in the appendix.

Enhancing model expressiveness with patches
On purpose we form graph patches using a clustering method that is not part of the neural network. An alternative consideration is to learn such cluster assignments with GNNs (e.g. DiffPool [39] and MinCutPool [4]. However, cluster assignment learned by GNNs inherits the limitation of GNNs and hinders the expessiveness of the entire model. Theorem 1. Suppose two graphs receive the same coloring by 1-WL algorithm, then DiffPool will compute the same vector representation for them.
Although DiffPool and MinCutPool claims to cluster "similar" graph nodes into clusters during pooling, but these nodes may not be connected. Because of the limitation of GNNs, they may aggregate nodes that are far apart in the graph. For example, nodes in the same orbit always get the same color by the 1-WL algorithm and also the same representations from a GNN, then these nodes always have the same cluster assignment. Merging these nodes into the same cluster does not seem capture the high-level structure of a graph.
Another prominent pooling method is the Graph U-Net [12], which has similar issues. We briefly introduce its calculation here. Suppose the layer input is (A, H), the model's pooling layer projects H with a unit vector p and gets values v = Hp for all nodes, then it chooses the top k nodes that have largest values in v and keep their representations only. We will show that this approach is NOT invariant to node orders.
We also consider a small variant of Graph U-Net for analysis convenience. . We call the model with the variant with thresholding as Graph U-Net-th. We show that the variant of Graph U-Net-th is also bounded by the 1-WL algorithm. Theorem 2. Suppose two graphs receive the same coloring by 1-WL algorithm, then Graph U-Net-th will compute the same vector representation for them.
The two theorems strongly indicate that pooling structures learned by GNNs have the same drawback. We provide detailed analysis for Graph U-Net in Appendix A.3.
In contrast, a small variant of PatchGT is more expressive than the 1-WL algorithm. Figure 7 in Appendix shows two graph pairs that can be distinguished by PatchGT but not the 1-WL algorithm.
In this PatchGT variant, we only need to choose the summation operation to aggregate node representations in the same patch and multiply a scalar to the MHA output. We put the result in the following Theorem. Theorem 3. Suppose a PatchGT uses GIN layers, uses sum-pooling as the readout function in Equation (4), z 0 k = i∈C k h L1 i , and multiplies the MHA output in Equation (7) with the number k of patches, q = k · MHA (q −1 , Z L2 , Z L2 ). Let g 1 and g 2 be outputs computed from two graphs G 1 and G 2 by a PatchGT model. There exists a PatchGT such that g 1 = g 2 if G 1 and G 2 can be distinguished by the 1-WL algorithm. Furthermore, there are graph pairs G 1 = G 2 that cannot be distinguished by the 1-WL algorithm, but g 1 = g 2 from this PatchGT model.
The first part of the conclusion is true because the patch aggregation, patch-level GNN, and the MHA pooling can all be bijective mapping. According to Corollary 6 of [36], the outputs of GIN layers have the same expressive power as the 1-WL algorithm. Such expressive power is maintained in the model output. However, when GIN layers on patches use extra structural information on patches, the model can distinguish graphs that cannot be distinguished by the 1-WL algorithm. We put the formal proof in Appendix A.4.

Permutation invariance
Our model depends on the patch structure formed by the clustering algorithm, which further depends on the spectral decomposition of the normalized Laplacian. Note that the spectral decomposition is not unique, but we show that the clustering result is not affected by sign variant and multiplicities associated with decomposition, and our model is still invariant to node permutations. Theorem 4. The network function of PatchGT is invariant to node permutations.

Addressing information bottleneck with patch representations
Alon et al. [2] recently characterize the issue of information bottleneck in GNNs through empirical methods. Here we consider this issue on a special case when a graph consists of loosely-connected node clusters. Note that molecule graphs often have this property. Here we make the first attempt to characterize the information bottleneck through theoretical analysis. We further show that our PatchGT can partially address this issue.
For convenient analysis, we consider a regular graph with degree τ . Suppose the node set V of G forms two clusters S and T : V = S ∪ T, S ∩ T = ∅, and there are only m edges between S and T .
We consider the difficulty of passing signal from S to T . Let f GNN (·) denote the network function of a GNN of L layers with ReLU activation σ as in (2), and input X = (x i ∈ R d : i ∈ V ) ∈ R |V |×d , which contains d-dimensional feature inputs to nodes in G. Let f GNN i (·) be the output at node i. We can ask this question: if we perturb the input to nodes in S, how much impact we can observe at the output at nodes in T . We need to avoid the case that the impact is amplified by scaling up network parameters. In real applications, scaling up network parameters also amplifies signals within T itself, and the signal from S still cannot be well received. Here we consider relative impact: the ratio between the impact on T from S over that from T itself.
Let α ∈ R |V |×d be some perturbation on S such that α ij ≤ if i ∈ S and α ij = 0 otherwise. Here is the scale of the perturbation. Similarly let β ∈ R |V |×d be some perturbation on T : β ij ≤ if i ∈ T and β ij = 0 otherwise. Then the impacts on node representations f GNN i , i ∈ T from α and β are respectively where the maximum is also over all possible learnable parameters W 1 L1→L1 , W 2 L1→L1 ≤ 1 as in (2). Then we have the following proposition to bound the ratio δ S→T /δ T →T . Proposition 1. Given a τ -regular graph G, a node subset S with its complement T such that there are only m edges between S and T , and a L-layer GNN, it holds that The proposition indicates that when there is a small graph cut between two clusters, then it forms an information bottleneck in a GNN -the network needs to use more layers to pass signal from one Molecules Ours Trainable Molecules Ours Trainable Figure 4: Segmentation results from spectral clustering and trainable clustering.
group to another. The bound is still conservative: if the signal is extracted in middle layers of the network, then passing the signal is even harder. The proposition is illustrated in Figure 3.
In our PatchGT model, communication can happen at the coarse graph and thus can partially address this issue. The coarse graphÃ consists of two nodes (we still denote them by S, T ), and there is an edge between S and T . From the output f GNN , we construct the patch representations Then we apply a GNN layer to get node represents on the coarse graph (g GNN where W 1 , W 2 ∈ R d×d are learnable parameters. We consider the impact of α on our patch GT, let Then we have the following proposition on the ratio η S→T /η T →T . Theorem 5. The ratio η S→T η T →T can be arbitrarily close to 1 in a PatchGT model, under the assumption of regular graphs. This is because S and T are direct neighbors in the coarse graph, then α S can directly impact z S , which can impact g GNN T through messages passed by GNN layers or the attention mechanism of Transformer layers. The right part of fig. 3 shows that patch representation can include signals from the other node cluster.

Comparison for different Segmentation methods
In the previous researches, there exist many hierarchical pooling models [4,12,13,19,27,39]. The most obvious difference from the proposed method is that the pooling/segmentation is trainable. Particularly, the pooling is from the node respresentations learned by GNNs. In the Theorem 1 and Theorem 2, we prove such trainable clustering methods will compute the same representations to the nodes if 1-WL algorithm can not differentiate them. This takes two serious problems for the graph segmentation: First, the nodes with the same representations will be assigned to the same cluster even if they are not connected to each other; Second, too many nodes could be assigned to one cluster to make sure that the nodes far away from each other are in the same cluster.
Here we compare the two segmentation results: one is from spectral clustering and another is from Memory-based graph networks [1] which is a typical trainable clustering method. In the first case, we find that nodes in the blue cluster from trainable clustering are not connected. If we adopt such patch representations by aggregating the disconnected nodes, it will definitely hurt the performance. This can also be applied to other hierarchical pooling methods such as Diffpool, Eigenpool, and MinCutpool.
In the second case, the spectral clustering methods segment the graph by minimum cuts. This is helpful to solve the information bottleneck between patches. However, the Memory-based graph networks cluster the two benzene rings together. It will be difficult for the model to detect the existence of these two benzene rings.

Empirical Study
In this section, we evaluate the effectiveness of PatchGT through experiments.
Datasets. We benchmark the performances of PatchGT on several commonly studied graph-level prediction datasets. The first four are from the Open Graph Benchmark (OGB) datasets [14] (ogbgmolhiv, ogbg-molbace, ogbg-molclintox, and ogbg-molsider). These tasks are predicting molecular attributes. The evaluation metric for these four datasets is ROC-AUC (%). The second group of six datasets are from the TU datasets [25], and they are DD, MUTAG, PROTEINS, PTC-MR, ENZYMES, and Mutagenicity. Each dataset contains one classification task for molecules. The evaluation metric is accuracy (%) over all six datasets. The statistics for the datasets is summarized in Appendix A.11.  Baselines. In this section, we compare the performance of PatchGT against several baselines including GCN [17], GIN [36], as well as recent works Nested Graph Neural Networks [44] and GraphSNN [33]. To compare with learnable pooling methods, we also include DiffPool [39], MinCutPool [4] Graph U-Nets [12], and EigenGCN [23] as baselines for TU datasets. We also include the Graphormer model, but note that Graphormer needs a large-scale pre-training and cannot be easily applied to a wider range of datasets. We also compare our model with other transformerbased models such as U2GNN [26] and SEG-BERT [43].

Quantitative evaluation
Settings. We search model hyper-parameters such as the eigenvalue threshold, the learning rate, and the number of graph neural network layers on the validation set. Each OGB dataset has its own data split of training, validation, and test sets. We run ten fold cross-validation on each TU dataset. In each fold, one-tenth of the data is used as the test set, one-tenth is used as the validation set, and the rest is used as training. For the detailed search space, please refer to Appendix A.12.  Results. Table 1 and Table 2 summarize the performance of PatchGT and other baselines on OGB datasets and TU datasets. We take values from the original papers and the OGB website; EXCEPT the performance values of Nested GIN on the last three OGB datasets -we obtain the three values by running Nested GIN. We also tried to run the contemporary method GRAPHSNN+VN on the other three OGB datasets, but we did not find the official implementation at the submission of this work.
From the results, we see that the proposed method gets good performances on almost all datasets and often outperforms competing methods with a large margin. On the ogbg-molhiv dataset, the performance of PatchGT with GCN is only slightly worse than Graphormer, but note that Graphormer needs large-scale pre-training, which limits its applications.
PatchGT with GCN outperforms three baselines on the other three OGB datasets. The improvements on these three OGB datasets are significant. PatchGT with GCN outperforms baselines on four out of six TU datasets. When it does not outperform all baselines, its performances are only slightly worse than the best performance. Similarly, two other configurations, PatchGT-GIN and PatchGT-DeeperGCN, also perform very well on these two datasets.

Ablation study
We perform ablation studies to check how different configurations of our model affect its performance. The results are shown in Figure 5.
Effect of eigenvalue threshold. The eigenvalue threshold γ influences how many patches for a graph after the segmentation. Generally speaking, larger γ introduces more patches and patches with smaller sizes. When γ is large enough, the number of patches k equals the number of nodes |V | in the graph, and the Transformer actually works at the node level. When the γ is 0, then the whole graph is treated as one patch, and the model is reduced to a GNN with pooling. The left figure shows that there is a sweet point (depending on the dataset) for the threshold, which means that using patches is a better choice than not using patches.
Effect of GNN layer on the coarse graph and Transformer layers. This ablation study removes either patch-level GNN layers or Transformer layers to check which part of the architecture is important for the model performance. From the middle plot in Figure 5, we see that both types of layers are useful, and Transformer layers are more useful. This is another piece of evidence that PatchGT can combine the strengths of different models.
Comparison of readout functions. We compare the performance of PatchGT model using different readout functions when aggregating node representations at each patch in Equation (4). In the right figure, we observe the remarkable influence of the readout function on the performance. Empirical studies indicate max-pooling is the optimal choice under most circumstances.

Understanding the attention
Besides improving learning performances, we are also interested in understanding how the attention mechanism helps the model identify the graph property. We train the PatchGT model on the ogbgmolhiv dataset and visualize the attention weights between query tokens and each patch. Interestingly, the attention only concentrates on some chemical motifs such as Cl O 3 and CON 2 but ignores other very common motifs such as benzene rings. It can be noticed that for the molecule in the first figure, the two benzene rings are connected to each other by -C-C-. However, the model does not pay any attention to this part. The two rings in the molecule of the second molecule are connected by -S-S-; differently, the model pays attention to this part this time. It indicates that Transformer can identify which motifs are informative and which motifs are common. Such property offers better model interpretability compared to the traditional global pooling. It not only makes accurate predictions but also provides some insight into why decisions are made. In the two examples shown above, we can start from motifs SO 3 and -S-S-to look for structures meaningful for the classification problem.

Conclusion and Limitations
In this work, we show that graph learning models benefit from modeling patches on graphs, particularly when it is combined with Transformer layers. We propose PatchGT, a new learning model that uses non-trainable clustering to get graph patches and learn graph representations based on patch representations. It combines the strengths of GNN layers and Transformer layers and we theoretically prove that it helps mitigate the bottleneck of graphs and limitations of trainable clustering. It shows superior performances on a list of graph learning tasks. Based on graph patches, Transformer layers also provides a good level of interpretability of model predictions.
However, the work tested our model mostly on chemical datasets. It is unclear whether the model still performs well when input graphs do not have clear cluster structures.

A.1 Proof of Theorem 1
The proof that DiffPooling cannot distinguish graphs that are colored in the same way by the 1-WL algorithm.

Proof. The function form of a pooling layer in DiffPooling is
Here gnn c (·, ·) learns a cluster assignment S of all nodes in the graph, and gnn r (·, ·) learns node representations.
Note that gnn r has at most the ability of 1-WL algorithm [36]. Two nodes must get the same representation when they have the same color in the 1-WL coloring result. We use an indicator matrix C to represent the 1-WL coloring of the graph, that is, the node i is colored as j if C i,j = 1, then we can write Here the j-th row of B denote the vector representation learned for color j.
If two graphs represented by A and Λ cannot be distinguished by the 1-WL algorithm, then they get the same coloring matrix C (subject to some node permutation that does not affect our analysis here). Now we show that: Let's compare the two matrices on both sides of the equation at an arbitrary entry (k, t). Let α k and α t represent nodes colored in k and t, then the entry at (k, t) is i∈α k j∈αt A i,j , which is the count of edges that have one incident node colored in k and the other incident node colored in t. Since the coloring is obtained by 1-WL algorithm, each node i ∈ α k has exactly the same number of neighbors colored as t. The number of nodes in color k and the number of neighbors in color t are exactly the same for Λ because Λ receives the same coloring as A. Therefore, i∈α k j∈αt A i,j = i∈α k j∈αt Λ i,j , and (18) holds. At the same time, if two graphs cannot be distinguished by 1-WL, they have the same node representations H, then they have the same H .

A.2 Proof of Theorem 2
We first prove a lemma. Lemma 1. Suppose two graphs represented by A and Λ obtain the same coloring from the 1-WL algorithm, then i) the resultant two graphs from removal of nodes in the same color still get the same coloring by the 1-WL algorithm; and ii) the two multigraphs represented by A and Λ still get the same coloring by the 1-WL algorithm.
Here A and Λ are the -th power of the two adjacency matrices, and they represent multigraphs that may have self-loops and parallel edges. The 1-WL algorithm is still valid over graphs with self-loops and multi-edges. A 1-WL style GNN defined in Section 3.1 or [12] is still bounded by the 1-WL algorithm on such multigraphs.
Proof. i) We first consider updating of 1-WL coloring when nodes in a color is removed. Suppose we have stable coloring of graphs represented by A. Let α t and α r denote two groups of nodes in color t and r respectively. We also assume each node in r has t in its color set -if there are not such cases, then we can simply remove nodes in a color and obtain a stable 1-WL coloring.
Suppose we remove nodes in color t from both graphs. Note that all nodes α r have the same number of neighbors in color t. We update the color set of each i ∈ α r by removing color t from it. Then all nodes in α r still get the same color. Therefore, removing the color t from nodes in all relevant color groups gives at least a stable coloring, which, however, might not be the coarsest.
Then we merge some colors when nodes share the same color set. If a node in color r has the same color set as a node in color r , then we assign the same color to both nodes in colors r and r . We run merging steps until no nodes in different colors share the same color set, then the coloring is a stable coloring of the graph, and the resultant coloring of the graph can be viewed as the 1-WL coloring of the graph.
In the procedure above, the step of removing a color, and the steps of merging colors directly operate on nodes' color sets. Since nodes in A and nodes in Λ have the same color sets, therefore, they will have the same color sets after color updates.
The update procedure above purely runs on color relations between different colors. Since A and Λ have exactly the same color relations because they receive the same 1-WL coloring. Therefore, the update procedure above still gives the same stable coloring to A and Λ.
ii) For the second part of the lemma, we first check the coloring of A . We show that the coloring of A is a stable coloring of A . Suppose each node i has a color set C i . In the graph A , i's -th neighbors become direct neighbors of i. The color set of i becomes We know that if two nodes i and i have the same color if and only if their color sets are the same. By using the relation recursively, i and i have the same color set in A . Therefore, the stable coloring of A is also a stable coloring of A . If necessary, we can also run the merging procedure above and eventually get 1-WL coloring of A . With the same argument as above, the operations only run on color sets, therefore, A and Λ have the same coloring.
Now we are ready to prove the main theorem that the Graph U-Net variant cannot distinguish graphs colored in the same way by the 1-WL algorithm.
Proof. In the calculation of Graph U-Net-th, the indicator b for removing nodes is obtained by thresholding v, which is computed by a 1-WL GNN. Therefore, nodes in the same color are always kept or removed all together in b. By using the argument above recursively, the network cannot distinguish the graph at the final outputs if network inputs (A, X) and (Λ, X) cannot be distinguished by the 1-WL algorithm.

Suppose the inputs to a
Remark 1. For graphs with noise or low homophily ratios, the aforementioned issue may not be severe and long-distance aggregation is helpful.

A.3 Analysis for expressiveness of Graph U-Nets
In this section we use an example in Fig. 7 to understand how to maintain a graph's global structure with pooling operations. In a pooling step, DiffPool and MinCutPool will assign nodes in the same color to the same cluster and merge them as one node. Clearly it does not maintain the global structure of the graph and cannot distinguish the two graphs.
Graph U-Net always ranks nodes in one color above nodes of the other color. It is not always permutation invariant: for example, it may get different structures when it breaks tie to take two green nodes. In many cases, it cannot distinguish the two graphs: when it takes three nodes, either three green nodes or two blue and one green nodes, it cannot distinguish the two graphs. The Graph U-Net variant considered above always remove blue or green nodes, thus it cannot distinguish the two graphs. One important observation is Graph U-Net cannot preserve the global graph structure in its pooling steps. For example, when it removes three nodes, the structure left is vastly different from the original graph.
Original graphs Graph segmentation Patch graph Original graphs Graph segmentation Patch graph Figure 7: Two graphs that cannot be distinguished by the 1-WL algorithm. The colors illustrate the 1-WL coloring of graph nodes. In comparison, PatchGT can differentiate them through the patch-level graph.

A.4 A proof showing that PatchGT is more expressive than the 1-WL algorithm
Proof. From the proof of GIN, we know that the two multi-sets {h L1 i : i ∈ G 1 } and {h L1 i : i ∈ G 2 } are already different if the two graphs can be distinguished by the L 1 -round 1-WL algorithm.
Then we show that the rest of a learned network from Equation (4) to Equation (9) is a bijective operation. We first consider the patch aggregation by the sum-pooling is bijective. According to Corollary 6 of [36], and assuming the GIN layers are properly trained, then there is an inverse inv(·) of sum-pooling such that {h L1 i : i ∈ C k } = inv(z 0 ). Then the inverse of patch aggregation is: If the L 2 GNN layers on patches are also properly trained, then the mapping from Z 0 to Z L2 is also bijective. At the same time, we assume vectors in Z L2 are properly transformed, which will be useful in the following MHA operation.
Finally, we consider MHA layers. We first analyze the case with only one layer with one attention head. Note that q 1 = k · softmax q 0 Z L2 / √ d Z L2 with d being the dimension of row vectors in Z 1 . Suppose PatchGT learns the query q 0 to be a zero vector, and the linear transformation in Equation (9) is the identity operation, then g 1 = q 1 = 1 Z L2 , which is the summation of patch vectors Z L2 . Combining the last GIN layer, this summation is a bijective operation according to Corollary 6 of [36]. If there are multiple MHA layers, then we only need the MLP in Equation (8) to zero out the input, and the layer is equivalent to no operation. If there are multiple attention heads, the network can always take the first attention head. Therefore, a general case of MHA layers can also be a summation of input vectors.
Putting these steps together, there is an inverse mapping g 1 to {h L1 i : i ∈ G 1 } and mapping g 2 to {h L1 i : i ∈ G 2 }. Then g 1 and g 2 must be different. We further show that there are cases that cannot be distinguished by the 1-WL algorithm but can be distinguished by PatchGT. Consider two examples in Figure 7. The two original graphs G 1 and G 2 , or G 3 and G 4 , are non-isomorphic. However, both the 1-WL algorithm cannot differentiate them. In comparison, by segmenting these graphs into patches, PatchGT can discriminate G 1 from G2. After segmentation, the two patches from G 1 and the pacthes G 2 can be distinguished by the 1-WL algorithm and also PatchGT. Note that node degrees of G 1 patches are already different from node degrees of G 2 patches. It is the same for G 3 and G 4 . These two examples indicate that the expressiveness of PatchGT is beyond 1-WL algorithm.

A.5 Proof of Theorem 4
We prove the theorem 4 through three lemmas below. Lemma 2. The patches split via k-means are invariant to column vectors in U from the spans of eigenvectors associated with the multiplicities of eigenvalues.
where Q is a standard block-diagonal rotation matrix.
Proof. If we use N u eigenvectors for the graph patch splitting, corresponding to the first N u smallest eigenvalues, we can write them as (λ 1 , u 1 ), ..., (λ Nu , u Nu ). If we have multiplicities in these eigenvalues, we can rotate the eigenvectors by a block-diagonal rotation matrix Q ∈ R Nu×Nu to obtain another set of eigenvectors, From the above three equations, it holds that So for i, j ∈ {1, ..., |V |}, we have The relative distance of new coordinates can be calculated as From the property of the rotational matrix, we have So it holds that So for any two node pair, the relative distance is preserved, thus it will not affect the k-means results.
where P is a permutation matrix.
Proof. We denote I |V | = [1, ..., 1] ∈ R |V |×1 For a permutation matrix P of A, we have the corresponding permutation matrix P such that where A and A are adjacency matrices of G and G respectively. And the for the degree matrix of From the symmetry of the permutation matrix, it holds that Combine the above three equations, we can get So the permuted Laplacian matrix is Substitute into the Laplacian eigen decomposition, we have the equation and its algebraic form so the eigenvalues are remaining invariant.
Next we look at the eigenvector. For a eigenvector of bL , (λ, u ), we have Combine with equation 36, we can get So we have the relation of two corresponding eigenvectors as So we have the relation for the node coordinate [x 1 ; ...; Thus there is a bijective mapping B : n → m such that (P) nB(n) = 1 and x n = x B(n) . Then for any node pair (i, j), we can find (i , j ) = (B(i), B(j)) such that then it clearly holds that So for any two node pair, the relative distance is preserved, thus it will not affect the k-means results.
Using the property of undirected τ -graph, it holds that where we denote and E i , E j ∈ R |V |×1 are unit vectors with ith and jth entry equal to 1 respectively. Then it is trivial to show that ||B S || 1 ≤ 2m.
This finishes the induction.
The above lemma gives max where ||V l || ≤ d and ||r l || 1 ≤ 2d m(l + 1)(τ + 1) l . So when only looking at indices ij with i ∈ T , the first term vanishes and it holds that For the denominator, we simply construct W 1l = W 2l as both identity matrix and take 0 = β.
Then it simply holds that where I T is the indicator vector on set T . Assume it holds, then from the Lipschitz continuity (ReLU) of σ and standard τ -graph, it holds that So that it holds that max Combine equation 68 and equation 73, and substitute the last layer number as L − 1, we have A.8 Proof of Theorem 5 From the proof of proposition 1 in appendix A.7, by simply constructing W 1l , W 2l in the node-level GNN as identity matrix, we have Then from Lipschitz continuity (ReLU) we have and Similarly, we can get and Then we can simply make ||W1||1 ||W2||1 = |S| |T | , so that the ratio is 1.
The assumption of output norm unification can be achieved by standard normalization, such as batch and layer normalizations. Lipschitz continuity exists widely in the activation functions such as ReLU. And most molecules can be modeled as qusi standard graphs. These assumptions are fair assumptions in graph learning. Although it is difficult to universally obtain a precise and tight bound, the existence of such bounds is still helpful for GNN structure design.
Remark 3. The ratio may become informative if there are information bottlenecks within a cluster. We can mitigate the problem by having an appropriate, sufficient number of clusters. However, the number of clusters can not be too large, so there is a tradeoff between avoiding bottlenecks and computational cost.
Here, we also introduce a heuristic example for possibly extending to a non-standard graph. Let subgraph S be an cycle (2-graph) and subgraph T be a clique (n-graph), approximately. And we assume |S| = |T | = n, and node values are all units with perturbation . After one propagation of node level, each node in S has the value 3(1 + ), each node in T has the value n(1 + ). Then at patch level, equations (75), (77), (79) are modified accordingly as η S→T = 3 W 2 , η T →T = n W 1 , then η S→T η T →T = 3 n · W2 W1 , which indicates the unevenness may affect the performance. However, if at patch level W2 W1 ≈ O(n) can be learned, we can still reach a sub-optimal balance. Actually, if W2 W1 > 1 can be learned, it will help mitigate the bottleneck anyway.

A.9 Graph segmentation
As a graph has an irregular structure and contains rich structural information, forming patches on a graph is not as straightforward as segmenting images. The previous works [9,22] generally split an image in the euclidean space. However, graphs are segmented through spectral clustering based on its topology. Figure 8 shows the second eigenvector and patch segmentations based on the algorithm described in Section 3.2. It can be seen that the eigenvectors change along with the graph structures, and the graphs are splitted into several function groups. Such patches are useful for discriminating the property of the given molecule.
A.10 More results Table 7 provides the performance of PatchGT on ogbg-moltox21 and ogbg-moltoxcast.  Table 4 contains the statistics for the six datasets from Open Graph Bechmark (OGB) [14], and Table 5 contains the statistics for the six datasets from TU datasets [25].

A.12 Hyper-parameters selection
We report the detailed hyper-parameter settings used for training PatchGT in Table 6   A.13 Visualization of attention on nodes Figure 9 shows more attention on graphs. We notice that some patches the model concentrates on are far away from each other. This can help address information bottleneck in the graph. Also, it provides more model interpretation.
A.14 Analysis of the computational complexity We compare our computational complexity with the node-level Transformer, Graphormer [38]. The comptutational complexity for both framework can be classified into two parts. The first part is extracting graph structure infromation. For PatchGT, the complexity is O(|V | 3 ) for calculating the eigenvectors and perform kmeans for k patches. For Graphormer, the complexity is O(|V | 4 ) due to node pairwise shortest path computation.
Remark 4. The software and algorithms of eigen-decomposition are being widely developed in many disciplines [10]. The complexity can be reduced to O(|V | 2 ) if a partial query and approximation of eigenvectors and eigenvalues are allowed [8,29]. And spectral clustering does not require all eigenvectors with exact values. However, we admit that for graphs with eigenvalues that are too close to each other, the complexity of computing the eigenvectors takes O(N 3 ).
The second part is neural network computation. For PatchGT, the complexity is O(|E|) for GNN if the adjacency matrix is sparse and O(k 2 ) for Transformer. And for Graphormer, the complexity of Transformer is O(|V | 2 ). It shoud be noticed that for a large graph, k << |V |. Overall, the complexity of patch-level transformer is significantly less than that of applying transformer directly on the node level.
For other hierarchical pooling methods, they also need O(L|E|) to learn the segmentation (L is the number of layers used in GNN), which is comparable to spectral clustering. And spectral clustering is easier for parallel computation. Specifically, for a N pool -level hierarchical pooling, it needs O(

A.15 Frequencies of motifs
There are two classes in ogbg-molhiv, and we record the frequencies of motifs PatchGT pay attention to. There are an apparent difference between the two classes. It indicates the model has a better interpretability.

A.16 Ablation study for patch level GNN
In PatchGT, we apply patch level GNN to the entire graph. We can also apply it to each patch so that there would not be any connection between subgraphs. Here we test the difference of these two designs.