Manuscript Offprint
arXiv:2611.00339Efficient NPN Classification for Large Functions using Graph Neural Network
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Chengdi Cao
University of California,
Los Angeles
Los Angeles, CA, USA
Hanyu Wang
University of California,
Los Angeles
Los Angeles, CA, USA
Wan-Hsuan Lin
University of California,
Los Angeles
Los Angeles, CA, USA
Jason Cong
University of California,
Los Angeles
Los Angeles, CA, USA
Abstract
Two Boolean functions are considered NPN equivalent if one can be transformed into the other by negating inputs, permuting inputs, or negating the output. Efficient NPN classification is valuable in fields such as logic synthesis, quantum computing, and information theory. However, exact NPN classification demands exhaustive enumeration of all possible input permutations and negations. Its complexity grows exponentially, making it impractical for larger functions with more inputs. In this paper, we introduce the first learning-based formulation for NPN classification by recasting it as NPN action prediction. Our method represents Boolean functions as AND-Inverter Graphs (AIGs) and applies a bidirectional heterogeneous graph neural network to predict input negations, output negation, and input permutations. To mitigate the non-canonicality of logic networks, we further introduce graph rewriting techniques that reduce structural ambiguity and recover useful symmetries before prediction. Experimental results show that NPN action prediction is learnable, that the resulting canonicalization quality improves over heuristic baselines, and that on practical benchmarks our method approaches exact methods on tractable cases while scaling to functions with up to 16 inputs.
CCS Concepts
• Hardware → Combinatorial synthesis; • Computing methodologies → Neural networks.
ACM Reference Format:
Chengdi Cao, Hanyu Wang, Wan-Hsuan Lin, and Jason Cong. 2026. GNN-NPN: Efficient NPN Classification for Large Functions using Graph Neural Network. In IEEE/ACM International Conference on Computer-Aided Design (ICCAD '26), November 08–12, 2026, San Jose, CA, USA. ACM, New York, NY, USA, 9 pages. https://doi.org/10.1145/3831252.3834266
1 Introduction
Two Boolean functions are NPN equivalent if one can be transformed into the other through a combination of three operations: input negation, input permutation, and output negation [11, 19]. NPN classification is the task of classifying Boolean functions into NPN-equivalent classes, and is a fundamental problem in logic synthesis. It is also of practical significance in a wide range of applications, including logic optimization [18, 23, 32], technology mapping [6, 7, 12, 14], and emerging technologies such as circuit synthesis for quantum computing [29].
However, NPN classification is computationally challenging due to the combinatorial explosion of possible transformations as the number of input bits increases. Specifically, for an -bit Boolean function, there are input negation patterns, input permutations, and 2 output negations, yielding a total of possible NPN transformations. This exponential growth makes exact NPN classification intractable for functions with more than a few inputs.
Depending on the approach, NPN classifiers can be broadly categorized as either exact or heuristic. Exact methods return provably correct canonical representatives but are typically limited to functions with only a few inputs [16, 23] due to their computational demands. To enable classification of larger functions, a number of heuristic approaches have been proposed. These methods trade optimality for scalability: they attempt to reduce the search space and often work well in practice, but they do not provide the same guarantees as exact methods [12, 21, 27, 34].
This exact-versus-heuristic distinction does not fully capture the practical scalability bottleneck, because the underlying representation also matters. Many existing methods operate on truth tables or on features derived from truth tables. Such methods can prune the NPN search space using function symmetries [1, 2, 5, 34], functionality-based signatures [33], or local search [12], but they still rely on the truth table representation whose size grows exponentially with the number of inputs. As a result, even heuristic methods remain increasingly expensive on larger functions.
In contrast, logic networks such as AND-Inverter Graphs (AIGs) provide a more scalable representation for practical synthesis flows. AIGs are compact, standard in modern synthesis tools, and expose structural regularities such as symmetry that are relevant to NPN transformations. But AIGs are non-canonical: the same Boolean function can be implemented by different graphs. This representation ambiguity poses challenges for learning on logic networks.
In this paper, we propose GNN-NPN, a novel heuristic approach to NPN classification that leverages both data-driven machine learning and structural cues from graph representations of Boolean functions. Specifically, we formulate NPN classification as a problem of predicting NPN actions that move a Boolean function toward its canonical representative. We represent Boolean functions as AIGs and design a graph neural network (GNN) to learn structural and functional features from these graphs for action prediction.
ICCAD '26, San Jose, CA, USA
© 2026 Copyright held by the owner/author(s).
This is the author's version of the work. It is posted here for your personal use. Not for redistribution. The definitive Version of Record was published in IEEE/ACM International Conference on Computer-Aided Design (ICCAD '26), November 08–12, 2026, San Jose, CA, USA, https://doi.org/10.1145/3831252.3834266.
Cao et al.
To mitigate the challenges posed by the non-canonical AIG representation, we further introduce graph rewriting techniques that reduce structural ambiguity and recover useful symmetries before feeding the graphs into the GNN. Together, these components yield a scalable and high-performing heuristic-based workflow for NPN classification on large Boolean functions.
The main contributions of this paper are listed as follows:
(1) We formulate NPN classification as a machine learning problem by casting it as NPN action prediction. This formulation clarifies the relationship among classification, canonicalization, and action prediction, while ensuring that every model output remains a valid NPN transformation (Section 3).
(2) We propose GNN-NPN, an AIG-based action-predictor built on a bidirectional heterogeneous GNN. The model predicts input negations, output negation, and input permutations directly from logic-network structure, enabling graph-based NPN canonicalization on larger functions (Section 4).
(3) We develop a graph rewriting flow for non-canonical AIGs that recovers useful symmetries and reduces structural ambiguity before prediction, improving the consistency of graph representations used by the GNN (Section 5).
(4) We perform extensive experiments to evaluate the method at the levels of action prediction, canonicalization, and practical classification. The results show that GNN-NPN improves canonicalization quality over heuristic baselines, approaches exact methods on tractable problem sizes, and scales to functions with up to 16 inputs (Section 6).
The source code and scripts are available at https://github.com/UCLA-VAST/GNN-NPN.
2 Background
2.1 Boolean Function and Its Representations
A Boolean function with n inputs is a mapping
where . In logic networks, the input bits correspond to primary inputs (PIs) and the output bit corresponds to the primary output (PO). We denote the input vector by . The input variables are ordered from the most significant bit (MSB) to the least significant bit (LSB) .
A truth table is a canonical representation of a Boolean function, since there exists a bijective correspondence between Boolean functions and their truth tables. Truth tables can be denoted as binary strings and the corresponding values are called the lexicographic values of Boolean functions, denoted . For example, the truth table of is and . Truth tables are convenient for defining canonical representatives and for implementing exact algorithms on small functions. However, their size grows exponentially with the number of inputs, making them increasingly expensive for large Boolean functions.
In practice, logic networks, modelled as directed acyclic graphs (DAGs), are more compact for representing large Boolean functions and are more commonly used in logic synthesis workflows. Specifically, AND-Inverter Graphs (AIGs), which consist of two-input AND gates and inverters, have become a de facto standard representation in modern synthesis tools [4]. However, they are non-canonical:
the same Boolean function can be implemented by different logic networks. This tradeoff between scalability and non-canonicity motivates the graph-based learning approach in this paper.
2.2 NPN Equivalence and Canonical Representative
For brevity, throughout this paper, we denote an NPN transformation consisting of input negation , input permutation and output negation as , where is the set of -element permutations. For an input vector , the permutation acts as
Applying a to a Boolean function f yields
where is the bitwise XOR operation.
We define the NPN equivalence relationship as follows:
DEFINITION 1 (NPN EQUIVALENCE). Two Boolean functions and are NPN-equivalent if and only if one can be transformed into the other through an NPN transformation,
Examples of NPN-equivalent Boolean functions can be found in Figure 1, where can be transformed into by applying , , and .
Given logic network implementations of a Boolean function, all Boolean functions that are NPN-equivalent to it can be implemented from the same logic networks by permitting the input bits and adding/removing inverters. Therefore, in logic synthesis workflows, it is sufficient to optimize only one canonical representative for each NPN-equivalent class, which can drastically reduce the size of precomputed libraries. These distinguished Boolean functions are called the canonical representatives of their NPN-equivalent classes. In this paper, we define them in terms of lexicographic value:
DEFINITION 2 (CANONICAL REPRESENTATIVE). The canonical representative of the NPN-equivalence class containing f is the unique Boolean function satisfying
2.3 Graph Neural Network
Since logic networks are naturally represented as graphs, graph neural networks (GNNs) are a natural model family for this domain. GNNs operate on graph-structured data by iteratively propagating and aggregating information over nodes and edges [10].
DAG-structured GNNs specialize this idea to directed acyclic graphs by following the topological order of the graph, which matches the computational structure of AIGs. Such models have already shown promise in logic synthesis tasks including logic optimization [35], symbolic reasoning on Boolean networks [31], and functionality-aware circuit representation learning [26].
Existing heuristic methods often rely on explicitly engineered cues such as symmetry information [1, 2, 5, 34] and function signatures [33] to guide canonicalization. A GNN offers a complementary learned mechanism: it can exploit symmetries already present in the
ICCCAD '26, November 08–12, 2026, San Jose, CA, USA
graph and can also learn distributed representations that play a role similar to structural or functional signatures, without restricting the method to a fixed set of handcrafted features.
3 Formulating NPN Classification as a Machine Learning Problem
For a fixed input size , let denote the set of all -input Boolean functions, and let
denote the set of all -input NPN transformations. The goal of this paper is to perform NPN classification, which we denote as Task 1.
TASK 1 (NPN CLASSIFICATION). Given two Boolean functions , determine whether they are NPN-equivalent,
Most existing methods perform NPN canonicalization by finding the canonical representative [12, 21, 34], which we denote as Task 2.
TASK 2 (NPN CANONICALIZATION). Given a Boolean function , find its canonical representative as defined in Definition 2,
When is available, Task 1 reduces to equality verification:
Although Tasks 1 and 2 have well-defined inputs and outputs, they are not the most suitable interfaces for machine learning. A learned may mistaken non-equivalent pairs as equivalent. Similarly, a learned may output a function that is not even NPN-equivalent to the input. In contrast, if the learning module is restricted to predicting elements of as defined in Equation 6, then every model output is a valid NPN transformation and therefore preserves NPN equivalence by construction. This motivates the following action-prediction formulation.
TASK 3 (NPN ACTION PREDICTION). Given a Boolean function , predict an NPN transformation that maps toward its canonical representative. Ideally, the predicted action solves
so that the predicted action maps to the canonical representative .
The relationship between the three tasks is depicted in Figure 1. To the best of our knowledge, this is the first machine learning formulation for NPN classification. In practice, our learned model approximates the ideal action predictor in Task 3. The predicted action need not be optimal in one step; it only needs to remain within the correct NPN class and move the function toward a better representative, after which local refinement can be applied. We highlight two advantages of this formulation:
(1) The transformed function remains correct by construction. Because every predicted output is a valid NPN transformation, applying it to always produces a function that remains in the same NPN-equivalence class as .
(2) The task tolerates imperfect predictions. The learned predictor does not need to recover the exact minimizer in one step; suboptimal but valid actions can still reduce the lexicographic value and can be further refined by post-processing such as local search.
4 GNN-NPN Action Predictor
We have shown in Section 3 that the fundamental task of NPN classification can be transformed into the task of predicting NPN actions that improve the Boolean function lexicographically. In this section, we present our proposed GNN-NPN action predictor, which is the core of our workflow in Figure 1.
4.1 State Representation
We adopt AIGs as the input representation for GNN-NPN. This choice is motivated by two considerations. First, AIGs are widely used in logic synthesis workflows and can be extracted directly from practical benchmarks. Second, unlike canonical representations such as truth tables, AIGs preserve structural regularities such as symmetry, which are exploited by existing NPN classification methods [34] and can also be exploited by graph learning.
Each node in the AIG is assigned a discrete type label indicating whether it is a PI, AND node, or NOT node. This type label is used to select the appropriate propagation and decoding modules in the heterogeneous GNN described below. The hidden state of every node is initialized to the zero vector.
4.2 Model Architecture
We propose a bi-directional heterogeneous DAG-structured GNN model architecture for our GNN-NPN action predictor, which is illustrated in Fig. 1. Compared to previous works that use DAG-structured GNNs to model AIGs [26], our proposed architecture adds backward propagation and thereby improves the model's ability to predict PI-related tasks such as input negation and input permutation. The architecture is also heterogeneous, in the sense that it uses a separate parameter set for each combination of propagation direction and destination-node type. This model can be applied to AIGs with arbitrary numbers of inputs and gates.
The proposed GNN-NPN architecture processes an AIG in three stages. First, it initializes a -dimensional hidden state for every node to zero. Second, it performs rounds of message passing, where each round consists of a forward sweep that follows the topological order of the AIG and a backward sweep that follows the reverse topological order. Finally, three multi-layer perceptron (MLP) decoder heads are applied to the final node embeddings:
(1) an input-negation decoder that outputs for each PI ,
(2) an output-negation decoder that outputs for the PO,
(3) a permutation decoder that outputs for each PI .
Together, these three heads define the NPN action .
The propagation uses five heterogeneous relation types:
(1) forward updates to AND nodes,
(2) forward updates to NOT nodes,
(3) backward updates to AND nodes,
(4) backward updates to NOT nodes,
(5) backward updates to PI nodes.
Cao et al.

