Analog circuit matching method based on graph neural network
Through the combination of hypergraph representation and graph neural network, the problems of high time complexity and large memory usage in large-scale circuit matching are solved, and fast and accurate circuit matching is achieved, which significantly improves the efficiency and accuracy of circuit recognition.
Patent Information
- Application Number
- CN202411106893.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-13
- Publication Date
- 2024-11-08
AI Technical Summary
The existing circuit matching method has problems such as high time complexity and large memory usage when dealing with large-scale circuits. The fuzzy matching method has large prediction errors due to information loss and excessive smoothing, which limits its prediction in circuit identification tasks. application.
Using hypergraph representation and fuzzy matching methods based on graph neural networks, circuit features are extracted through hypergraph segmentation and graph neural network models, combined with accurate matching verification, fast and accurate circuit matching is achieved.
It improves the efficiency and accuracy of large-scale circuit matching, reduces calculation and time costs, and significantly improves the accuracy and operating speed of circuit identification.
Smart Images

Figure CN118917258A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of circuit design verification, and specifically relates to an analog circuit matching method based on graph neural network. Background Art
[0002] Existing circuit matching methods usually model the circuit into a graph and then use a subgraph isomorphism algorithm to detect matching subcircuits. This method has the following two main problems:
[0003] 1) Since it is difficult to represent the many-to-many connection relationship between devices and wires with a simple graph, circuits are mostly represented as bipartite graphs. Bipartite graphs introduce edge nodes to represent the connection relationship between a wire and multiple devices. This representation can completely extract the connection relationship of the circuit, but the introduced edge nodes cause redundancy in the representation.
[0004] 2) Existing subgraph matching algorithms are mainly divided into two categories: exact matching methods and fuzzy matching methods. For exact matching methods, such as the VF2 algorithm and the Ullmann algorithm, depth-first search and node similarity calculation are used to traverse and match nodes in the target graph and the query graph, and when the node matching fails, a backtracking process is used to find other possible matching nodes. Therefore, this type of algorithm has an exponential time complexity in the worst case. Although efficient pruning strategies have been developed to reduce the search space, the matching time is still unacceptable when processing large netlists with hundreds of thousands of nodes; and because of the need to store intermediate state information, this type of algorithm requires a large amount of memory space when matching large-scale graphs.
[0005] For the fuzzy matching method, by extracting the features of the graph and matching at the full graph level, the problem of long matching time of the exact matching method is effectively solved. With the development of deep learning, researchers have proposed graph neural networks to realize representation learning of non-Euclidean data. Graph neural networks can extract the structural features of graphs through iterative message aggregation mechanisms, so they have been widely used in subgraph matching tasks. This process can be understood as mapping the sparse adjacency matrix and node feature matrix into low-dimensional dense vectors, and predicting the relationship between graphs through classifiers such as multi-layer perceptrons, or calculating the similarity of feature vectors. However, due to the inevitable information loss in the message passing process, this will lead to certain prediction errors; in addition, each layer of graph neural network can only aggregate the information of the 1-hop neighborhood of the central node, so the number of graph neural network layers required by the model depends on the size of the query circuit. When it is necessary to stack multiple layers of graph neural networks, the features extracted with different nodes as the center tend to converge to the same value, resulting in the "over-smoothing" phenomenon. Especially when dealing with large-scale graphs, it is necessary to use multi-layer graph neural networks to extract features, which further aggravates the information loss. As a key link in the design verification process, circuit matching has a very low tolerance for prediction errors. Therefore, large prediction errors limit the application of fuzzy matching methods in circuit identification tasks.
[0006] In recent years, a two-stage matching method has attracted attention. This method first screens out subcircuits in the target circuit that may match the query circuit through fuzzy matching, and then verifies them through exact matching. Since this method combines the advantages of fast fuzzy matching and high accuracy of exact matching, it has shown significant potential in large-scale circuit matching tasks. However, due to the poor versatility of existing fuzzy matching methods, this method still faces challenges when applied to large query graphs. Summary of the invention
[0007] In order to make up for the shortcomings of the prior art, the present invention aims to provide an analog circuit matching method based on graph neural network to solve the problem of large-scale circuit identification. Firstly, according to the unique structure of the post-simulation netlist of the analog circuit, the hypergraph representation of the netlist is adopted to achieve efficient modeling of the analog circuit; secondly, a general hypergraph subgraph matching method is developed to achieve fast and accurate circuit matching.
[0008] To achieve the above objectives, the specific technical solutions of this application are as follows:
[0009] The analog circuit matching method based on graph neural network comprises the following steps:
[0010] S1. Input two netlists, which are named target circuit and query circuit respectively;
[0011] S2. Extract topology and device properties from the netlist using a netlist parser;
[0012] S3. construct a hypergraph representation of the netlist and perform hypergraph segmentation;
[0013] S4. Perform fuzzy matching of circuits based on graph neural network model to identify potential matching subgraphs;
[0014] S5. Use the exact subgraph isomorphism method to verify the matching results.
[0015] Furthermore, the netlist parser is an automated program developed based on Python language to extract device attributes and device connection relationships in the analog circuit post-simulation netlist.
[0016] Furthermore, the specific process of constructing the netlist hypergraph in step S3 is as follows:
[0017] S31. The transistor is represented as four nodes, which represent the four pins of the drain, source, gate and substrate respectively; the diode is represented as two nodes, which represent the two pins of the cathode and anode respectively; the four pins of the transistor and the two pins of the diode are connected by a hyperedge respectively;
[0018] S32. Encode the parasitic capacitance, the parasitic resistance, the capacitance, the resistance, the I / O, the four pins of the transistor, and the two pins of the diode into an 11-dimensional one-hot vector;
[0019] S33. Use the KaHyPar library to split the hypergraph. Generally, a hypergraph with 100,000 to 200,000 nodes is split into small-scale hypergraphs with 3,000 to 5,000 nodes, and the small-scale graphs are used for training.
[0020] S34. After completing the hypergraph segmentation, start training the graph neural network model.
[0021] Furthermore, the fuzzy matching in step S4 includes a sampling stage, an embedding stage and a query stage, and the graph neural network model includes a model training stage and a model reasoning stage. Both the model training stage and the model reasoning stage include a sampling stage, an embedding stage and a query stage. The model training stage is to train the graph neural network model with existing data so that it can perform sub-graph matching tasks. The model reasoning stage is to use the previously trained model to perform matching on the actual circuit.
[0022] Further, regarding the model training phase:
[0023] Sampling phase: From the target graph G T Randomly sample a node m and extract the k-hop neighborhood of node m and 2k hop neighborhood To form a positive example; then, from G T Sample another node n and its k-hop neighbors and Constitute a negative example; in order to prevent and Satisfying the subgraph isomorphism relationship, Add randomly generated nodes and hyperedges;
[0024] Embedding stage: The obtained positive / negative example association matrix and node feature matrix are input into the GNN model to propagate node features. After message propagation, the feature vector of the hypergraph is obtained.
[0025] Query phase: obtain the predicted value through vector comparison, calculate the difference between the predicted value and the actual label through the loss function, and update the model parameters through back propagation.
[0026] Furthermore, in the embedding stage, the association matrix and node feature matrix of the sampled hypergraph are input into the convolution layer to obtain an embedding vector;
[0027] Furthermore, in the query phase, it is determined whether the two graphs satisfy the following subgraph relationship constraints: For a positive example, query graph G Q Embedding z q Cannot be larger than the target graph G in any dimension T Embedding z t , that is, for positive samples, the expected z q In the embedding space, it is located at z t The lower left of; For negative samples, we expect z q Located in different locations.
[0028] Furthermore, in the query stage, the specific steps of calculating the difference between the predicted value and the actual label through the loss function are:
[0029] R1. Define E to measure the embedding vector z q and z t The degree of constraint violation, the goal of model learning: For positive examples, z q Less than or equal to z in any dimension t , that is, E is 0, indicating that the constraint is not violated; for negative examples, z q At least one dimension is greater than z t , and z q With z t The sample can only be judged as a negative example when E is greater than α, where α is an artificially set positive number;
[0030] R2. Understand the goal of model learning from a spatial perspective: In the embedding space, E represents z q and z t The distance between the positive examples and the expected value z is , and the maximum boundary loss is used as the loss function. q In the embedding space, it is located at z tThe lower left of ; and for negative examples, the expected z q Located elsewhere and related to z t The distance between is at least α;
[0031] R3. Based on the above objectives, the following loss function is set:
[0032]
[0033] Where L is the loss function, z q and z t are the embedding vectors of the query graph q and the target graph t respectively, E is the degree of constraint violation, N is the negative example, P is the positive example, and α is the distance.
[0034] Furthermore, regarding the model inference phase:
[0035] Sampling phase: Check whether the neighborhood of each transistor in the target circuit matches the query circuit. Specifically, for a query graph with a diameter of k hops, extract the k-hop neighborhood of each transistor in the target graph and determine whether each neighborhood satisfies a subgraph isomorphism relationship with the query graph.
[0036] Embedding stage: The model inputs the hypergraph association matrix H and node feature matrix X, and the model outputs the embedding vector z;
[0037] Query phase: compare the embedding vectors of the two input hypergraphs to determine whether the two graphs satisfy the subgraph relationship and give a prediction value.
[0038] Furthermore, the exact matching in step S5 is used to verify the subgraph in the target graph that may match the query graph, and the specific operation process is as follows:
[0039] S51. Convert the hypergraph into a graph using star expansion;
[0040] S52. Call the VF3 library implemented in Python language to perform precise verification and obtain the precise result of whether each pair of subgraph samples of the query graph and the target graph matches.
[0041] Compared with the prior art, the present invention has the following advantages:
[0042] 1) The present invention adopts hypergraph for modeling. Hypergraph can more effectively represent the complex relationship between devices and interconnects in the circuit, where nodes represent devices and hyperedges represent interconnects. In this way, the hypergraph model can capture the topological structure and device properties of the circuit, providing a more accurate and efficient basis for the subsequent matching process.
[0043] 2) The present invention improves the matching efficiency of large-scale circuits while maintaining high matching accuracy, and can effectively deal with the identification problem of large-scale circuits; a fuzzy matching method based on a hypergraph neural network is used to preliminarily screen out possible subgraph candidate sets, and the transitivity of subgraph relationships is used to simplify the matching at the graph level to the node level; then, the idea of contrastive learning and the method of sequential embedding are introduced, and the model is guided to obtain an embedding vector that satisfies the subgraph relationship constraints through the maximum boundary loss. At the same time, the training method of curriculum learning and the matching strategy around transistors are used to optimize the accuracy and reasoning time of the model respectively. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 is a flowchart of the method of the present invention;
[0045] Figure 2 It is a circuit matching flow chart of the present invention;
[0046] Figure 3 It is a flowchart of the fuzzy matching method of the present invention;
[0047] Figure 4 It is a diagrammatic representation of the group expansion and star expansion of the present invention. DETAILED DESCRIPTION
[0048] In order to enable those skilled in the art to more clearly understand the technical solution of the present application, an analog circuit matching method based on a graph neural network of the present invention is further described below in conjunction with the accompanying drawings.
[0049] like Figure 1 and Figure 2 As shown, a method for analog circuit matching based on graph neural network is used to determine whether the query circuit is a subcircuit of the target circuit and output all subcircuits matching the query circuit. The specific steps of the method include:
[0050] (i) Input two netlists, denoted as target circuit and query circuit respectively.
[0051] (ii) Use a netlist parser to extract topology and device properties from the netlist.
[0052] The netlist parser is an automated program developed based on Python language to extract the device properties and device connection relationships in the simulated circuit netlist. Input the circuit netlist in DSPF format, and the netlist parser extracts the topology structure and device properties of the circuit in the netlist.
[0053] (iii) Construct a hypergraph representation of the netlist and perform hypergraph segmentation.
[0054] Using the structure and attribute information extracted by the circuit parser, the circuit is modeled as a hypergraph, where nodes represent devices or pins and hyperedges represent connection lines. The specific process of building a netlist hypergraph is as follows:
[0055] (1) The transistor is represented by four nodes, each representing its four pins (i.e., drain, source, gate, and substrate); the diode is represented by two nodes, each representing its two pins (i.e., cathode and anode); the four pins of the transistor and the two pins of the diode are connected by a hyperedge.
[0056] (2) In order to represent the properties of different devices / pins, one-hot encoding is introduced as the feature of the node. Specifically, five types of devices / pins (parasitic capacitance, parasitic resistance, capacitance, resistance, I / O), four transistor pins, and two diode pins are encoded as an 11-dimensional one-hot vector. This not only minimizes the number of nodes and edges required, but also eliminates the need to introduce hyperedge weights.
[0057] (3) After obtaining the above hypergraph, a method based on graph neural network is used to perform fuzzy matching of the circuit. Since the hypergraph corresponding to the circuit used has hundreds of thousands of nodes, the sampling process of directly using this large hypergraph for the training phase is slow. Therefore, the hypergraph is first segmented using the hypergraph segmentation tool KaHyPar. Generally, a hypergraph with 100,000 to 200,000 nodes is segmented into small-scale hypergraphs with 3,000 to 5,000 nodes, and the small-scale graph is used for training. Note: When using the trained model for inference, it is not necessary to segment the input hypergraph.
[0058] (4) After completing the hypergraph segmentation, start training the graph neural network model.
[0059] (iv) Perform fuzzy matching of circuits based on the graph neural network model and identify potential matching subgraphs.
[0060] Fuzzy matching includes sampling, embedding and querying stages. The model training stage uses existing data to train the graph neural network model so that it can perform subgraph matching tasks; the model reasoning stage uses the previously trained model to match the actual circuit (i.e., perform subgraph matching tasks), so there is no need for backpropagation in the training stage to update the parameters. Both the model training stage and the model reasoning stage include three steps: sampling, embedding and querying. The difference between the model training stage and the model reasoning stage is that in order to simplify the sampling process, hypergraph segmentation is used in the training stage; while the model reasoning stage does not use hypergraph segmentation to prevent the circuit to be queried from being segmented and unable to be matched.
[0061] Note: The concepts of machine learning model training and inference, as well as loss functions, are common knowledge to those skilled in the art, and therefore will not be introduced in detail here.
[0062] (1) Model training phase
[0063] ① Sampling stage
[0064] After the hypergraph is split, the small-scale hypergraph of 3000 to 5000 nodes is sampled to generate data for graph neural network training. The contrastive learning method is used to sample positive and negative examples from the small-scale hypergraph to train the graph neural network model. The generalization performance of the model is enhanced by randomly sampling positive and negative examples. First, from the target graph G T Randomly sample a node m from the cluster; then extract the k-hop neighborhood of node m and 2k hop neighborhood To form a positive example; from G T Sample another node n and its k-hop neighbors and To prevent and Satisfying the subgraph isomorphism relationship, Add randomly generated nodes and hyperedges.
[0065] ②Embedding stage
[0066] The association matrix and node feature matrix of the positive / negative examples obtained by the above method are input into the GNN model for training / inference.
[0067] The learning goal of the graph neural network model is to constrain the subgraph relationship, that is, sequential embedding. First, define the constraints of the subgraph relationship: For a positive example, query the graph G Q Embedding z q Cannot be larger than the target graph G in any dimension T Embedding z t In other words, we expect z q In the embedding space, it is located at z t The lower left of; For negative examples, the expected z q Located in different locations.
[0068] The graph neural network model includes a hypergraph convolution layer, a linear layer, a pooling layer, and skip connections between convolution layers. The convolution layer uses the hypergraph convolution layer in the Pytorch.geometric library to obtain the embedding vector z of the hypergraph. The specific parameter settings of the model refer to the parameter settings verified in the embodiment. The specific calculation formula of the model is as follows:
[0069]
[0070] Where H and X are inputs, D is calculated from H, and W is learned by the model during training. The activation function σ uses ReLU. After several convolutional layers (the number of convolutional layers depends on the size of the input hypergraph), the embedding vector z of the input hypergraph can be obtained.
[0071] Skip connections between convolutional layers are used to solve the over-smoothing problem. For a query graph with a given diameter of k hops, if node m in the query graph matches node n in the target graph, it is necessary to extract the k-hop neighborhood of node n to ensure full coverage of the query graph. Since each convolution operation aggregates messages from the 1-hop neighborhood, a k-hop subgraph requires at least 2k convolutional layers. However, when multiple convolutional layers are stacked, the k-hop neighborhoods of adjacent nodes overlap excessively, leading to the "over-smoothing" problem, that is, the expressive power of the model decreases due to the similarity of node embeddings. Therefore, skip connections are introduced to alleviate the problem of over-fusion of information caused by stacking convolutional layers by directly fusing the node embeddings of the shallow network with the node embeddings of the deep network. Specifically, skip connections allow the model to retain the original information of each layer of node embedding when performing multiple layers of convolution, rather than relying solely on the embedding representation of the last layer.
[0072] Given that the sizes of subgraphs with different numbers of hops vary significantly, curriculum learning is introduced during the training phase to improve the convergence speed of the model. Curriculum learning is a model training method that mimics the human learning process. In the early stages of training, the model is trained on small batches or small-scale graphs; when the model performance is stable, the scale and complexity of the training data are gradually increased. Curriculum learning enables the model to efficiently find local optimality in the early stages of training, thereby improving convergence speed and prediction accuracy. In this application, the graph neural network model is initially trained on a 2-hop query graph. When the training accuracy of the model is stable, the scale of the training graph data is gradually expanded, increasing by 1 hop each time.
[0073] ③Query stage
[0074] The prediction value is obtained by comparing the vectors. In the embedding stage, the embedding vector of the hypergraph is obtained. The idea of partial order relationship learning is adopted to determine whether the two graphs satisfy the subgraph relationship by comparing the embedding vector sizes of the two graphs. Specifically, if the embedding vector z q In any dimension, it is smaller than z t , then the model predicts that q is a subgraph of t; if any dimension does not meet the condition that is less than , then the model predicts that q is not a subgraph of t.
[0075] The difference between the predicted value and the actual label is calculated through the loss function, and the model parameters are updated through back propagation. The specific steps for calculating the difference between the predicted value and the actual label through the loss function are:
[0076] R1. Define E to measure the predicted value z q and zt The degree of constraint violation. If z q Less than or equal to z in any dimension t , then E is 0, indicating that the constraint is not violated. q Greater than z in at least one dimension t , then E is greater than 0, indicating a constraint violation.
[0077] R2. The learning goal of the model is: for positive examples, z q Less than or equal to z in any dimension t , that is, E is 0, indicating that the constraint is not violated; for negative examples, z q At least one dimension is greater than z t , and z q With z t The sample can only be judged as a negative example when E is greater than α, where α is an artificially set positive number.
[0078] R3. Understand the goal of model learning from a spatial perspective: In the embedding space, E represents z q and z t The distance between the positive examples and the expected value z is , and the maximum boundary loss is used as the loss function. q In the embedding space, it is located at z t The lower left of ; and for negative examples, the expected z q Located elsewhere and related to z t The distance between is at least α;
[0079] R4. Based on the above objectives, the following loss function is set:
[0080]
[0081] Where L is the loss function, z q and z t are the embedding vectors of the query graph q and the target graph t respectively, E is the degree of constraint violation, N is the negative example, P is the positive example, and α is the distance.
[0082] The difference between the predicted value and the actual label is calculated through the loss function, and the model parameters are updated through back propagation. The role of the above loss function is to calculate the gap between the model's predicted value for the input data and the actual label of the input data. The size of the gap is quantitatively calculated through the loss function, and the model's learnable parameters are updated in back propagation to obtain a predicted value that is closer to the actual label.
[0083] After the above training process, a trained machine learning model can be obtained, which can make reasonable predictions on whether the two input hypergraphs satisfy the subgraph relationship.
[0084] (2) Model inference stage
[0085] ① Sampling stage
[0086] The sampling method in the model reasoning phase is the same as that in the model training phase. However, the sampling phase samples the hypergraph of 3,000 to 5,000 nodes after the hypergraph is segmented; the reasoning phase samples the complete hypergraph of hundreds of thousands of nodes. Since all query circuits and target circuits contain transistors, and transistors account for a small proportion of all devices, in order to reduce the matching time in the reasoning phase, the present application only needs to check whether the neighborhood of each transistor in the target circuit matches the query circuit. Specifically, for a query graph with a diameter of k hops, the k-hop neighborhood of each transistor in the target graph is extracted, and it is determined whether each neighborhood satisfies the subgraph isomorphism relationship with the query graph.
[0087] ②Embedding stage
[0088] The embedding phase is exactly the same as the model training phase. The model inputs the hypergraph association matrix H and the node feature matrix X, and the model outputs the embedding vector z.
[0089] ③Query stage
[0090] Unlike the query phase in the model training phase, only the embedding vectors of the two input hypergraphs are compared to determine whether the two graphs satisfy the subgraph relationship and give a prediction value. Since the model has completed learning in the training phase, there is no need to calculate the loss function and update the model parameters.
[0091] Regarding the model reasoning stage, in a specific embodiment: there are 2000 transistors in the target graph with a scale of 200,000 nodes, and the neighborhood of each transistor is sampled in the sampling stage. The obtained 2000 subgraphs plus the query graph, a total of 2001 graphs are input into the embedding stage to obtain 2001 embedding vectors. In the query stage, the embedding vector of the query graph is compared with the embedding vectors of the subgraphs of the 2000 target graphs in turn (i.e., the comparison is performed 2000 times), and it is predicted which subgraphs of the target graph match the query graph. If there is a match, the query graph and the subgraph of the target graph are input into the subsequent exact matching method for verification; if there is a match, the subgraph of the target graph will not undergo the subsequent verification process.
[0092] In summary, the fuzzy matching method uses a hypergraph neural network to quickly embed a subgraph centered on the transistor, avoiding the time-consuming search process in the precise method. In the query stage, only the size of the two embedding vectors needs to be compared, which significantly reduces the computational and time costs; according to previous studies, for the same pair of samples, the speed of vector comparison in sequential embedding is 10 times faster than that of a multilayer perceptron. In actual circuit matching scenarios, when identifying multiple query circuits within a target circuit, a hypergraph neural network model can be pre-trained and embeddings can be generated for the neighborhood of each transistor in the target circuit. In the matching stage of the query circuit, only the embedding vectors of different query circuits need to be calculated and the vector sizes compared.
[0093] (V) Use precise subgraph isomorphism methods to verify the matching results.
[0094] Exact matching is used to accurately verify the subgraphs in the target graph that may match the query graph. The specific operation process is as follows:
[0095] (1) Since VF3 can only process graphs, star expansion is used to convert the hypergraph into a graph. Figure 4 Two main conversion methods are shown. Compared with clique expansion, the graph generated by star expansion has more nodes and fewer edges. More importantly, star expansion can completely preserve the structural information of the graph, so this application uses this method to convert the target graph subgraph and query graph screened by the fuzzy matching process from a hypergraph to a graph.
[0096] (2) Call the Python-based VF3 library for verification to obtain the exact result of whether each pair of subgraph samples of the query graph and the target graph matches.
[0097] (VI) Verification of implementation examples.
[0098] The performance of the recognition method in this application was tested on query graphs of different sizes, and its running time and accuracy were compared with a series of representative subgraph matching methods.
[0099] (Baseline) Typical subgraph isomorphism algorithms are divided into two categories: fuzzy matching methods and exact matching methods. The following compares the recognition method of this application with the most advanced exact matching method VF3 and the most advanced fuzzy matching method NeuroMatch.
[0100] (Dataset) As shown in Table 1, 8 VCO designs are selected for model training and testing. First, Cadence Quantus is used to extract the parasitic parameters of the circuit and obtain the post-simulation netlist in dspf format; then, a netlist parser is developed to automatically capture device properties and connection relationships; based on the extracted information, a hypergraph is constructed using the HyperNetX library. In order to improve the efficiency of generating training datasets, the KaHyPar library is used to divide each case into sub-hypergraphs of 3000 to 5000 nodes, and the training set and validation set are randomly sampled from the sub-hypergraphs, with a ratio of 1:1 for positive and negative samples. Given a query circuit with a diameter of k hops, the test set consists of the k-hop neighborhood of all transistor nodes in each case.
[0101] Table 1: Statistics of the dataset
[0102]
[0103] (Experimental setup) The proposed hypergraph learning model was implemented using PyTorch, and the model was trained on a Linux server equipped with a 20-core Intel Xeon Gold 6133 CPU and an NVIDIA RTX 4090 GPU (24GB video memory), and the VF3Py library was used for exact matching. In the hypergraph learning model, 10 hypergraph convolutional layers were used, and the maximum allowed matching radius of the query graph was 5 hops; ReLU was used as the activation function, and the maximum margin loss was used as the loss function, with the margin set to 0.10; and the model with the highest accuracy on the validation set was selected for testing.
[0104] (Result Analysis) The proposed hypergraph learning model was evaluated on the validation set, and the query graph sizes and prediction accuracy are listed in Table 2. The sampling range is set from 2 hops to 5 hops, and the number of nodes in the query graph ranges from 13.62 to 221.14 on average. The accuracy of the graph neural network model of this application exceeds 92% on different query graph sizes.
[0105] Table 2: Relationship between query graph size and model accuracy during verification
[0106]
[0107] After the fuzzy matching, the subsequent exact matching further filtered out the false positive (FP) samples, while the false negative (FN) samples were ignored. The average matching results of the 2-hop query graph on 8 cases are shown in Table 3. Among the 4000 samples, only 3.50 were misclassified as negative, that is, the recall rate of the model was as high as 99.83%. The subsequent exact matching filtered out 234.00 false positive samples, increasing the accuracy from 94.07% to 99.91%.
[0108] Table 3: Average confusion matrix for validation on the 2-hop query graph of the validation set
[0109]
[0110] The performance of each method on the 2-hop query graph was further evaluated, and the results are summarized in Table 4. The running time of the recognition method of the present application includes four parts: subgraph sampling, model reasoning, hypergraph to graph conversion, and exact matching verification. The running time of NeuroMatch and VF3 baselines includes the first two parts and the last two parts, respectively. Compared with VF3, the method of the present application is 20.29 times faster on average while maintaining an accuracy of 99.91%, slightly lower than VF3; compared with NeuroMatch, the method of the present application significantly improves the matching accuracy by 16.46%, and the resulting increase in running time is acceptable. Overall, compared with other methods, the recognition method of the present application achieves the best comprehensive performance in terms of running time and accuracy.
[0111] Table 4: Recognition results on a 2-hop query graph. Running time: seconds
[0112]
[0113] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. An analog circuit matching method based on graph neural network, characterized in that: The method steps include: S1. Input two netlists, which are named target circuit and query circuit respectively; S2. Extract topology and device properties from the netlist using a netlist parser; S3. construct a hypergraph representation of the netlist and perform hypergraph segmentation; S4. Perform fuzzy matching of circuits based on graph neural network model to identify potential matching subgraphs; S5. Use the exact subgraph isomorphism method to verify the matching results.
2. The analog circuit matching method based on graph neural network according to claim 1, characterized in that: The netlist parser is an automated program developed based on Python language to extract device attributes and device connection relationships in the analog circuit post-simulation netlist.
3. The analog circuit matching method based on graph neural network according to claim 1, characterized in that: The specific process of constructing the netlist hypergraph in step S3 is as follows: S31. The transistor is represented as four nodes, which represent the four pins of the drain, source, gate and substrate respectively; the diode is represented as two nodes, which represent the two pins of the cathode and anode respectively; the four pins of the transistor and the two pins of the diode are connected by a hyperedge respectively; S32. Encode the parasitic capacitance, the parasitic resistance, the capacitance, the resistance, the I / O, the four pins of the transistor, and the two pins of the diode into an 11-dimensional one-hot vector; S33. Use the KaHyPar library to split the hypergraph. Generally, a hypergraph with 100,000 to 200,000 nodes is split into small-scale hypergraphs with 3,000 to 5,000 nodes, and the small-scale graphs are used for training. S34. After completing the hypergraph segmentation, start training the graph neural network model.
4. The analog circuit matching method based on graph neural network according to claim 1, characterized in that: The fuzzy matching in step S4 includes a sampling stage, an embedding stage and a query stage, and the graph neural network model includes a model training stage and a model reasoning stage. The model training stage and the model reasoning stage both include a sampling stage, an embedding stage and a query stage. The model training stage is to train the graph neural network model with existing data so that it can perform subgraph matching tasks. The model reasoning stage is to use the previously trained model to perform matching on the actual circuit.
5. The analog circuit matching method based on graph neural network according to claim 4 is characterized in that: About the model training phase: Sampling phase: From the target graph G T Randomly sample a node m and extract the k-hop neighborhood of node m and 2k hop neighborhood To form a positive example; then, from G T Sample another node n and its k-hop neighbors and Constitute a negative example; in order to prevent and Satisfying the subgraph isomorphism relationship, Add randomly generated nodes and hyperedges; Embedding stage: The obtained positive / negative example association matrix and node feature matrix are input into the GNN model to propagate node features; Query phase: obtain the predicted value through vector comparison, calculate the difference between the predicted value and the actual label through the loss function, and update the model parameters through back propagation.
6. The analog circuit matching method based on graph neural network according to claim 5, characterized in that: In the embedding stage, the association matrix and node feature matrix of the sampled hypergraph are input into the convolution layer to obtain the embedding vector; for the positive example, the query graph G Q Embedding z q Cannot be larger than the target graph G in any dimension T Embedding z t , that is, for positive samples, the expected z q In the embedding space, it is located at z t The lower left of; For negative samples, we expect z q Located in different locations.
7. The analog circuit matching method based on graph neural network according to claim 5, characterized in that: In the query phase, the embedding vectors of the two graphs are compared to determine whether the two graphs satisfy the subgraph relationship. q In any dimension, it is smaller than z t , then q is a subgraph of t, that is, the model predicts that q is a subgraph of t; if the condition that any dimension is less than is not satisfied, then q is not a subgraph of t.
8. The analog circuit matching method based on graph neural network according to claim 7, characterized in that: In the query stage, the specific steps of calculating the difference between the predicted value and the actual label through the loss function are: R1. Define E to measure the embedding vector z q and z t The degree of constraint violation, the goal of model learning: For positive examples, z q Less than or equal to z in any dimension t , that is, E is 0, indicating that the constraint is not violated; for negative examples, z q At least one dimension is greater than z t , and z q With z t The sample can only be judged as a negative example when E is greater than α, where α is an artificially set positive number; R2. Understand the goal of model learning from a spatial perspective: In the embedding space, E represents z q and z t The distance between the positive examples and the expected value z is , and the maximum boundary loss is used as the loss function. q In the embedding space, it is located at z t The lower left of ; and for negative examples, the expected z q Located elsewhere and related to z t The distance between is at least α; R3. Based on the above objectives, the following loss function is set: Where L is the loss function, z q and z t are the embedding vectors of the query graph q and the target graph t respectively, E is the degree of constraint violation, N is the negative example, P is the positive example, and α is the distance.
9. The analog circuit matching method based on graph neural network according to claim 5, characterized in that: About the model inference phase: Sampling phase: Check whether the neighborhood of each transistor in the target circuit matches the query circuit. Specifically, for a query graph with a diameter of k hops, extract the k-hop neighborhood of each transistor in the target graph and determine whether each neighborhood satisfies a subgraph isomorphism relationship with the query graph. Embedding stage: The model inputs the hypergraph association matrix H and node feature matrix X, and the model outputs the embedding vector z; Query phase: compare the embedding vectors of the two input hypergraphs to determine whether the two graphs satisfy the subgraph relationship and give a prediction value.
10. The analog circuit matching method based on graph neural network according to claim 1, characterized in that: The exact matching in step S5 is used to verify the subgraphs in the target graph that may match the query graph, and the specific operation process is as follows: S51. Convert the hypergraph into a graph using star expansion; S52. Call the VF3 library implemented in Python language to perform precise verification and obtain the precise result of whether each pair of subgraph samples of the query graph and the target graph matches.
Citation Information
Cited By
VLSI circuit layout optimization method and system based on deep learning
CN120524911A