Figure 1: Overview of the proposed GNN-NPN Workflow. At its core, our approach employs an NPN action predictor (introduced in Section 4) that takes AIG as input and produces an NPN action. We demonstrate in Section 3 that this model can be utilized to perform NPN canonicalization for a given function and consequently, perform NPN classification. Additionally, we propose graph rewriting algorithms (detailed in Section 5) to enhance the symmetry in AIG representations.
Each relation type uses the same message-passing rule but with an independent set of parameters. Let denote a propagation type, and let be the neighbors of node participating in type- aggregation at the current propagation level. The update is written schematically as
where , , , and are the type-specific query, key, value, and update parameters, respectively.
4.3 Action Sampling
From the decoder outputs, we sample NPN transformations with a temperature to control the randomness. Larger encourages exploration while smaller leads to more deterministic sampling, and results in greedy deterministic sampling. We use during training to encourage exploration and use deterministic sampling () for the single-trial evaluation settings.
To sample input negation, we transform the PI-negation logits to probabilities using the sigmoid function and sample independently from Bernoulli distributions:
Similarly, the output negation bit is sampled as
To sample the permutation, we use the Plackett-Luce model [22] from the most significant bit (MSB) to the least significant bit (LSB). The permutation decoder outputs one score per PI, and the same score vector is reused at every step. At step , the scores are re-normalized over the currently available PI set , i.e., the PIs
that have not been selected in earlier steps.
After sampling , the selected PI is removed from .
4.4 Training Algorithms
The goal of action prediction is to optimize the Boolean function towards its canonical representation, that is, the NPN-equivalent Boolean function with the minimal lexicographical truth table value.
We consider two training strategies. The first is a supervised baseline derived from exact NPN actions. Input negation and output negation are treated as binary classification tasks, while permutation learning is decomposed into multiple binary classification tasks over all PI pairs, where each label indicates the relative order of the two PIs in the exact permutation.
The second, and primary, strategy is reinforcement learning based on the quality of the sampled action. We design the reward to reflect the reduction in lexicographical value from the original function to the transformed function . Specifically, we normalize the lexicographic improvement to :
We use Group Relative Policy Optimization (GRPO) [25] to optimize the policy. For each Boolean function, we sample a group of G NPN actions and compare the rewards within the group to estimate the advantage of each action.
The weights of the GNN-NPN action predictor are updated using the Proximal Policy Optimization [24] objective for epochs per group, with a clipping factor to avoid drastic updates and an entropy term [30] to regularize the policy. The loss function is
ICCCAD '26, November 08–12, 2026, San Jose, CA, USA
(18)
where is the importance sampling ratio between the action probabilities after and before the update.
5 Graph Rewriting for NPN Classification
Although AIG is an expressive intermediate representation for the GNN in Section 4, it is not a canonical form and inevitably introduces structural bias that can hamper the model's performance. The same Boolean function may be realized by many different graphs. For instance, the function in Fig. 1 can be implemented using either or , each with a different graph structure. This structural variability poses a challenge for GNNs to learn consistent representations for NPN-equivalent functions, as the same function can be represented by different graph topologies.
In this section, we develop two graph rewriting algorithms designed to mitigate this structural variability. In an ideal scenario, logic network rewriting would be both NPN-invariant and exhibit perfect reachability: it would normalize all equivalent functions into a single structural form, differing only in input ordering and inversions. However, such an idealized oracle does not exist, which motivates the use of a learned predictor as introduced in Section 4. Nevertheless, even without achieving perfectly identical graphs, applying specific rewriting rules can reduce structural differences among graphs within the same NPN class. By increasing graph similarity, the rewriting step can improve NPN action prediction and downstream NPN classification accuracy.
5.1 Symmetry Recovery
After graph initialization, we introduce a mapping procedure in Algorithm 1 that scans the graph and recovers symmetries broken by structural bias. The key idea is to identify associative chains of AND gates with uniform polarity and merge them into higher-order super nodes. This transformation preserves functionality while standardizing graph structure, making it easier for GNNs to learn symmetry-aware representations as discussed in Section 4.1. The merged node is treated as an AND-type node by the GNN and therefore reuses the same message-passing parameters as AND nodes.
Figure 2 shows an example where the same three-input AND function can be represented either as or as . Although these representations are functionally equivalent, their different tree structures produce different graph topologies. In our framework, we address this issue by unifying these structures and grouping the entire associative chain into a single super node.
5.2 Ambiguity-Oriented Graph Rewriting
While symmetry recovery focuses on collapsing structurally redundant patterns, our ambiguity-oriented graph rewriting actively reshapes the logic network. This approach both shortens the propagation path of the GNN and increases opportunities for effective symmetry recovery.

(a)

(b)

(c)
Figure 2: Structural ambiguity (a, b) and resolution (c) via node merging.
Algorithm 1 Symmetry-Recovery Mapping
Require: Logic network
Require: Predicate MERGEABLE for associative AND-type merging
1: for all node in do
2: if type and is not yet merged then
3:
4:
5: while is not empty do
6: Pop a node from
7: for all fanin of do
8: if and MERGEABLE then
9:
10: Push into
11: end if
12: end for
13: end while
14: if then
15: Replace nodes in with one AND-type super node
16: end if
17: end if
18: end for
Algorithm 2 Ambiguity-Oriented Rewriting
Require: Logic network
Require: Boolean optimizer that returns equivalent candidates for a given window
1: Initialize:
2: for all window do
3: Let be the current subgraph in
4: functionally equivalent candidates()
5: Initialize: best_cost Cost(), best_cand
6: for all candidate circuit do
7: Cost()
8: if best_cost then
9: best_cost
10: best_cand
11: end if
12: end for
13: Replace in with best_cand
14: end for
15: return
More specifically, our algorithm identifies local rewriting opportunities using a window-based peephole approach. For each window selected for optimization, we employ the resynthesis engine to generate a set of candidate circuits that preserve functionality. Our task is then to evaluate each candidate and select the one that minimizes structural ambiguity and aligns best with the surrounding context.
To guide this decision, we define a cost metric for each candidate circuit based on its potential to merge with neighboring gates into a larger super gate. Formally, for each candidate circuit , we define the ambiguity cost as:
where represents the minimum number of propagation levels in the GNN from node n to any primary input from which
Cao et al.
NPN actions are predicted. More precisely,
Here, match(n, l) is true if node n and its fanin l can be merged by the symmetry-recovery rule, i.e., they have compatible AND-type semantics and the connecting edge satisfies the required polarity.
Overall, the rewriting flow enhances the effectiveness of symmetry recovery, reduces the number of layers between nodes and primary inputs, and improves the efficiency of message passing.
6 Experimental Results
In this section, we evaluate the proposed GNN-NPN workflow from three perspectives: action prediction, canonicalization quality, and practical NPN classification performance. We organize the experiments around the following three research questions (RQs).
RQ1 : How well can GNN-NPN predict NPN actions that improve a Boolean function toward its canonical representative?
RQ2 : How much can the predicted actions improve NPN canonicalization quality compared with existing heuristic methods?
RQ3 : How does the full GNN-NPN workflow perform on practical logic synthesis benchmarks in terms of NPN classification quality and scalability?
6.1 Implementation Details
During training, we generate random AIGs corresponding to 6-input Boolean functions on the fly. For the small-scale evaluations in RQ1 and RQ2, we use a separate set of 1000 random 6-input Boolean functions, for which the exact canonical representative and exact NPN action are computed using the exact_npn implementation in the kitty library [28]. For the practical benchmark evaluation in RQ3, we extract subcircuits with 6–16 inputs from the 20 circuits in the EPFL Combinational Benchmark Suite [3], covering both arithmetic and control circuits. The subcircuits are generated using reconvergence-driven cuts implemented in mockturtle [28].
Our baselines include two heuristics in the kitty library [28] and eleven NPN classification algorithms in ABC [4]. The two kitty heuristics are the flip-swap and sifting heuristics proposed in [12]. Both greedily apply single-bit negations and two-bit swaps until no further lexicographical improvement is found. The testnpn command in ABC provides exact and heuristic NPN classification algorithms selected through its -A option [12, 21, 34]. They are non-learning methods that operate on truth tables rather than AIGs.
For all experiments, we set the embedding dimension and the number of propagation rounds . We use three-layer multi-layer perceptrons (MLPs) for decoding logits. For the GRPO algorithm, the clipping parameter is , the entropy loss weight is , the number of PPO epochs is , the mini-batch size is and the group size is . Adam optimizer [15] with a learning rate and cosine learning rate annealing [17] is used to train our models for 10K steps. All of our experiments are performed on server machines with AMD EPYC 7V13 64-Core Processors and AMD Instinct MI210 GPUs. The models are built using PyTorch [20] and PyTorch Geometric [9].
6.2 Evaluation of Action Prediction
To answer RQ1, we evaluate action prediction on the 1000 random 6-input Boolean functions, where exact NPN actions are available.
Table 1 compares supervised training, GRPO training, and GRPO training with graph rewriting. All three models achieve strong PI/PO negation accuracy. For permutation prediction, the exact permutation accuracy is low, but the pairwise permutation accuracy exceeds 70% for all methods, indicating that the predicted ordering is often locally consistent even when the full permutation is not exactly recovered. This behavior is important because our downstream flow can refine a predicted action with local search. It is also worth noting that the ratio of canonical representative directly achieved with the predicted action is higher than the exact permutation accuracy (Exact), which indicates that some symmetry exists among PIs.
Comparing supervised learning and GRPO, supervised training yields slightly higher direct action-prediction accuracy and initial canonicalization success, whereas GRPO achieves better post-processed canonicalization. This trend is consistent with the idea that reward-based training better aligns the predictor with the downstream objective of improving the representative, especially for permutation prediction. Adding rewriting further improves reward and canonicalization-related metrics, which supports using rewriting in the default workflow adopted later. In the following experiments, we will use the GRPO algorithm with rewriting as the default training algorithm for GNN-NPN, as it achieves the best performance in action prediction and canonicalization.
To isolate the benefits of the proposed architecture, we compare it with uni-directional and homogeneous variants trained using the same GRPO and graph rewriting setup. Removing backward propagation yields near-random PI-related predictions, with input-negation and pairwise permutation accuracies dropped to 47.63% and 50.39%, respectively. The homogeneous variant also degrades all canonicalization metrics, demonstrating the benefits of both bidirectional propagation and type-specific parameters.
6.3 Evaluation of NPN Canonicalization
To answer RQ2, we again evaluate on the same 1000 random 6-input Boolean functions used in RQ1. The ground-truth canonical representative is obtained by exact NPN canonicalization using kitty's exact_npn implementation [28]. We measure the quality of the representative derived by our workflow using
where smaller values are better.
Unless otherwise stated, the reported GNN-NPN results in this subsection use the model trained with GRPO and graph rewriting, and each sampled action is followed by flip-swap or sifting as post-processing for local refinement.
To further enhance the quality of the derived representative, we sample multiple NPN actions from the logits produced by the GNN-NPN predictor. This is inexpensive because it samples from the predicted distribution without additional model inference. We denote the number of sampled actions #Trials. When #Trials = 1, the sampling is deterministic and corresponds to greedy decoding.
ICCCAD '26, November 08–12, 2026, San Jose, CA, USA
Table 1: Evaluation of NPN action prediction for different training algorithms and GNN architecture variants. The columns from left to right are: the accuracy of prediction for input negation , output negation , input permutation (pairwise and exact), reward (defined in Equation 16) achieved by the predicted action, and the ratio of canonical representative achieved directly and with flip-swap and sifting post-processing, respectively. The architecture ablations use GRPO with graph rewriting.
| (Pairwise) | (Exact) | |||||||
|---|---|---|---|---|---|---|---|---|
| Training Algorithm | ||||||||
| Supervised | 87.7% | 96.9% | 71.07% | 4.20% | 0.2232 | 22.30% | 60.78% | 74.66% |
| GRPO | 77.69% | 95.62% | 72.12% | 5.70% | 0.2290 | 19.59% | 60.78% | 76.49% |
| GRPO + Rewriting | 77.47% | 95.83% | 72.31% | 5.71% | 0.2773 | 20.95% | 60.78% | 79.70% |
| GNN Architecture Ablations | ||||||||
| Uni-directional | 47.63% | 68.28% | 50.39% | 0.12% | 0.1962 | 0.12% | 47.50% | 63.78% |
| Homogeneous | 66.04% | 81.07% | 65.96% | 2.16% | 0.2361 | 0.67% | 58.24% | 67.10% |

(a) Flip-swap post-processing.

(b) Sifting post-processing.
Figure 3: Comparison of canonicalization gaps using different post-processing, temperature , and number of trials.
. When #Trials > 1, the sampling is stochastic with a temperature that controls the randomness of sampling. Larger encourages more exploration of the action space.
In Figure 3, we perform grid searches on the number of trials and temperature. Compared to the two baselines that directly apply the flip-swap and sifting post-processing to the original function, GNN-NPN consistently achieves lower gap values, even with a single trial. With more trials and a suitable temperature, GNN-NPN further improves the derived representative and reaches substantially smaller gaps. These results show that the predictor logits provide a useful ranking over candidate NPN actions and that multi-trial sampling is an effective way to exploit that information.
6.4 Evaluation of NPN Classification
Finally, to answer RQ3, we evaluate how well GNN-NPN groups practical Boolean functions into NPN-equivalence classes. This is of practical value in modern logic synthesis workflows, where a precomputed library is indexed by a canonical representative for each function class. At runtime, each lookup tests whether the current function matches one of these representatives, and, on a match, replaces the existing network fragment with the optimized, precomputed structure. Therefore, better NPN classification quality improves optimization opportunities and reduces library size.
We extract subcircuits of 6–16 inputs from the 20 circuits in the EPFL Combinational Benchmark Suite [3] and compare the GNN-NPN workflow against all baselines. The metric is the number of
distinct NPN-equivalence classes obtained after canonicalization, smaller values are better. This metric is appropriate here because all compared methods map each function only to representatives within its own NPN class; therefore, errors manifest as failing to merge equivalent functions, which increases the final number of classes. We set a 10-hour timeout. As shown in Table 2, GNN-NPN with 16 trials and sifting as post-processing achieves performance close to the exact ABC methods (-A 1 and -A 10) on problem sizes where exact methods remain tractable, while continuing to scale to 16-input functions. The exact methods stop at 8 inputs and 12 inputs, respectively. At the same time, GNN-NPN produces fewer classes than all heuristic baselines on larger problem sizes. These results support the central claim of the paper: the proposed workflow closes much of the quality gap to exact methods while retaining the scalability advantages of heuristic methods.
We further analyze the scalability of GNN-NPN by plotting the time-bit curve in Figure 4. The exact methods (-A 1 and -A 10) scale super-exponentially and quickly become intractable as the number of inputs increases. Heuristic methods such as flip-swap, sifting, and -A 9 (the best-performing heuristic in ABC) scale more favorably, but their runtime still increases substantially with the input size. In contrast, GNN-NPN shows a much more favorable scalability, with runtime increasing only slightly as the number of bits increases. This trend is consistent with the graph-based design of GNN-NPN, which avoids exhaustive truth-table manipulation and instead operates on compact logic-network representations.
Cao et al.
Table 2: Performance of NPN classification, quantified by number of NPN equivalent classes reduced from subcircuits of the EPFL Combinatorial Benchmark Suite [3], the smaller the better. The timeout is 10 hours. The best results are in bold.
| Method | Note | 6-bit | 8-bit | 10-bit | 12-bit | 14-bit | 16-bit |
|---|---|---|---|---|---|---|---|
| None | Number of functions | 403672 | 370269 | 360215 | 354395 | 339435 | 334501 |
| kitty [28] | Flip-swap [12] | 2028 | 10507 | 20950 | 31717 | 40537 | 46774 |
| Sifting [12] | 1828 | 10301 | 20573 | 31088 | 39578 | 45344 | |
| ABC testnpn [4] | -A 0 (uniquify) | 12847 | 30099 | 39942 | 55349 | 63054 | 66993 |
| -A 1 (exact) | 1253 | 7829 | timeout | timeout | timeout | timeout | |
| -A 2 | 2151 | 10640 | 21849 | 36470 | 45594 | 50070 | |
| -A 3 | 1321 | 8001 | 17794 | 27442 | 35208 | 40172 | |
| -A 4 | 1291 | 7935 | 17644 | 27116 | 34742 | 39688 | |
| -A 5 | 1314 | 8019 | 17869 | 27938 | 35827 | 40904 | |
| -A 6 | 4503 | 17189 | 27376 | 39591 | 48232 | 54075 | |
| -A 7 | 1314 | 8019 | 17869 | 27938 | 35827 | 40904 | |
| -A 8 | 1253 | 7834 | 17490 | 26981 | 34552 | 39419 | |
| -A 9 | 1253 | 7834 | 17490 | 26981 | 34552 | 39419 | |
| -A 10 (exact) | 1253 | 7829 | 17430 | 26495 | timeout | timeout | |
| GNN-NPN (Ours) | #Trial=16, sifting post-processed | 1253 | 7829 | 17474 | 26512 | 33856 | 38939 |
Table 3: Runtime breakdown and memory footprint of GNN-NPN on EPFL subcircuits at different bit widths.
| Bit Width | 6-bit | 8-bit | 10-bit | 12-bit | 14-bit | 16-bit |
|---|---|---|---|---|---|---|
| Runtime (s) | ||||||
| Graph Rewriting | 3.5 | 22.1 | 38.3 | 79.8 | 150.5 | 294.3 |
| Model Inference | 93.75 | 319.01 | 611.15 | 1245.75 | 1576.11 | 2129.56 |
| Action Sampling | 0.03 | 0.06 | 0.12 | 0.26 | 0.40 | 0.48 |
| Post-Processing | 0.30 | 0.63 | 1.50 | 4.62 | 19.81 | 95.97 |
| Memory Footprint (MB) | ||||||
| CPU Memory | 3.8 | 32.1 | 105.8 | 511.5 | 2227.4 | 9338.3 |
| GPU Memory | 117.9 | 177.7 | 246.6 | 378.5 | 495.5 | 618.8 |

Figure 4: Scalability of exact, heuristic, and GNN-NPN methods on EPFL subcircuits with 6–16 input bits.
Table 3 further reports the runtime breakdown and memory footprint of GNN-NPN. The end-to-end runtime includes graph rewriting, model inference with a batch size of 256 on GPU, action sampling, and post-processing. Model inference is the dominant stage at every bit width.
7 Conclusion and Discussion
In this paper, we introduced a learning-based formulation for NPN classification by casting it as NPN action prediction rather than directly predicting class labels or canonical representatives. Based on this formulation, we proposed a graph-based workflow that represents Boolean functions as AIGs, predicts NPN actions with a bidirectional heterogeneous GNN, and reduces structural ambiguity through graph rewriting. Experimental results showed that the proposed predictor learns useful NPN actions, improves canonicalization quality over heuristic baselines, and achieves practical classification quality close to exact methods on tractable problem sizes while scaling to larger Boolean functions.
A natural question is how to take advantage of the better NPN matching capability offered by GNN-NPN. In our initial experiment, we performed cut enumeration in a given logic network using cut sizes ranging from 6 to 16 following the method in [8], performed NPN-matching against a highly optimized library of small size logic functions [13], and replaced whenever we see an improvement. However, the gain from this simple approach is limited so far. The results from sifting [12] are similar, despite the fact that GNN-NPN can reduce the number of NPN classes by 23%. More research is needed to better utilize the capability offered by GNN-NPN. We also would like to point out that generalization of GNN-NPN beyond EPFL-derived subcircuits has not been verified and may degrade on out-of-distribution circuits.
Acknowledgments
This work was partially supported by NSF grants 2410716 and 2533041, and the CDSC industrial partners (https://cdsc.ucla.edu/partners/).
References
[1] Afshin Abdollahi and Massoud Pedram. 2008. Symmetry detection and Boolean matching utilizing a signature-based canonical form of Boolean functions. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 27, 6 (2008), 1128–1137.
[2] Giovanni Agosta, Francesco Bruschi, Gerardo Pelosi, and Donatella Sciuto. 2009. A transform-parametric approach to Boolean matching. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 28, 6 (2009), 805–817.
[3] Luca Amarú, Pierre-Emmanuel Gaillardon, and Giovanni De Micheli. 2015. The EPFL combinational benchmark suite. In Proceedings of the 24th International Workshop on Logic & Synthesis (IWLS).
[4] Robert Brayton and Alan Mishchenko. 2010. ABC: An academic industrial-strength verification tool. In Computer Aided Verification: 22nd International Conference, CAV 2010, Edinburgh, UK, July 15–19, 2010. Proceedings 22. Springer, 24–40.
[5] Donald Chai and Andreas Kuehlmann. 2006. Building a better Boolean matcher and symmetry detector. In Proceedings of the Design Automation & Test in Europe Conference, Vol. 1. IEEE, 1–6.
[6] Satrajit Chatterjee, Alan Mishchenko, Robert K Brayton, Xinning Wang, and Timothy Kam. 2006. Reducing structural bias in technology mapping. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 25, 12 (2006), 2894–2903.
[7] Jason Cong and Yuzheng Ding. 1994. FlowMap: An optimal technology mapping algorithm for delay optimization in lookup-table based FPGA designs. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 13, 1 (1994), 1–12.
[8] Jason Cong, Chang Wu, and Yuzheng Ding. 1999. Cut ranking and pruning: enabling a general and efficient FPGA mapping solution. In Proceedings of the 1999 ACM/SIGDA Seventh International Symposium on Field Programmable Gate Arrays (Monterey, California, USA) (FPGA '99). Association for Computing Machinery, New York, NY, USA, 29–35. doi:10.1145/296399.296425
[9] Matthias Fey and Jan Eric Lenssen. 2019. Fast Graph Representation Learning with PyTorch Geometric. arXiv preprint arXiv:1903.02428 (2019).
[10] Marco Gori, Gabriele Monfardini, and Franco Scarselli. 2005. A new model for learning in graph domains. In Proceedings. 2005 IEEE International Joint Conference on Neural Networks, 2005, Vol. 2. IEEE, 729–734.
[11] Eiichi Goto and Hidetosi Takahasi. 1962. Some Theorems Useful in Threshold Logic for Enumerating Boolean Functions.. In IFIP Congress, Vol. 62.
[12] Zheng Huang, Lingli Wang, Yakov Nasikovskiy, and Alan Mishchenko. 2013. Fast Boolean matching based on NPN classification. In 2013 International Conference on Field-Programmable Technology (FPT). IEEE, 310–313.
[13] International Workshop on Logic and Synthesis. [n.d.]. IWLS Contest. https://www.iwls.org contest/
[14] Andrew Kennings, Alan Mishchenko, Kristofer Vorwerk, Val Pevzner, and Arun Kundu. 2010. Efficient FPGA resynthesis using precomputed LUT structures. In 2010 International Conference on Field Programmable Logic and Applications. IEEE, 532–537.
[15] Diederik P Kingma and Jimmy Ba. 2014. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980 (2014).
[16] Nan Li and Elena Dubrova. 2011. AIG rewriting using 5-input cuts. In 2011 IEEE 29th International Conference on Computer Design (ICCD). IEEE, 429–430.
[17] Ilya Loshchilov and Frank Hutter. 2016. SGDR: Stochastic gradient descent with warm restarts. arXiv preprint arXiv:1608.03983 (2016).
[18] Alan Mishchenko, Satrajit Chatterjee, and Robert Brayton. 2006. DAG-aware AIG rewriting a fresh look at combinational logic synthesis. In Proceedings of the
43rd Annual Design Automation Conference. 532–535.
[19] Saburo Muroga. 1979. Logic design and switching theory. John Wiley & Sons, Inc.
[20] Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, et al. 2019. Pytorch: An Imperative Style, High-Performance Deep Learning Library. Advances in neural information processing systems 32 (2019).
[21] Ana Petkovska, Mathias Soeken, Giovanni De Micheli, Paolo Ienne, and Alan Mishchenko. 2016. Fast hierarchical NPN classification. In 2016 26th International Conference on Field Programmable Logic and Applications (FPL). IEEE, 1–4.
[22] Robin L Plackett. 1975. The analysis of permutations. Journal of the Royal Statistical Society Series C: Applied Statistics 24, 2 (1975), 193–202.
[23] Richard Rudell. 1993. Dynamic variable ordering for ordered binary decision diagrams. In Proceedings of 1993 International Conference on Computer Aided Design (ICCAD). IEEE, 42–47.
[24] John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov. 2017. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347 (2017).
[25] Zhihong Shao, Peiyi Wang, Qihao Zhu, Runxin Xu, Junxiao Song, Xiao Bi, Haowei Zhang, Mingchuan Zhang, YK Li, Y Wu, et al. 2024. Deepseekmath: Pushing the limits of mathematical reasoning in open language models. arXiv preprint arXiv:2402.03300 (2024).
[26] Zhengyuan Shi, Hongyang Pan, Sadaf Khan, Min Li, Yi Liu, Junhua Huang, Hui-Ling Zhen, Mingxuan Yuan, Zhufei Chu, and Qiang Xu. 2023. Deepgate2: Functionality-aware circuit representation learning. In 2023 IEEE/ACM International Conference on Computer Aided Design (ICCAD). IEEE, 1–9.
[27] Mathias Soeken, Alan Mishchenko, Ana Petkovska, Baruch Sterin, Paolo Ienne, Robert K Brayton, and Giovanni De Micheli. 2016. Heuristic NPN classification for large functions using AIGs and LEXSAT. In Theory and Applications of Satisfiability Testing–SAT 2016: 19th International Conference, Bordeaux, France, July 5–8, 2016, Proceedings 19. Springer, 212–227.
[28] Mathias Soeken, Heinz Riener, Winston Haaswijk, Eleonora Testa, Bruno Schmitt, Giulia Meuli, Fereshite Mozafari, Siang-Yun Lee, Alessandro Tempia Calvino, Dewmini Sudara Marakkalage, et al. 2018. The EPFL logic synthesis libraries. arXiv preprint arXiv:1805.05121 (2018).
[29] Hanyu Wang, Jason Cong, and Giovanni De Micheli. 2024. Quantum state preparation using an exact CNOT synthesis formulation. In 2024 Design, Automation & Test in Europe Conference & Exhibition (DATE). IEEE, 1–6.
[30] Ronald J Williams and Jing Peng. 1991. Function optimization using connectionist reinforcement learning algorithms. Connection Science 3, 3 (1991), 241–268.
[31] Nan Wu, Yingjie Li, Cong Hao, Steve Dai, Cunxi Yu, and Yuan Xie. 2023. Gamora: Graph learning based symbolic reasoning for large-scale Boolean networks. In 2023 60th ACM/IEEE Design Automation Conference (DAC). IEEE, 1–6.
[32] Wenlong Yang, Lingli Wang, and Alan Mishchenko. 2012. Lazy man's logic synthesis. In Proceedings of the International Conference on Computer-Aided Design. 597–604.
[33] Jiaxi Zhang, Shenggen Zheng, Liwei Ni, Huawei Li, and Guojie Luo. 2023. Rethinking NPN classification from face and point characteristics of Boolean functions. In 2023 Design, Automation & Test in Europe Conference & Exhibition (DATE). IEEE, 1–6.
[34] Xuegong Zhou, Lingli Wang, and Alan Mishchenko. 2019. Fast adjustable NPN classification using generalized symmetries. ACM Transactions on Reconfigurable Technology and Systems (TRETS) 12, 2 (2019), 1–16.
[35] Keren Zhu, Mingjie Liu, Hao Chen, Zheng Zhao, and David Z Pan. 2020. Exploring logic optimizations with reinforcement learning and graph convolutional network. In Proceedings of the 2020 ACM/IEEE Workshop on Machine Learning for CAD. 145–150.